decompiled_code:
void __fastcall characterDataHandler_APD(const char *a1, const void *a2, int a3)
{
void *v4; // r12
char *v5; // rax
char *v6; // rax
char *v7; // rcx
__int64 i; // rax

v4 = calloc(a3 + 1, 1uLL);
memcpy(v4, a2, a3);
if ( !*a1 || strcmp(a1, "serviceURI") )
{
LABEL_3:
free(v4);
return;
}
v5 = (char *)calloc(1uLL, 0x110uLL);
if ( v5 )
{
v6 = strcpy(v5, (const char *)v4);
*((_QWORD *)v6 + 32) = 0LL;
v7 = v6;
*((_QWORD *)v6 + 33) = 0LL;
for ( i = *(_QWORD *)(*apd + 8LL); ; i = *(_QWORD *)(i + 264) )
{
if ( !i )
{
*(_QWORD *)(*apd + 8LL) = v7;
goto LABEL_3;
}
if ( !*(_QWORD *)(i + 264) )
break;
}
*((_QWORD *)v7 + 32) = i;
*(_QWORD *)(i + 264) = v7;
goto LABEL_3;
}
puts("Could not alloc memory for serviceURI!");
}

canonical_decompiled_code:
void __fastcall func0(const char *a1, const void *a2, int a3)
{
void *v4; // r12
char *v5; // rax
char *v6; // rax
char *v7; // rcx
__int64 i; // rax

v4 = calloc(a3 + 1, 1uLL);
memcpy(v4, a2, a3);
if ( !*a1 || strcmp(a1, "serviceURI") )
{
LABEL_3:
free(v4);
return;
}
v5 = (char *)calloc(1uLL, 0x110uLL);
if ( v5 )
{
v6 = strcpy(v5, (const char *)v4);
*((_QWORD *)v6 + 32) = 0LL;
v7 = v6;
*((_QWORD *)v6 + 33) = 0LL;
for ( i = *(_QWORD *)(*apd + 8LL); ; i = *(_QWORD *)(i + 264) )
{
if ( !i )
{
*(_QWORD *)(*apd + 8LL) = v7;
goto LABEL_3;
}
if ( !*(_QWORD *)(i + 264) )
break;
}
*((_QWORD *)v7 + 32) = i;
*(_QWORD *)(i + 264) = v7;
goto LABEL_3;
}
puts("Could not alloc memory for serviceURI!");
}

original_code:
static void characterDataHandler_APD(void *userData, const XML_Char *s, int len) {
  serviceURI_t *tmp_serviceURI;
  serviceURI_t *serviceURI;
  char *value;
  value = (char*)calloc(len+1, sizeof(char));
  memcpy(value, s, len);
  if(strcmp((const char*)userData, "") == 0) {
  }
  else if(strcmp((const char*)userData, "serviceURI") == 0) {
    if(!(serviceURI = (serviceURI_t*)calloc(1, sizeof(serviceURI_t)))) {
      printf("Could not alloc memory for serviceURI!\n");
      return;
    }
    strcpy(serviceURI->URI, value);
    serviceURI->prev = ((void *)0);
    serviceURI->next = ((void *)0);
    tmp_serviceURI = apd->postFileRepair->serviceURI_List;
    while(1) {
      if(tmp_serviceURI == ((void *)0)) {
        apd->postFileRepair->serviceURI_List = serviceURI;
        break;
      }
      if(tmp_serviceURI->next == ((void *)0)) {
        serviceURI->prev = tmp_serviceURI;
        tmp_serviceURI->next = serviceURI;
        break;
      }
      tmp_serviceURI = tmp_serviceURI->next;
    }
  }
  free(value);
}

canonical_original_code:
static void characterDataHandler_APD(void *userData, char *s, int len) {
  struct serviceURI *tmp_serviceURI;
  struct serviceURI *serviceURI;
  char *value;
  value = (char *)calloc(len+1, sizeof(char));
  memcpy(value, s, len);
  if(strcmp((char *)userData, "") == 0) {
  }
  else if(strcmp((char *)userData, "serviceURI") == 0) {
    if(!(serviceURI = (struct serviceURI *)calloc(1, sizeof(serviceURI_t)))) {
      printf("Could not alloc memory for serviceURI!\n");
      return;
    }
    strcpy(serviceURI->URI, value);
    serviceURI->prev = ((void *)0);
    serviceURI->next = ((void *)0);
    tmp_serviceURI = apd->postFileRepair->serviceURI_List;
    while(1) {
      if(tmp_serviceURI == ((void *)0)) {
        apd->postFileRepair->serviceURI_List = serviceURI;
        break;
      }
      if(tmp_serviceURI->next == ((void *)0)) {
        serviceURI->prev = tmp_serviceURI;
        tmp_serviceURI->next = serviceURI;
        break;
      }
      tmp_serviceURI = tmp_serviceURI->next;
    }
  }
  free(value);
}

variable_types:
userData
void *

variable_types:
s
char *

variable_types: len int

variable_types: struct serviceURI { char URI[256]; struct serviceURI *prev; struct serviceURI *next; } *

variable_types:
value
char *


decompiled_code:
char __fastcall startElementHandler_APD(char *a1, const char *a2, const char **a3)
{
_DWORD *v5; // rax
const char *v6; // r14
__int64 *v7; // r13
const char **v8; // r12
int v9; // er9
bool v10; // zf
_QWORD *v11; // r10
const char *v12; // rsi
const char **v13; // r12
int v14; // er9
_QWORD *v15; // rax
_BYTE *v16; // rax
_QWORD *v18; // [rsp+8h] [rbp-40h]

LOBYTE(v5) = (unsigned __int8)strcpy(a1, a2);
v6 = *a3;
if ( *a3 )
{
while ( strcmp(a2, "postFileRepair") )
{
v10 = strcmp(a2, "bmFileRepair") == 0;
LOBYTE(v5) = !v10;
if ( !v10 )
{
v8 = a3 + 1;
goto LABEL_6;
}
v11 = apd;
if ( !apd[1] )
{
v18 = apd;
v16 = calloc(1uLL, 0x100uLL);
v11 = v18;
v18[1] = v16;
if ( !v16 )
{
LOBYTE(v5) = puts("Could not alloc memory for bmFileRepair!");
return (char)v5;
}
*v16 = 0;
}
v8 = a3;
v10 = strcmp(v6, "sessionDescriptionURI") == 0;
LOBYTE(v5) = !v10;
if ( v10 )
{
v12 = a3[1];
v13 = a3 + 1;
a3 += 2;
LOBYTE(v5) = (unsigned __int8)strcpy((char *)v11[1], v12);
v6 = v13[1];
if ( !v6 )
return (char)v5;
}
else
{
LABEL_6:
v6 = v8[1];
a3 = v8 + 1;
if ( !v6 )
return (char)v5;
}
}
v7 = apd;
if ( !*apd )
{
v15 = calloc(1uLL, 0x10uLL);
*v7 = (__int64)v15;
if ( !v15 )
{
LOBYTE(v5) = puts("Could not alloc memory for postFileRepair!");
return (char)v5;
}
*v15 = 0LL;
v15[1] = 0LL;
}
v8 = a3 + 1;
if ( !strcmp(v6, "offsetTime") )
{
v9 = atoi(a3[1]);
v5 = (_DWORD *)*v7;
*(_DWORD *)*v7 = v9;
}
else
{
v10 = strcmp(v6, "randomTimePeriod") == 0;
LOBYTE(v5) = !v10;
if ( v10 )
{
v14 = atoi(a3[1]);
v5 = (_DWORD *)*v7;
*(_DWORD *)(*v7 + 4) = v14;
}
else
{
v8 = a3;
}
}
goto LABEL_6;
}
return (char)v5;
}

canonical_decompiled_code:
char __fastcall func2(char *a1, const char *a2, const char **a3)
{
_DWORD *v5; // rax
const char *v6; // r14
__int64 *v7; // r13
const char **v8; // r12
int v9; // er9
bool v10; // zf
_QWORD *v11; // r10
const char *v12; // rsi
const char **v13; // r12
int v14; // er9
_QWORD *v15; // rax
_BYTE *v16; // rax
_QWORD *v18; // [rsp+8h] [rbp-40h]

LOBYTE(v5) = (unsigned __int8)strcpy(a1, a2);
v6 = *a3;
if ( *a3 )
{
while ( strcmp(a2, "postFileRepair") )
{
v10 = strcmp(a2, "bmFileRepair") == 0;
LOBYTE(v5) = !v10;
if ( !v10 )
{
v8 = a3 + 1;
goto LABEL_6;
}
v11 = apd;
if ( !apd[1] )
{
v18 = apd;
v16 = calloc(1uLL, 0x100uLL);
v11 = v18;
v18[1] = v16;
if ( !v16 )
{
LOBYTE(v5) = puts("Could not alloc memory for bmFileRepair!");
return (char)v5;
}
*v16 = 0;
}
v8 = a3;
v10 = strcmp(v6, "sessionDescriptionURI") == 0;
LOBYTE(v5) = !v10;
if ( v10 )
{
v12 = a3[1];
v13 = a3 + 1;
a3 += 2;
LOBYTE(v5) = (unsigned __int8)strcpy((char *)v11[1], v12);
v6 = v13[1];
if ( !v6 )
return (char)v5;
}
else
{
LABEL_6:
v6 = v8[1];
a3 = v8 + 1;
if ( !v6 )
return (char)v5;
}
}
v7 = apd;
if ( !*apd )
{
v15 = calloc(1uLL, 0x10uLL);
*v7 = (__int64)v15;
if ( !v15 )
{
LOBYTE(v5) = puts("Could not alloc memory for postFileRepair!");
return (char)v5;
}
*v15 = 0LL;
v15[1] = 0LL;
}
v8 = a3 + 1;
if ( !strcmp(v6, "offsetTime") )
{
v9 = atoi(a3[1]);
v5 = (_DWORD *)*v7;
*(_DWORD *)*v7 = v9;
}
else
{
v10 = strcmp(v6, "randomTimePeriod") == 0;
LOBYTE(v5) = !v10;
if ( v10 )
{
v14 = atoi(a3[1]);
v5 = (_DWORD *)*v7;
*(_DWORD *)(*v7 + 4) = v14;
}
else
{
v8 = a3;
}
}
goto LABEL_6;
}
return (char)v5;
}

original_code:
static void startElementHandler_APD(void *userData, const char *name, const char **atts) {
  strcpy((char*)userData, name);
  while(*atts != ((void *)0)) {
    if(!strcmp(name, "postFileRepair")) {
      if(apd->postFileRepair == ((void *)0)) {
        if(!(apd->postFileRepair = (postFileRepair_t*)calloc(1, sizeof(postFileRepair_t)))) {
          printf("Could not alloc memory for postFileRepair!\n");
          return;
        }
        apd->postFileRepair->offsetTime = 0;
        apd->postFileRepair->randomTimePeriod = 0;
        apd->postFileRepair->serviceURI_List = ((void *)0);
      }
      if(!strcmp(*atts, "offsetTime")) {
        apd->postFileRepair->offsetTime = atoi(*(++atts));
      }
      else if(!strcmp(*atts, "randomTimePeriod")) {
        apd->postFileRepair->randomTimePeriod = atoi(*(++atts));
      }
    }
    else if(!strcmp(name, "bmFileRepair")) {
      if(apd->bmFileRepair == ((void *)0)) {
        if(!(apd->bmFileRepair = (bmFileRepair_t*)calloc(1, sizeof(bmFileRepair_t)))) {
          printf("Could not alloc memory for bmFileRepair!\n");
          return;
        }
        strcpy(apd->bmFileRepair->sessionDescriptionURI, "");
      }
      if(!strcmp(*atts, "sessionDescriptionURI")) {
        strcpy(apd->bmFileRepair->sessionDescriptionURI, *(++atts));
      }
    }
    else {
      atts ++;
    }
    atts++;
  }
}

canonical_original_code:
static void startElementHandler_APD(void *userData, char *name, char **atts) {
  strcpy((char *)userData, name);
  while(*atts != ((void *)0)) {
    if(!strcmp(name, "postFileRepair")) {
      if(apd->postFileRepair == ((void *)0)) {
        if(!(apd->postFileRepair = (struct postFileRepair *)calloc(1, sizeof(postFileRepair_t)))) {
          printf("Could not alloc memory for postFileRepair!\n");
          return;
        }
        apd->postFileRepair->offsetTime = 0;
        apd->postFileRepair->randomTimePeriod = 0;
        apd->postFileRepair->serviceURI_List = ((void *)0);
      }
      if(!strcmp(*atts, "offsetTime")) {
        apd->postFileRepair->offsetTime = atoi(*(++atts));
      }
      else if(!strcmp(*atts, "randomTimePeriod")) {
        apd->postFileRepair->randomTimePeriod = atoi(*(++atts));
      }
    }
    else if(!strcmp(name, "bmFileRepair")) {
      if(apd->bmFileRepair == ((void *)0)) {
        if(!(apd->bmFileRepair = (struct bmFileRepair *)calloc(1, sizeof(bmFileRepair_t)))) {
          printf("Could not alloc memory for bmFileRepair!\n");
          return;
        }
        strcpy(apd->bmFileRepair->sessionDescriptionURI, "");
      }
      if(!strcmp(*atts, "sessionDescriptionURI")) {
        strcpy(apd->bmFileRepair->sessionDescriptionURI, *(++atts));
      }
    }
    else {
      atts ++;
    }
    atts++;
  }
}

variable_types:
name
char *

variable_types:
atts
char **

return_type: void

user_defined_types: struct postFileRepair { unsigned int offsetTime; unsigned int randomTimePeriod; struct serviceURI *serviceURI_List; }

user_defined_types: struct bmFileRepair { char sessionDescriptionURI[256]; }

user_defined_types: struct serviceURI { char URI[256]; struct serviceURI *prev; struct serviceURI *next; }


FreeAPD

decompiled_code:
void __fastcall FreeAPD(void *ptr)
{
_QWORD *v1; // r8
_QWORD *v3; // rdi
void *v4; // rdi

v1 = *(_QWORD **)ptr;
if ( *(_QWORD *)ptr )
{
while ( 1 )
{
v3 = (_QWORD *)v1[1];
if ( !v3 )
break;
v1[1] = v3[33];
free(v3);
v1 = *(_QWORD **)ptr;
}
free(v1);
}
v4 = (void *)*((_QWORD *)ptr + 1);
if ( v4 )
free(v4);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
_QWORD *v1; // r8
_QWORD *v3; // rdi
void *v4; // rdi

v1 = *(_QWORD **)ptr;
if ( *(_QWORD *)ptr )
{
while ( 1 )
{
v3 = (_QWORD *)v1[1];
if ( !v3 )
break;
v1[1] = v3[33];
free(v3);
v1 = *(_QWORD **)ptr;
}
free(v1);
}
v4 = (void *)*((_QWORD *)ptr + 1);
if ( v4 )
free(v4);
free(ptr);
}

original_code:
void FreeAPD(apd_t *apd) {
 serviceURI_t *tmp_serviceURI;
 if(apd->postFileRepair != ((void *)0)) {
  while(1) {
   tmp_serviceURI = apd->postFileRepair->serviceURI_List;
   if(tmp_serviceURI != ((void *)0)) {
    apd->postFileRepair->serviceURI_List = tmp_serviceURI->next;
    free(tmp_serviceURI);
   }
   else {
    break;
   }
  }
  free(apd->postFileRepair);
 }
 if(apd->bmFileRepair != ((void *)0)) {
  free(apd->bmFileRepair);
 }
 free(apd);
}

canonical_original_code:
void FreeAPD(struct apd *apd) {
 struct serviceURI *tmp_serviceURI;
 if(apd->postFileRepair != ((void *)0)) {
  while(1) {
   tmp_serviceURI = apd->postFileRepair->serviceURI_List;
   if(tmp_serviceURI != ((void *)0)) {
    apd->postFileRepair->serviceURI_List = tmp_serviceURI->next;
    free(tmp_serviceURI);
   }
   else {
    break;
   }
  }
  free(apd->postFileRepair);
 }
 if(apd->bmFileRepair != ((void *)0)) {
  free(apd->bmFileRepair);
 }
 free(apd);
}

variable_types: struct apd { struct postFileRepair { unsigned int offsetTime; unsigned int randomTimePeriod; struct serviceURI { char URI[256]; struct serviceURI *prev; struct serviceURI *next; } *serviceURI_List; } *postFileRepair; struct bmFileRepair { char sessionDescriptionURI[256]; } *bmFileRepair; } *

user_defined_types: struct apd { struct postFileRepair *postFileRepair; struct bmFileRepair *bmFileRepair; }


original_code:
trans_block_t* rs_fec_encode_src_block(char *data, unsigned long long len, unsigned int sbn,
            unsigned short es_len, int rs, unsigned int max_sb_len) {
    trans_block_t *tr_block;
    trans_unit_t *tr_unit;
    unsigned int i;
    char *ptr;
    void *code;
    char *src[((1 << 8) - 1)];
    unsigned int k;
    unsigned int n;
    unsigned int max_k;
    unsigned int max_n;
    unsigned long long data_left;
    div_t div_k;
    div_t div_max_n;
    div_t div_n;
 data_left = len;
    max_k = max_sb_len;
    div_k = div((unsigned int)len, es_len);
    if(div_k.rem == 0) {
            k = (unsigned int)div_k.quot;
    }
    else {
            k = (unsigned int)div_k.quot + 1;
    }
    div_max_n = div((max_k * (100 + rs)), 100);
    max_n = (unsigned int)div_max_n.quot;
    div_n = div((k * max_n), (max_k));
    n = (unsigned int)div_n.quot;
    code = fec_new(k, n);
 tr_block = create_block();
    if(tr_block == ((void *)0)) {
            return tr_block;
    }
    tr_unit = create_units(n);
    if(tr_unit == ((void *)0)) {
            free(tr_block);
            return ((void *)0);
    }
    ptr = data;
    tr_block->unit_list = tr_unit;
    tr_block->sbn = sbn;
    tr_block->n = n;
    tr_block->k = k;
    tr_block->max_k = max_k;
    tr_block->max_n = max_n;
    for(i = 0; i < k; i++) {
           tr_unit->esi = i;
            tr_unit->len = data_left < es_len ? (unsigned short)data_left : es_len;
            if(!(tr_unit->data = (char*)calloc(es_len, sizeof(char)))) {
                    printf("Could not alloc memory for transport unit's data!\n");
                    tr_unit = tr_block->unit_list;
                    while(tr_unit != ((void *)0)) {
                            free(tr_unit->data);
                            tr_unit++;
                    }
                    free(tr_block->unit_list);
                    free(tr_block);
                    return ((void *)0);
            }
            memcpy(tr_unit->data, ptr, tr_unit->len);
            src[i] = tr_unit->data;
            ptr += tr_unit->len;
            data_left -= tr_unit->len;
            tr_unit++;
    }
    for (i = 0; i < (n - k); i++) {
            tr_unit->esi = k+i;
            tr_unit->len = es_len;
            if(!(tr_unit->data = (char*)calloc(es_len, sizeof(char)))) {
                    printf("Could not alloc memory for transport unit's data!\n");
                    tr_unit = tr_block->unit_list;
                    while(tr_unit != ((void *)0)) {
                            free(tr_unit->data);
                            tr_unit++;
                    }
                    free(tr_block->unit_list);
                    free(tr_block);
                    return ((void *)0);
            }
            fec_encode(code, (void**)src, tr_unit->data, k+i, es_len);
            tr_unit++;
    }
    fec_free(code);
    return tr_block;
}

canonical_original_code:
struct trans_block *rs_fec_encode_src_block(char *data, unsigned long long len, unsigned int sbn, unsigned short es_len, int rs, unsigned int max_sb_len) {
    struct trans_block *tr_block;
    struct trans_unit *tr_unit;
    unsigned int i;
    char *ptr;
    void *code;
    char *src[-1];
    unsigned int k;
    unsigned int n;
    unsigned int max_k;
    unsigned int max_n;
    unsigned long long data_left;
    struct div_t div_k;
    struct div_t div_max_n;
    struct div_t div_n;
 data_left = len;
    max_k = max_sb_len;
    div_k = div((unsigned int)len, es_len);
    if(div_k.rem == 0) {
            k = (unsigned int)div_k.quot;
    }
    else {
            k = (unsigned int)div_k.quot + 1;
    }
    div_max_n = div((max_k * (100 + rs)), 100);
    max_n = (unsigned int)div_max_n.quot;
    div_n = div((k * max_n), (max_k));
    n = (unsigned int)div_n.quot;
    code = fec_new(k, n);
 tr_block = create_block();
    if(tr_block == ((void *)0)) {
            return tr_block;
    }
    tr_unit = create_units(n);
    if(tr_unit == ((void *)0)) {
            free(tr_block);
            return ((void *)0);
    }
    ptr = data;
    tr_block->unit_list = tr_unit;
    tr_block->sbn = sbn;
    tr_block->n = n;
    tr_block->k = k;
    tr_block->max_k = max_k;
    tr_block->max_n = max_n;
    for(i = 0; i < k; i++) {
           tr_unit->esi = i;
            tr_unit->len = data_left < es_len ? (unsigned short)data_left : es_len;
            if(!(tr_unit->data = (char *)calloc(es_len, sizeof(char)))) {
                    printf("Could not alloc memory for transport unit's data!\n");
                    tr_unit = tr_block->unit_list;
                    while(tr_unit != ((void *)0)) {
                            free(tr_unit->data);
                            tr_unit++;
                    }
                    free(tr_block->unit_list);
                    free(tr_block);
                    return ((void *)0);
            }
            memcpy(tr_unit->data, ptr, tr_unit->len);
            src[i] = tr_unit->data;
            ptr += tr_unit->len;
            data_left -= tr_unit->len;
            tr_unit++;
    }
    for (i = 0; i < (n - k); i++) {
            tr_unit->esi = k+i;
            tr_unit->len = es_len;
            if(!(tr_unit->data = (char *)calloc(es_len, sizeof(char)))) {
                    printf("Could not alloc memory for transport unit's data!\n");
                    tr_unit = tr_block->unit_list;
                    while(tr_unit != ((void *)0)) {
                            free(tr_unit->data);
                            tr_unit++;
                    }
                    free(tr_block->unit_list);
                    free(tr_block);
                    return ((void *)0);
            }
            fec_encode(code, (void **)src, tr_unit->data, k+i, es_len);
            tr_unit++;
    }
    fec_free(code);
    return tr_block;
}

variable_types:
data
char *

variable_types:
len
unsigned long long

variable_types:
sbn
unsigned int

variable_types: rs int

variable_types: struct trans_block { unsigned int sbn; struct trans_unit { struct trans_unit *prev; struct trans_unit *next; unsigned int esi; unsigned short len; char *data; long offset; unsigned char used; } *unit_list; struct trans_unit *last_unit; unsigned int nb_of_rx_units; unsigned int n; unsigned int k; unsigned int max_k; unsigned int max_n; unsigned char finite_field; } *

variable_types:
i
unsigned int

variable_types:
ptr
char *

variable_types:
code
void *

variable_types:
src
char *[-1]

variable_types:
k
unsigned int

variable_types:
n
unsigned int

user_defined_types: struct trans_block { unsigned int sbn; struct trans_unit *unit_list; struct trans_unit *last_unit; unsigned int nb_of_rx_units; unsigned int n; unsigned int k; unsigned int max_k; unsigned int max_n; unsigned char finite_field; }


original_code:
char *rs_fec_decode_src_block(trans_block_t *tr_block, unsigned long long *block_len,
         unsigned short es_len) {
    char *buf = ((void *)0);
    trans_unit_t *next_tu;
    trans_unit_t *tu;
    unsigned long long len;
    void *code;
    char *dst[((1 << 8) - 1)];
    int index[((1 << 8) - 1)];
    unsigned int i = 0;
    unsigned int k;
    unsigned int n;
    div_t div_n;
    k = tr_block->k;
    div_n = div((k * tr_block->max_n), tr_block->max_k);
    n = (unsigned int)div_n.quot;
    len = es_len*tr_block->k;
    code = fec_new(k, n);
    if(!(buf = (char*)calloc((unsigned int)(len + 1), sizeof(char)))) {
            printf("Could not alloc memory for buf!\n");
            *block_len = 0;
            return ((void *)0);
    }
    next_tu = tr_block->unit_list;
    while(next_tu != ((void *)0)) {
            tu = next_tu;
            dst[i] = tu->data;
            index[i] = tu->esi;
            next_tu = tu->next;
            i++;
    }
    fec_decode(code, (void**)dst, index, es_len);
    fec_free(code);
    for(i = 0; i < k; i++) {
            memcpy(buf + i*es_len, dst[i], es_len);
    }
    next_tu = tr_block->unit_list;
   *block_len = len;
    return buf;
}

canonical_original_code:
char *rs_fec_decode_src_block(struct trans_block *tr_block, unsigned long long *block_len, unsigned short es_len) {
    char *buf = ((void *)0);
    struct trans_unit *next_tu;
    struct trans_unit *tu;
    unsigned long long len;
    void *code;
    char *dst[-1];
    int index[-1];
    unsigned int i = 0;
    unsigned int k;
    unsigned int n;
    struct div_t div_n;
    k = tr_block->k;
    div_n = div((k * tr_block->max_n), tr_block->max_k);
    n = (unsigned int)div_n.quot;
    len = es_len*tr_block->k;
    code = fec_new(k, n);
    if(!(buf = (char *)calloc((unsigned int)(len + 1), sizeof(char)))) {
            printf("Could not alloc memory for buf!\n");
            *block_len = 0;
            return ((void *)0);
    }
    next_tu = tr_block->unit_list;
    while(next_tu != ((void *)0)) {
            tu = next_tu;
            dst[i] = tu->data;
            index[i] = tu->esi;
            next_tu = tu->next;
            i++;
    }
    fec_decode(code, (void **)dst, index, es_len);
    fec_free(code);
    for(i = 0; i < k; i++) {
            memcpy(buf + i*es_len, dst[i], es_len);
    }
    next_tu = tr_block->unit_list;
   *block_len = len;
    return buf;
}

variable_types:
buf
char *

variable_types: struct trans_unit { struct trans_unit *prev; struct trans_unit *next; unsigned int esi; unsigned short len; char *data; long offset; unsigned char used; } *

variable_types:
dst
char *[-1]

variable_types:
index
int [-1]

return_type: char *


decompiled_code:
void *create_object()
{
void *v0; // r12

v0 = calloc(1uLL, 0x78uLL);
if ( !v0 )
puts("Could not alloc memory for transport object!");
return v0;
}

canonical_decompiled_code:
void *func0()
{
void *v0; // r12

v0 = calloc(1uLL, 0x78uLL);
if ( !v0 )
puts("Could not alloc memory for transport object!");
return v0;
}

original_code:
trans_obj_t* create_object(void) {
 trans_obj_t *obj = ((void *)0);
 if (!(obj = (trans_obj_t*)calloc(1, sizeof(trans_obj_t)))) {
  printf("Could not alloc memory for transport object!\n");
  return ((void *)0);
 }
 return obj;
}

canonical_original_code:
struct trans_obj *create_object() {
 struct trans_obj *obj = ((void *)0);
 if (!(obj = (struct trans_obj *)calloc(1, sizeof(trans_obj_t)))) {
  printf("Could not alloc memory for transport object!\n");
  return ((void *)0);
 }
 return obj;
}

variable_types: struct trans_obj { struct trans_obj *prev; struct trans_obj *next; struct trans_block { unsigned int sbn; struct trans_unit { struct trans_unit *prev; struct trans_unit *next; unsigned int esi; unsigned short len; char *data; long offset; unsigned char used; } *unit_list; struct trans_unit *last_unit; unsigned int nb_of_rx_units; unsigned int n; unsigned int k; unsigned int max_k; unsigned int max_n; unsigned char finite_field; } *block_list; unsigned int nb_of_ready_blocks; unsigned char fec_enc_id; unsigned short fec_inst_id; unsigned char content_enc_algo; unsigned long long len; unsigned long long rx_bytes; unsigned long long toi; unsigned int es_len; unsigned int max_sb_len; struct blocking_struct { unsigned int N; unsigned int I; unsigned int A_large; unsigned int A_small; } *bs; char *tmp_filename; int fd; char *tmp_st_filename; int fd_st; double last_print_rx_percent; } *

user_defined_types: struct trans_obj { struct trans_obj *prev; struct trans_obj *next; struct trans_block *block_list; unsigned int nb_of_ready_blocks; unsigned char fec_enc_id; unsigned short fec_inst_id; unsigned char content_enc_algo; unsigned long long len; unsigned long long rx_bytes; unsigned long long toi; unsigned int es_len; unsigned int max_sb_len; struct blocking_struct *bs; char *tmp_filename; int fd; char *tmp_st_filename; int fd_st; double last_print_rx_percent; }


decompiled_code:
void *create_block()
{
void *v0; // r12

v0 = calloc(1uLL, 0x30uLL);
if ( !v0 )
puts("Could not alloc memory for transport block!");
return v0;
}

canonical_decompiled_code:
void *func1()
{
void *v0; // r12

v0 = calloc(1uLL, 0x30uLL);
if ( !v0 )
puts("Could not alloc memory for transport block!");
return v0;
}

original_code:
trans_block_t* create_block(void) {
 trans_block_t *block = ((void *)0);
 if (!(block = (trans_block_t*)calloc(1, sizeof(trans_block_t)))) {
  printf("Could not alloc memory for transport block!\n");
  return ((void *)0);
 }
 return block;
}

canonical_original_code:
struct trans_block *create_block() {
 struct trans_block *block = ((void *)0);
 if (!(block = (struct trans_block *)calloc(1, sizeof(trans_block_t)))) {
  printf("Could not alloc memory for transport block!\n");
  return ((void *)0);
 }
 return block;
}

return_type: struct trans_block { unsigned int sbn; struct trans_unit { struct trans_unit *prev; struct trans_unit *next; unsigned int esi; unsigned short len; char *data; long offset; unsigned char used; } *unit_list; struct trans_unit *last_unit; unsigned int nb_of_rx_units; unsigned int n; unsigned int k; unsigned int max_k; unsigned int max_n; unsigned char finite_field; } *


decompiled_code:
void *__fastcall create_units(size_t nmemb)
{
void *v1; // r12

v1 = calloc((unsigned int)nmemb, 0x30uLL);
if ( !v1 )
printf("Could not alloc memory for %i transport units!\n", (unsigned int)nmemb);
return v1;
}

canonical_decompiled_code:
void *__fastcall func2(size_t nmemb)
{
void *v1; // r12

v1 = calloc((unsigned int)nmemb, 0x30uLL);
if ( !v1 )
printf("Could not alloc memory for %i transport units!\n", (unsigned int)nmemb);
return v1;
}

original_code:
trans_unit_t* create_units(unsigned int number) {
 trans_unit_t *unit = ((void *)0);
 if (!(unit = (trans_unit_t*)calloc(number, sizeof(trans_unit_t)))) {
  printf("Could not alloc memory for %i transport units!\n", number);
 }
 return unit;
}

canonical_original_code:
struct trans_unit *create_units(unsigned int number) {
 struct trans_unit *unit = ((void *)0);
 if (!(unit = (struct trans_unit *)calloc(number, sizeof(trans_unit_t)))) {
  printf("Could not alloc memory for %i transport units!\n", number);
 }
 return unit;
}

variable_types:
number
unsigned int

return_type: struct trans_unit { struct trans_unit *prev; struct trans_unit *next; unsigned int esi; unsigned short len; char *data; long offset; unsigned char used; } *


decompiled_code:
void __fastcall free_units(__int64 a1)
{
_QWORD *v2; // rbp
void *v3; // rdi
_QWORD *v4; // rbx

v2 = *(_QWORD **)(a1 + 8);
if ( v2 )
{
while ( 1 )
{
v3 = (void *)v2[3];
if ( v3 )
free(v3);
v4 = (_QWORD *)v2[1];
free(v2);
if ( !v4 )
break;
v2 = v4;
}
}
*(_QWORD *)(a1 + 8) = 0LL;
}

original_code:
void free_units(trans_block_t *tb) {
  trans_unit_t *tu = ((void *)0);
  trans_unit_t *next_tu = ((void *)0);
  next_tu = tb->unit_list;
  while(next_tu != ((void *)0)) {
    tu = next_tu;
    if(tu->data != ((void *)0)) {
      free(tu->data);
      tu->data = ((void *)0);
    }
    next_tu = tu->next;
    free(tu);
  }
  tb->unit_list = ((void *)0);
}

canonical_original_code:
void free_units(struct trans_block *tb) {
  struct trans_unit *tu = ((void *)0);
  struct trans_unit *next_tu = ((void *)0);
  next_tu = tb->unit_list;
  while(next_tu != ((void *)0)) {
    tu = next_tu;
    if(tu->data != ((void *)0)) {
      free(tu->data);
      tu->data = ((void *)0);
    }
    next_tu = tu->next;
    free(tu);
  }
  tb->unit_list = ((void *)0);
}

user_defined_types: struct trans_unit { struct trans_unit *prev; struct trans_unit *next; unsigned int esi; unsigned short len; char *data; long offset; unsigned char used; }


original_code:
void free_units2(trans_block_t *tb) {
    trans_unit_t *tu = ((void *)0);
    trans_unit_t *current_tu = ((void *)0);
 char *data = ((void *)0);
 unsigned short data_buffer_len;
    current_tu = tb->unit_list;
    while(current_tu != ((void *)0)) {
        tu = current_tu;
  data = tu->data;
  data_buffer_len = tu->len;
  current_tu = tu->next;
  memset(tu, 0, sizeof(trans_unit_t));
  tu->data = data;
  tu->len = data_buffer_len;
    }
    tb->unit_list = ((void *)0);
}

canonical_original_code:
void free_units2(struct trans_block *tb) {
    struct trans_unit *tu = ((void *)0);
    struct trans_unit *current_tu = ((void *)0);
 char *data = ((void *)0);
 unsigned short data_buffer_len;
    current_tu = tb->unit_list;
    while(current_tu != ((void *)0)) {
        tu = current_tu;
  data = tu->data;
  data_buffer_len = tu->len;
  current_tu = tu->next;
  memset(tu, 0, sizeof(trans_unit_t));
  tu->data = data;
  tu->len = data_buffer_len;
    }
    tb->unit_list = ((void *)0);
}

variable_types:
data
char *


original_code:
int insert_unit(trans_unit_t *tu, trans_block_t *tb, trans_obj_t *to) {
    trans_unit_t *tmp;
    int retval = 0;
    tmp = tb->unit_list;
    if(tmp == ((void *)0)) {
        to->rx_bytes += tu->len;
        if(to->rx_bytes > to->len) {
            to->rx_bytes = to->len;
        }
        tb->nb_of_rx_units++;
        tb->unit_list = tu;
        return retval;
    }
    for(;;) {
        if(tu->esi < tmp->esi) {
            to->rx_bytes += tu->len;
            if(to->rx_bytes > to->len) {
                to->rx_bytes = to->len;
            }
            tb->nb_of_rx_units++;
            if(tmp->prev == ((void *)0)) {
                tu->next = tmp;
                tu->prev = tmp->prev;
                tmp->prev = tu;
                tb->unit_list = tu;
            }
            else {
                tu->next = tmp;
                tu->prev = tmp->prev;
                tmp->prev->next = tu;
                tmp->prev = tu;
            }
            break;
        }
        else if(tu->esi == tmp->esi) {
            retval = 1;
            break;
        }
        if(tmp->next == ((void *)0)) {
            to->rx_bytes += tu->len;
            if(to->rx_bytes > to->len) {
                to->rx_bytes = to->len;
            }
            tb->nb_of_rx_units++;
            tu->next = tmp->next;
            tu->prev = tmp;
            tmp->next = tu;
            break;
        }
        tmp = tmp->next;
    }
    return retval;
}

canonical_original_code:
int insert_unit(struct trans_unit *tu, struct trans_block *tb, struct trans_obj *to) {
    struct trans_unit *tmp;
    int retval = 0;
    tmp = tb->unit_list;
    if(tmp == ((void *)0)) {
        to->rx_bytes += tu->len;
        if(to->rx_bytes > to->len) {
            to->rx_bytes = to->len;
        }
        tb->nb_of_rx_units++;
        tb->unit_list = tu;
        return retval;
    }
    for(;;) {
        if(tu->esi < tmp->esi) {
            to->rx_bytes += tu->len;
            if(to->rx_bytes > to->len) {
                to->rx_bytes = to->len;
            }
            tb->nb_of_rx_units++;
            if(tmp->prev == ((void *)0)) {
                tu->next = tmp;
                tu->prev = tmp->prev;
                tmp->prev = tu;
                tb->unit_list = tu;
            }
            else {
                tu->next = tmp;
                tu->prev = tmp->prev;
                tmp->prev->next = tu;
                tmp->prev = tu;
            }
            break;
        }
        else if(tu->esi == tmp->esi) {
            retval = 1;
            break;
        }
        if(tmp->next == ((void *)0)) {
            to->rx_bytes += tu->len;
            if(to->rx_bytes > to->len) {
                to->rx_bytes = to->len;
            }
            tb->nb_of_rx_units++;
            tu->next = tmp->next;
            tu->prev = tmp;
            tmp->next = tu;
            break;
        }
        tmp = tmp->next;
    }
    return retval;
}

variable_types: struct trans_block { unsigned int sbn; struct trans_unit *unit_list; struct trans_unit *last_unit; unsigned int nb_of_rx_units; unsigned int n; unsigned int k; unsigned int max_k; unsigned int max_n; unsigned char finite_field; } *

variable_types: struct trans_obj { struct trans_obj *prev; struct trans_obj *next; struct trans_block *block_list; unsigned int nb_of_ready_blocks; unsigned char fec_enc_id; unsigned short fec_inst_id; unsigned char content_enc_algo; unsigned long long len; unsigned long long rx_bytes; unsigned long long toi; unsigned int es_len; unsigned int max_sb_len; struct blocking_struct { unsigned int N; unsigned int I; unsigned int A_large; unsigned int A_small; } *bs; char *tmp_filename; int fd; char *tmp_st_filename; int fd_st; double last_print_rx_percent; } *

variable_types: retval int

return_type: int


decompiled_code:
__int64 __fastcall sdp_attr_get(__int64 a1, const char *a2)
{
__int64 v2; // rbx
int v3; // eax
_QWORD *v4; // rbp
__int64 v5; // r12
int v6; // er13
int v7; // ebx
int v8; // er15

v2 = *(_QWORD *)(a1 + 136);
v3 = osip_list_size(v2);
if ( !v3 )
return 0LL;
v4 = *(_QWORD **)(v2 + 8);
v5 = v4[1];
if ( v3 <= 0 )
return 0LL;
v6 = v3;
v7 = 0;
v8 = v3 - 1;
while ( strcmp(a2, *(const char **)v5) )
{
if ( v8 > v7 )
{
v4 = (_QWORD *)*v4;
v5 = v4[1];
}
if ( v6 == ++v7 )
return 0LL;
}
return *(_QWORD *)(v5 + 8);
}

original_code:
char* sdp_attr_get(sdp_message_t *sdp, char *attr_name) {
 osip_list_t *list;
 __node_t *node;
 sdp_attribute_t *attr;
 int size;
 int i;
 list = sdp->a_attributes;
 size = osip_list_size(list);
 if(size == 0) {
  return ((void *)0);
 }
 node = list->node;
 attr = (sdp_attribute_t*)node->element;
 for(i = 0; i < size; i++) {
  if(strcmp(attr_name, attr->a_att_field) == 0) {
   return attr->a_att_value;
  }
  if(i < size - 1) {
   node = (__node_t*)node->next;
   attr = (sdp_attribute_t*)node->element;
  }
 }
 return ((void *)0);
}

canonical_original_code:
char *sdp_attr_get(struct sdp_message *sdp, char *attr_name) {
 struct osip_list *list;
 struct __node *node;
 struct sdp_attribute *attr;
 int size;
 int i;
 list = sdp->a_attributes;
 size = osip_list_size(list);
 if(size == 0) {
  return ((void *)0);
 }
 node = list->node;
 attr = (struct sdp_attribute *)node->element;
 for(i = 0; i < size; i++) {
  if(strcmp(attr_name, attr->a_att_field) == 0) {
   return attr->a_att_value;
  }
  if(i < size - 1) {
   node = (struct __node *)node->next;
   attr = (struct sdp_attribute *)node->element;
  }
 }
 return ((void *)0);
}

variable_types: struct sdp_message { char *v_version; char *o_username; char *o_sess_id; char *o_sess_version; char *o_nettype; char *o_addrtype; char *o_addr; char *s_name; char *i_info; char *u_uri; struct osip_list { int nb_elt; struct __node { void *next; void *element; } *node; } *e_emails; struct osip_list *p_phones; struct sdp_connection { char *c_nettype; char *c_addrtype; char *c_addr; char *c_addr_multicast_ttl; char *c_addr_multicast_int; } *c_connection; struct osip_list *b_bandwidths; struct osip_list *t_descrs; char *z_adjustments; struct sdp_key { char *k_keytype; char *k_keydata; } *k_key; struct osip_list *a_attributes; struct osip_list *m_medias; } *

variable_types: struct sdp_attribute { char *a_att_field; char *a_att_value; } *

variable_types: size int

variable_types: i int

user_defined_types: struct sdp_message { char *v_version; char *o_username; char *o_sess_id; char *o_sess_version; char *o_nettype; char *o_addrtype; char *o_addr; char *s_name; char *i_info; char *u_uri; struct osip_list *e_emails; struct osip_list *p_phones; struct sdp_connection *c_connection; struct osip_list *b_bandwidths; struct osip_list *t_descrs; char *z_adjustments; struct sdp_key *k_key; struct osip_list *a_attributes; struct osip_list *m_medias; }

user_defined_types: struct osip_list { int nb_elt; struct __node *node; }


decompiled_code:
void __fastcall sf_free(void **a1)
{
if ( a1 )
{
free(*a1);
free(a1[1]);
free(a1[2]);
free(a1[3]);
free(a1[4]);
}
}

canonical_decompiled_code:
void __fastcall func1(void **a1)
{
if ( a1 )
{
free(*a1);
free(a1[1]);
free(a1[2]);
free(a1[3]);
free(a1[4]);
}
}

original_code:
void sf_free(sf_t *sf) {
 if(sf == ((void *)0)) {
   return;
 }
 free(sf->filter_mode);
 free(sf->net_type);
 free(sf->addr_type);
 free(sf->dest_addr);
 free(sf->src_addr);
}

canonical_original_code:
void sf_free(struct sf *sf) {
 if(sf == ((void *)0)) {
   return;
 }
 free(sf->filter_mode);
 free(sf->net_type);
 free(sf->addr_type);
 free(sf->dest_addr);
 free(sf->src_addr);
}

variable_types: struct sf { char *filter_mode; char *net_type; char *addr_type; char *dest_addr; char *src_addr; } *


decompiled_code:
__int64 __fastcall fec_dec_free(_QWORD *a1)
{
_QWORD *v1; // rbx
__int64 result; // rax

if ( a1 )
{
v1 = (_QWORD *)a1[2];
if ( v1 )
{
while ( 1 )
{
free(a1);
result = v1[2];
a1 = v1;
if ( !result )
break;
v1 = (_QWORD *)v1[2];
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
_QWORD *v1; // rbx
__int64 result; // rax

if ( a1 )
{
v1 = (_QWORD *)a1[2];
if ( v1 )
{
while ( 1 )
{
free(a1);
result = v1[2];
a1 = v1;
if ( !result )
break;
v1 = (_QWORD *)v1[2];
}
}
}
return result;
}

original_code:
void fec_dec_free(fec_dec_t *fec_dec) {
 fec_dec_t *current;
 fec_dec_t *next;
 if(fec_dec == ((void *)0)) {
  return;
 }
 current = fec_dec;
 while(current->next != ((void *)0)) {
  next = current->next;
  free(current);
  current = next;
 }
}

canonical_original_code:
void fec_dec_free(struct fec_dec *fec_dec) {
 struct fec_dec *current;
 struct fec_dec *next;
 if(fec_dec == ((void *)0)) {
  return;
 }
 current = fec_dec;
 while(current->next != ((void *)0)) {
  next = current->next;
  free(current);
  current = next;
 }
}

variable_types: struct fec_dec { unsigned int index; short fec_enc_id; int fec_inst_id; struct fec_dec *next; } *


decompiled_code:
void __fastcall __noreturn start_flute_process(void *a1)
{
char v1; // al

v1 = *((_BYTE *)a1 + 61);
if ( v1 )
{
if ( v1 == 1 )
flute_receiver(a1, (char *)a1 + 7384);
}
else
{
flute_sender(a1, (char *)a1 + 7384, (char *)a1 + 7392);
if ( *((int *)a1 + 17) > 0 )
printf("Total bytes sent: %llu\n", *((_QWORD *)a1 + 924));
}
pthread_exit(0LL);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(void *a1)
{
char v1; // al

v1 = *((_BYTE *)a1 + 61);
if ( v1 )
{
if ( v1 == 1 )
flute_receiver(a1, (char *)a1 + 7384);
}
else
{
flute_sender(a1, (char *)a1 + 7384, (char *)a1 + 7392);
if ( *((int *)a1 + 17) > 0 )
printf("Total bytes sent: %llu\n", *((_QWORD *)a1 + 924));
}
pthread_exit(0LL);
}

original_code:
void* start_flute_process(void *t_par) {
  thread_params_t *t_p;
  int retval = 0;
  t_p = (thread_params_t*)t_par;
  if(t_p->a.alc_a.mode == 0) {
 retval = flute_sender(&t_p->a, &t_p->s_id, &t_p->session_size);
 if(t_p->a.alc_a.verbosity > 0) {
   printf("Total bytes sent: %llu\n", t_p->session_size);
 }
  }
  else if(t_p->a.alc_a.mode == 1) {
 retval = flute_receiver(&t_p->a, &t_p->s_id);
  }
 pthread_exit(0);
  return ((void *)0);
}

canonical_original_code:
void *start_flute_process(void *t_par) {
  struct thread_params *t_p;
  int retval = 0;
  t_p = (struct thread_params *)t_par;
  if(t_p->a.alc_a.mode == 0) {
 retval = flute_sender(&t_p->a, &t_p->s_id, &t_p->session_size);
 if(t_p->a.alc_a.verbosity > 0) {
   printf("Total bytes sent: %llu\n", t_p->session_size);
 }
  }
  else if(t_p->a.alc_a.mode == 1) {
 retval = flute_receiver(&t_p->a, &t_p->s_id);
  }
 pthread_exit(0);
  return ((void *)0);
}

variable_types: struct thread_params { struct arguments { struct alc_arguments { unsigned long long tsi; unsigned long long start_time; unsigned long long stop_time; char *port; char *addr; char *intface; char *intface_name; unsigned int addr_family; unsigned char addr_type; unsigned char mode; unsigned char nb_channel; unsigned char cc_id; unsigned char rx_memory_mode; int verbosity; char *src_addr; char base_dir[1024]; int accept_expired_fdt_inst; int use_ssm; unsigned int tx_rate; unsigned char ttl; unsigned short nb_tx; int simul_losses; double loss_ratio1; double loss_ratio2; unsigned short fec_ratio; unsigned short es_len; unsigned int max_sb_len; unsigned char fec_enc_id; unsigned short fec_inst_id; int use_fec_oti_ext_hdr; unsigned char encode_content; int half_word; int optimize_tx_rate; int calculate_session_size; } alc_a; char repair[1024]; char file_path[1024]; int log_fd; int rx_automatic; int open_file; char sdp_file[1024]; int rx_object; int name_incomplete_objects; unsigned short complete_fdt; int file_table_output; unsigned long long toi; char fdt_file[1024]; int cont; int send_session_close_packets; char requested_blocks_file[1024]; char flute_conf_file[1024]; struct sdp_message { char *v_version; char *o_username; char *o_sess_id; char *o_sess_version; char *o_nettype; char *o_addrtype; char *o_addr; char *s_name; char *i_info; char *u_uri; struct osip_list { int nb_elt; struct __node { void *next; void *element; } *node; } *e_emails; struct osip_list *p_phones; struct sdp_connection { char *c_nettype; char *c_addrtype; char *c_addr; char *c_addr_multicast_ttl; char *c_addr_multicast_int; } *c_connection; struct osip_list *b_bandwidths; struct osip_list *t_descrs; char *z_adjustments; struct sdp_key { char *k_keytype; char *k_keydata; } *k_key; struct osip_list *a_attributes; struct osip_list *m_medias; } *sdp; struct sf { char *filter_mode; char *net_type; char *addr_type; char *dest_addr; char *src_addr; } *src_filt; } a; int s_id; unsigned long long session_size; } *

return_type: void *

user_defined_types: struct thread_params { struct arguments a; int s_id; unsigned long long session_size; }

user_defined_types: struct arguments { struct alc_arguments alc_a; char repair[1024]; char file_path[1024]; int log_fd; int rx_automatic; int open_file; char sdp_file[1024]; int rx_object; int name_incomplete_objects; unsigned short complete_fdt; int file_table_output; unsigned long long toi; char fdt_file[1024]; int cont; int send_session_close_packets; char requested_blocks_file[1024]; char flute_conf_file[1024]; struct sdp_message *sdp; struct sf *src_filt; }


decompiled_code:
void signal_handler()
{
puts("Exiting...");
fflush(stdout);
set_all_flute_sessions_state(1LL);
}

canonical_decompiled_code:
void func0()
{
puts("Exiting...");
fflush(stdout);
set_all_flute_sessions_state(1LL);
}

original_code:
void signal_handler(int sig){
  printf("Exiting...\n");
  fflush(stdout);
  set_all_flute_sessions_state(SExiting);
}

variable_types: sig int


usage

decompiled_code:
void __noreturn usage()
{
printf("\nFLUTE Version %s, %s\n\n", "1.7", "March 2, 2007");
puts(" Copyright (c) 2003-2007 TUT - Tampere University of Technology");
puts(" main authors/contacts: jani.peltotalo@tut.fi and sami.peltotalo@tut.fi");
puts(" web site: http://www.atm.tut.fi/mad/\n");
puts(" This is free software, and you are welcome to redistribute it");
puts(" under certain conditions; See the GNU General Public License");
puts(" as published by the Free Software Foundation, version 2 or later,");
puts(" for more details.\n");
puts(" * mad_rlc.c & mad_rlc.h -- Portions of code derived from MCL library by");
puts(" * Vincent Roca et al. (http://www.inrialpes.fr/planete/people/roca/mcl/)");
puts(" *");
puts(" * Copyright (c) 1999-2004 INRIA - Universite Paris 6 - All rights reserved");
puts(" * (main author: Julien Laboure - julien.laboure@inrialpes.fr");
puts(" * Vincent Roca - vincent.roca@inrialpes.fr)\n");
puts(" * fec.c & fec.h -- forward error correction based on Vandermonde matrices");
puts(" * 980624");
puts(" * (C) 1997-98 Luigi Rizzo (luigi@iet.unipi.it)");
puts(" *");
puts(" * Portions derived from code by Phil Karn (karn@ka9q.ampr.org),");
puts(" * Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and");
puts(" * Hari Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995");
puts(" *");
puts(" * Redistribution and use in source and binary forms, with or without");
puts(" * modification, are permitted provided that the following conditions");
puts(" * are met:");
puts(" *");
puts(" * 1. Redistributions of source code must retain the above copyright");
puts(" * notice, this list of conditions and the following disclaimer.");
puts(" * 2. Redistributions in binary form must reproduce the above");
puts(" * copyright notice, this list of conditions and the following");
puts(" * disclaimer in the documentation and/or other materials");
puts(" * provided with the distribution.");
puts(" *");
puts(" * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND");
puts(" * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,");
puts(" * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A");
puts(" * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS");
puts(" * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,");
puts(" * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,");
puts(" * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,");
puts(" * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY");
puts(" * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR");
puts(" * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT");
puts(" * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY");
puts(" * OF SUCH DAMAGE.\n");
puts("Sender usage: flute [-a:str] [-B:str] [-c:int] [-C] [-d:str] [-D:ull] [-e:int]");
puts(" [-f:str] [-F:str,str,...] [-G] [-h] [-H] [-i:str] [-k:int] [-l:int]");
puts(" [-L:int] [-m:str] [-n:int] [-p:int] [-P:float,float]");
printf(" [-q:int] [-r:int]");
puts(" [-R:str] [-S] [-t:ull] [-T:int] [-U]");
puts(" [-v:int] [-V:str] [-w:int] [-W] [-x:int] [-X:int] [-z:int]");
puts(" [-Z]\n");
puts("Receiver usage: flute [-a:str] [-A] [-b:int] [-B:str] [-c:int] [-d:str] [-E]");
printf(" [-F:str,str,...] [-h] [-i:str]");
printf(" [-I:str]");
printf(" [-m:str]");
puts(" [-M]");
printf(" [-N] [-o:ull]");
printf(" [-p:int] [-P:float,float]");
puts(" [-R:str]");
puts(" [-s:str] [-t:ull] [-U] [-v:int] [-V:str] [-w:int] [-W]\n");
puts("Common options:\n");
puts(" -a:str Address family [IPv4 or IPv6], default: IPv4");
puts(" -d:str SDP file (start/join FLUTE session based on SDP file),");
puts(" default: no");
puts(" -h Print this help");
puts(" -i:str Local interface to bind to, default: INADDR_ANY");
puts(" -m:str IPv4 or IPv6 address for base channel,");
printf(" default: %s or %s\n", "226.10.40.1", "ff1a::1");
printf(" -p:int Port number for base channel, default: %s\n", "4001");
puts(" -P[:float,float] Simulate packet losses, default packet loss");
printf(" percentages: %.1f,%.1f\n", *(double *)&LC75, *(double *)&LC74);
puts(" -S Act as sender, send data; otherwise receive data");
printf(" -t:ull TSI for the session, default: %i\n", 0LL);
puts(" -U Address type is unicast, default: multicast");
puts(" -v:int Log verbosity level [0 = No output, 1 = File level,");
puts(" 2 = 1 + percent, 3 = 2 + blocks, 4 = 3 + FDT], default: 1");
puts(" -V:str Print logs to 'str' file, default: print to stdout");
puts(" -w:int Congestion control scheme [0 = Null, 1 = RLC],");
printf(" default: %i; the number of channels, defined by -c option,\n", 0LL);
puts(" are used with both schemes and bitrate of each channel is");
puts(" set according to RLC rules");
puts(" -W File table output mode. In receiver this work only with");
puts(" -A option\n");
puts("Sender options:\n");
puts(" -B:str Base directory for files or directories to be sent,");
puts(" default: working directory");
printf(" -c:int Number of used channels, default: %i\n", 1LL);
puts(" -C Continuous transmission, default: not used");
printf(" -D:ull Duration of the session in seconds, default: %i\n", 604800LL);
puts(" -e:int FEC-OTI for file objects");
puts(" [0 = FEC-OTI in FDT, 1 = FEC-OTI in EXT_FTI], default: 0");
printf(" -f:str FDT file (send based on FDT), default: %s\n", "fdt.xml");
puts(" -F:str,str,... Files or directories to be sent. Given base directory is");
puts(" same for all entries.");
puts(" -G Calculate session size, but do not send anything");
puts(" -H Use Half-word (when used, TSI field can be 16, 32 or 48");
puts(" bits long and TOI field can be 16, 32, 48 or 64 bits");
puts(" long), default: not used");
puts(" -k:int Send a Complete FDT in the beginning of the session");
puts(" [0 = No, 1 = Yes, 2 = Yes, only Complete FDT], default: 0");
printf(" -l:int Encoding symbol length in bytes, default: %i\n", 1428LL);
puts(" -L:int Maximum source block length in multiple of encoding");
printf(" symbols, default: %i\n", 64LL);
printf(" -n:int Number of transmissions, default: %i\n", 1LL);
puts(" -q:int Send session close packets [0 = No, 1 = Yes], default: 1");
printf(" -r:int Transmission rate at base channel in kbits/s, default: %i\n", 250LL);
printf(" -R[:str] Save configuration to a file, default: %s\n", "flute.conf");
printf(" -T:int Time To Live or Hop Limit for the session, default: %i\n", 1LL);
puts(" -x:int FEC Encoding [0 = Null, 1 = Simple XOR, 2 = Reed-Solomon");
printf(" (old I-D) 3 = Reed-Solomon (new I-D), default: %i\n", 0LL);
printf(" -X:int FEC ratio percent, default: %i\n", 50LL);
puts(" -z:int Encode content [0 = no, 1 = ZLIB FDT,");
puts(" 2 = ZLIB FDT and GZIP files,");
puts(" 3 = PAD files], default: 0");
puts(" -Z Optimize transmission rate (use more CPU)\n");
puts("Receiver options:\n");
puts(" -A Receive files automatically");
puts(" -b:int Receiver's memory consumption [0 = high, 1 = medium,");
puts(" 2 = low], default: 1");
puts(" -B:str Base directory for downloaded files,");
printf(" default: %s\n", "flute-downloads");
printf(" -c:int Maximum number of channels, default: %i\n", 1LL);
puts(" -E Accept expired FDT Instances");
puts(" -F:str,str,... Files to be received");
puts(" -I:str Local interface name for IPv6 multicast join, use for");
puts(" example 'ifconfig' command to see interface names;");
puts(" otherwise OS default");
puts(" -M Use Source-Specific Multicast, default: no");
puts(" -N Name incomplete objects after the session has ended");
puts(" -o:ull TOI for the object to be received");
puts(" -R[:str] Use HTTP file repair with given config file, default:");
printf(" %s\n", "apd.xml");
puts(" -s:str Source IPv4 or IPv6 address of this session. If not set,");
puts(" receiver locks to the first IP address found from the");
puts(" FLUTE packets.");
puts("\nExample use cases:\n");
puts("1. Send a file or directory n times\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -F:files/flute-draft.txt");
puts("\t -n:2\n");
puts("2. Send a file or directory in a loop\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -F:files/flute-draft.txt");
puts("\t -C\n");
puts("3. Send files defined in an FDT file\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -f:fdt2.xml\n");
puts("4. Send files defined in an FDT file in a loop\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -f:fdt2.xml -C\n");
puts("5. Send using unicast\n\n\tflute -S -U -m:1.2.3.4 -p:4000 -t:2 -r:100 -f:fdt2.xml -C\n");
puts("6. Receive one object\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2 -o:1\n");
puts("7. Receive file(s) defined by file name(s)\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2");
puts("\t -F:files/flute-man.txt,flute-draft.txt\n");
puts("8. Receive file(s) defined by wild card option\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2 -F:*.jpg\n");
puts("9. Receive file(s) with User Interface\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2\n");
puts("10. Receive file(s) automatically from session\n\n\tflute -A -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2\n");
puts("11. Receive using unicast\n\n\tflute -A -U -p:4000 -t:2 -s:2.2.2.2\n");
exit(1);
}

canonical_decompiled_code:
void __noreturn func3()
{
printf("\nFLUTE Version %s, %s\n\n", "1.7", "March 2, 2007");
puts(" Copyright (c) 2003-2007 TUT - Tampere University of Technology");
puts(" main authors/contacts: jani.peltotalo@tut.fi and sami.peltotalo@tut.fi");
puts(" web site: http://www.atm.tut.fi/mad/\n");
puts(" This is free software, and you are welcome to redistribute it");
puts(" under certain conditions; See the GNU General Public License");
puts(" as published by the Free Software Foundation, version 2 or later,");
puts(" for more details.\n");
puts(" * mad_rlc.c & mad_rlc.h -- Portions of code derived from MCL library by");
puts(" * Vincent Roca et al. (http://www.inrialpes.fr/planete/people/roca/mcl/)");
puts(" *");
puts(" * Copyright (c) 1999-2004 INRIA - Universite Paris 6 - All rights reserved");
puts(" * (main author: Julien Laboure - julien.laboure@inrialpes.fr");
puts(" * Vincent Roca - vincent.roca@inrialpes.fr)\n");
puts(" * fec.c & fec.h -- forward error correction based on Vandermonde matrices");
puts(" * 980624");
puts(" * (C) 1997-98 Luigi Rizzo (luigi@iet.unipi.it)");
puts(" *");
puts(" * Portions derived from code by Phil Karn (karn@ka9q.ampr.org),");
puts(" * Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and");
puts(" * Hari Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995");
puts(" *");
puts(" * Redistribution and use in source and binary forms, with or without");
puts(" * modification, are permitted provided that the following conditions");
puts(" * are met:");
puts(" *");
puts(" * 1. Redistributions of source code must retain the above copyright");
puts(" * notice, this list of conditions and the following disclaimer.");
puts(" * 2. Redistributions in binary form must reproduce the above");
puts(" * copyright notice, this list of conditions and the following");
puts(" * disclaimer in the documentation and/or other materials");
puts(" * provided with the distribution.");
puts(" *");
puts(" * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND");
puts(" * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,");
puts(" * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A");
puts(" * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS");
puts(" * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,");
puts(" * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,");
puts(" * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,");
puts(" * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY");
puts(" * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR");
puts(" * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT");
puts(" * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY");
puts(" * OF SUCH DAMAGE.\n");
puts("Sender usage: flute [-a:str] [-B:str] [-c:int] [-C] [-d:str] [-D:ull] [-e:int]");
puts(" [-f:str] [-F:str,str,...] [-G] [-h] [-H] [-i:str] [-k:int] [-l:int]");
puts(" [-L:int] [-m:str] [-n:int] [-p:int] [-P:float,float]");
printf(" [-q:int] [-r:int]");
puts(" [-R:str] [-S] [-t:ull] [-T:int] [-U]");
puts(" [-v:int] [-V:str] [-w:int] [-W] [-x:int] [-X:int] [-z:int]");
puts(" [-Z]\n");
puts("Receiver usage: flute [-a:str] [-A] [-b:int] [-B:str] [-c:int] [-d:str] [-E]");
printf(" [-F:str,str,...] [-h] [-i:str]");
printf(" [-I:str]");
printf(" [-m:str]");
puts(" [-M]");
printf(" [-N] [-o:ull]");
printf(" [-p:int] [-P:float,float]");
puts(" [-R:str]");
puts(" [-s:str] [-t:ull] [-U] [-v:int] [-V:str] [-w:int] [-W]\n");
puts("Common options:\n");
puts(" -a:str Address family [IPv4 or IPv6], default: IPv4");
puts(" -d:str SDP file (start/join FLUTE session based on SDP file),");
puts(" default: no");
puts(" -h Print this help");
puts(" -i:str Local interface to bind to, default: INADDR_ANY");
puts(" -m:str IPv4 or IPv6 address for base channel,");
printf(" default: %s or %s\n", "226.10.40.1", "ff1a::1");
printf(" -p:int Port number for base channel, default: %s\n", "4001");
puts(" -P[:float,float] Simulate packet losses, default packet loss");
printf(" percentages: %.1f,%.1f\n", *(double *)&LC75, *(double *)&LC74);
puts(" -S Act as sender, send data; otherwise receive data");
printf(" -t:ull TSI for the session, default: %i\n", 0LL);
puts(" -U Address type is unicast, default: multicast");
puts(" -v:int Log verbosity level [0 = No output, 1 = File level,");
puts(" 2 = 1 + percent, 3 = 2 + blocks, 4 = 3 + FDT], default: 1");
puts(" -V:str Print logs to 'str' file, default: print to stdout");
puts(" -w:int Congestion control scheme [0 = Null, 1 = RLC],");
printf(" default: %i; the number of channels, defined by -c option,\n", 0LL);
puts(" are used with both schemes and bitrate of each channel is");
puts(" set according to RLC rules");
puts(" -W File table output mode. In receiver this work only with");
puts(" -A option\n");
puts("Sender options:\n");
puts(" -B:str Base directory for files or directories to be sent,");
puts(" default: working directory");
printf(" -c:int Number of used channels, default: %i\n", 1LL);
puts(" -C Continuous transmission, default: not used");
printf(" -D:ull Duration of the session in seconds, default: %i\n", 604800LL);
puts(" -e:int FEC-OTI for file objects");
puts(" [0 = FEC-OTI in FDT, 1 = FEC-OTI in EXT_FTI], default: 0");
printf(" -f:str FDT file (send based on FDT), default: %s\n", "fdt.xml");
puts(" -F:str,str,... Files or directories to be sent. Given base directory is");
puts(" same for all entries.");
puts(" -G Calculate session size, but do not send anything");
puts(" -H Use Half-word (when used, TSI field can be 16, 32 or 48");
puts(" bits long and TOI field can be 16, 32, 48 or 64 bits");
puts(" long), default: not used");
puts(" -k:int Send a Complete FDT in the beginning of the session");
puts(" [0 = No, 1 = Yes, 2 = Yes, only Complete FDT], default: 0");
printf(" -l:int Encoding symbol length in bytes, default: %i\n", 1428LL);
puts(" -L:int Maximum source block length in multiple of encoding");
printf(" symbols, default: %i\n", 64LL);
printf(" -n:int Number of transmissions, default: %i\n", 1LL);
puts(" -q:int Send session close packets [0 = No, 1 = Yes], default: 1");
printf(" -r:int Transmission rate at base channel in kbits/s, default: %i\n", 250LL);
printf(" -R[:str] Save configuration to a file, default: %s\n", "flute.conf");
printf(" -T:int Time To Live or Hop Limit for the session, default: %i\n", 1LL);
puts(" -x:int FEC Encoding [0 = Null, 1 = Simple XOR, 2 = Reed-Solomon");
printf(" (old I-D) 3 = Reed-Solomon (new I-D), default: %i\n", 0LL);
printf(" -X:int FEC ratio percent, default: %i\n", 50LL);
puts(" -z:int Encode content [0 = no, 1 = ZLIB FDT,");
puts(" 2 = ZLIB FDT and GZIP files,");
puts(" 3 = PAD files], default: 0");
puts(" -Z Optimize transmission rate (use more CPU)\n");
puts("Receiver options:\n");
puts(" -A Receive files automatically");
puts(" -b:int Receiver's memory consumption [0 = high, 1 = medium,");
puts(" 2 = low], default: 1");
puts(" -B:str Base directory for downloaded files,");
printf(" default: %s\n", "flute-downloads");
printf(" -c:int Maximum number of channels, default: %i\n", 1LL);
puts(" -E Accept expired FDT Instances");
puts(" -F:str,str,... Files to be received");
puts(" -I:str Local interface name for IPv6 multicast join, use for");
puts(" example 'ifconfig' command to see interface names;");
puts(" otherwise OS default");
puts(" -M Use Source-Specific Multicast, default: no");
puts(" -N Name incomplete objects after the session has ended");
puts(" -o:ull TOI for the object to be received");
puts(" -R[:str] Use HTTP file repair with given config file, default:");
printf(" %s\n", "apd.xml");
puts(" -s:str Source IPv4 or IPv6 address of this session. If not set,");
puts(" receiver locks to the first IP address found from the");
puts(" FLUTE packets.");
puts("\nExample use cases:\n");
puts("1. Send a file or directory n times\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -F:files/flute-draft.txt");
puts("\t -n:2\n");
puts("2. Send a file or directory in a loop\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -F:files/flute-draft.txt");
puts("\t -C\n");
puts("3. Send files defined in an FDT file\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -f:fdt2.xml\n");
puts("4. Send files defined in an FDT file in a loop\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -f:fdt2.xml -C\n");
puts("5. Send using unicast\n\n\tflute -S -U -m:1.2.3.4 -p:4000 -t:2 -r:100 -f:fdt2.xml -C\n");
puts("6. Receive one object\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2 -o:1\n");
puts("7. Receive file(s) defined by file name(s)\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2");
puts("\t -F:files/flute-man.txt,flute-draft.txt\n");
puts("8. Receive file(s) defined by wild card option\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2 -F:*.jpg\n");
puts("9. Receive file(s) with User Interface\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2\n");
puts("10. Receive file(s) automatically from session\n\n\tflute -A -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2\n");
puts("11. Receive using unicast\n\n\tflute -A -U -p:4000 -t:2 -s:2.2.2.2\n");
exit(1);
}

original_code:
void usage(void) {
  printf("\nFLUTE Version %s, %s\n\n", "1.7", "March 2, 2007");
  printf("  Copyright (c) 2003-2007 TUT - Tampere University of Technology\n");
  printf("  main authors/contacts: jani.peltotalo@tut.fi and sami.peltotalo@tut.fi\n");
  printf("  web site: http://www.atm.tut.fi/mad/\n\n");
  printf("  This is free software, and you are welcome to redistribute it\n");
  printf("  under certain conditions; See the GNU General Public License\n");
  printf("  as published by the Free Software Foundation, version 2 or later,\n");
  printf("  for more details.\n\n");
  printf("  * mad_rlc.c & mad_rlc.h -- Portions of code derived from MCL library by\n");
  printf("  * Vincent Roca et al. (http://www.inrialpes.fr/planete/people/roca/mcl/)\n");
  printf("  *\n");
  printf("  * Copyright (c) 1999-2004 INRIA - Universite Paris 6 - All rights reserved\n");
  printf("  * (main author: Julien Laboure - julien.laboure@inrialpes.fr\n");
  printf("  *               Vincent Roca - vincent.roca@inrialpes.fr)\n\n");
  printf("  * fec.c & fec.h -- forward error correction based on Vandermonde matrices\n");
  printf("  * 980624\n");
  printf("  * (C) 1997-98 Luigi Rizzo (luigi@iet.unipi.it)\n");
  printf("  *\n");
  printf("  * Portions derived from code by Phil Karn (karn@ka9q.ampr.org),\n");
  printf("  * Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and\n");
  printf("  * Hari Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995\n");
  printf("  *\n");
  printf("  * Redistribution and use in source and binary forms, with or without\n");
  printf("  * modification, are permitted provided that the following conditions\n");
  printf("  * are met:\n");
  printf("  *\n");
  printf("  * 1. Redistributions of source code must retain the above copyright\n");
  printf("  *    notice, this list of conditions and the following disclaimer.\n");
  printf("  * 2. Redistributions in binary form must reproduce the above\n");
  printf("  *    copyright notice, this list of conditions and the following\n");
  printf("  *    disclaimer in the documentation and/or other materials\n");
  printf("  *    provided with the distribution.\n");
  printf("  *\n");
  printf("  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND\n");
  printf("  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\n");
  printf("  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n");
  printf("  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS\n");
  printf("  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\n");
  printf("  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n");
  printf("  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n");
  printf("  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n");
  printf("  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR\n");
  printf("  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\n");
  printf("  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY\n");
  printf("  * OF SUCH DAMAGE.\n\n");
  printf("Sender usage: flute [-a:str] [-B:str] [-c:int] [-C] [-d:str] [-D:ull] [-e:int]\n");
  printf("                    [-f:str] [-F:str,str,...] [-G] [-h] [-H] [-i:str] [-k:int] [-l:int]\n");
  printf("                    [-L:int] [-m:str] [-n:int] [-p:int] [-P:float,float]\n");
  printf("                    [-q:int] [-r:int]");
  printf(" [-R:str] [-S] [-t:ull] [-T:int] [-U]\n");
  printf("                    [-v:int] [-V:str] [-w:int] [-W] [-x:int] [-X:int] [-z:int]\n");
  printf("                    [-Z]\n\n");
  printf("Receiver usage: flute [-a:str] [-A] [-b:int] [-B:str] [-c:int] [-d:str] [-E]\n");
  printf("                      [-F:str,str,...] [-h] [-i:str]");
  printf(" [-I:str]");
  printf(" [-m:str]");
  printf(" [-M]\n");
  printf("                      [-N] [-o:ull]");
  printf(" [-p:int] [-P:float,float]");
  printf(" [-R:str]\n");
  printf("                      [-s:str] [-t:ull] [-U] [-v:int] [-V:str] [-w:int] [-W]\n\n");
  printf("Common options:\n\n");
  printf("   -a:str           Address family [IPv4 or IPv6], default: IPv4\n");
  printf("   -d:str           SDP file (start/join FLUTE session based on SDP file),\n");
  printf("                    default: no\n");
  printf("   -h               Print this help\n");
  printf("   -i:str           Local interface to bind to, default: INADDR_ANY\n");
  printf("   -m:str           IPv4 or IPv6 address for base channel,\n");
  printf("                    default: %s or %s\n", "226.10.40.1", "ff1a::1");
  printf("   -p:int           Port number for base channel, default: %s\n", "4001");
  printf("   -P[:float,float] Simulate packet losses, default packet loss\n");
  printf("                    percentages: %.1f,%.1f\n", (float)5, (float)50);
  printf("   -S               Act as sender, send data; otherwise receive data\n");
  printf("   -t:ull           TSI for the session, default: %i\n", 0);
  printf("   -U               Address type is unicast, default: multicast\n");
  printf("   -v:int           Log verbosity level [0 = No output, 1 = File level,\n");
  printf("                    2 = 1 + percent, 3 = 2 + blocks, 4 = 3 + FDT], default: 1\n");
  printf("   -V:str           Print logs to 'str' file, default: print to stdout\n");
  printf("   -w:int           Congestion control scheme [0 = Null, 1 = RLC],\n");
  printf("                    default: %i; the number of channels, defined by -c option,\n", 0);
  printf("                    are used with both schemes and bitrate of each channel is\n");
  printf("                    set according to RLC rules\n");
  printf("   -W               File table output mode. In receiver this work only with\n");
  printf("                    -A option\n\n");
  printf("Sender options:\n\n");
  printf("   -B:str           Base directory for files or directories to be sent,\n");
  printf("                    default: working directory\n");
  printf("   -c:int           Number of used channels, default: %i\n", 1);
  printf("   -C               Continuous transmission, default: not used\n");
  printf("   -D:ull           Duration of the session in seconds, default: %i\n", 604800);
  printf("   -e:int           FEC-OTI for file objects\n");
  printf("                    [0 = FEC-OTI in FDT, 1 = FEC-OTI in EXT_FTI], default: 0\n");
  printf("   -f:str           FDT file (send based on FDT), default: %s\n", "fdt.xml");
  printf("   -F:str,str,...   Files or directories to be sent. Given base directory is\n");
  printf("                    same for all entries.\n");
  printf("   -G               Calculate session size, but do not send anything\n");
  printf("   -H               Use Half-word (when used, TSI field can be 16, 32 or 48\n");
  printf("                    bits long and TOI field can be 16, 32, 48 or 64 bits\n");
  printf("                    long), default: not used\n");
  printf("   -k:int           Send a Complete FDT in the beginning of the session\n");
  printf("                    [0 = No, 1 = Yes, 2 = Yes, only Complete FDT], default: 0\n");
  printf("   -l:int           Encoding symbol length in bytes, default: %i\n", 1428);
  printf("   -L:int           Maximum source block length in multiple of encoding\n");
  printf("                    symbols, default: %i\n", 64);
  printf("   -n:int           Number of transmissions, default: %i\n", 1);
  printf("   -q:int           Send session close packets [0 = No, 1 = Yes], default: 1\n");
  printf("   -r:int           Transmission rate at base channel in kbits/s, default: %i\n", 250);
  printf("   -R[:str]         Save configuration to a file, default: %s\n", "flute.conf");
  printf("   -T:int           Time To Live or Hop Limit for the session, default: %i\n", 1);
  printf("   -x:int           FEC Encoding [0 = Null, 1 = Simple XOR, 2 = Reed-Solomon\n");
  printf("                    (old I-D) 3 = Reed-Solomon (new I-D), default: %i\n", 0);
  printf("   -X:int           FEC ratio percent, default: %i\n", 50);
  printf("   -z:int           Encode content [0 = no, 1 = ZLIB FDT,\n");
  printf("                    2 = ZLIB FDT and GZIP files,\n");
  printf("                    3 = PAD files], default: 0\n");
  printf("   -Z               Optimize transmission rate (use more CPU)\n\n");
  printf("Receiver options:\n\n");
  printf("   -A               Receive files automatically\n");
  printf("   -b:int           Receiver's memory consumption [0 = high, 1 = medium,\n");
  printf("                    2 = low], default: 1\n");
  printf("   -B:str           Base directory for downloaded files,\n");
  printf("                    default: %s\n", "flute-downloads");
  printf("   -c:int           Maximum number of channels, default: %i\n", 1);
  printf("   -E               Accept expired FDT Instances\n");
  printf("   -F:str,str,...   Files to be received\n");
  printf("   -I:str           Local interface name for IPv6 multicast join, use for\n");
  printf("                    example 'ifconfig' command to see interface names;\n");
  printf("                    otherwise OS default\n");
  printf("   -M               Use Source-Specific Multicast, default: no\n");
  printf("   -N               Name incomplete objects after the session has ended\n");
  printf("   -o:ull           TOI for the object to be received\n");
  printf("   -R[:str]         Use HTTP file repair with given config file, default:\n");
  printf("                    %s\n", "apd.xml");
  printf("   -s:str           Source IPv4 or IPv6 address of this session. If not set,\n");
  printf("                    receiver locks to the first IP address found from the\n");
  printf("                    FLUTE packets.\n");
  printf("\nExample use cases:\n\n");
  printf("1. Send a file or directory n times\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -F:files/flute-draft.txt\n");
  printf("\t      -n:2\n\n");
  printf("2. Send a file or directory in a loop\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -F:files/flute-draft.txt\n");
  printf("\t      -C\n\n");
  printf("3. Send files defined in an FDT file\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -f:fdt2.xml\n\n");
  printf("4. Send files defined in an FDT file in a loop\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -f:fdt2.xml -C\n\n");
  printf("5. Send using unicast\n\n\tflute -S -U -m:1.2.3.4 -p:4000 -t:2 -r:100 -f:fdt2.xml -C\n\n");
  printf("6. Receive one object\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2 -o:1\n\n");
  printf("7. Receive file(s) defined by file name(s)\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2\n");
  printf("\t      -F:files/flute-man.txt,flute-draft.txt\n\n");
  printf("8. Receive file(s) defined by wild card option\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2 -F:*.jpg\n\n");
  printf("9. Receive file(s) with User Interface\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2\n\n");
  printf("10. Receive file(s) automatically from session\n\n\tflute -A -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2\n\n");
  printf("11. Receive using unicast\n\n\tflute -A -U -p:4000 -t:2 -s:2.2.2.2\n\n");
  exit(1);
}

canonical_original_code:
void usage() {
  printf("\nFLUTE Version %s, %s\n\n", "1.7", "March 2, 2007");
  printf("  Copyright (c) 2003-2007 TUT - Tampere University of Technology\n");
  printf("  main authors/contacts: jani.peltotalo@tut.fi and sami.peltotalo@tut.fi\n");
  printf("  web site: http://www.atm.tut.fi/mad/\n\n");
  printf("  This is free software, and you are welcome to redistribute it\n");
  printf("  under certain conditions; See the GNU General Public License\n");
  printf("  as published by the Free Software Foundation, version 2 or later,\n");
  printf("  for more details.\n\n");
  printf("  * mad_rlc.c & mad_rlc.h -- Portions of code derived from MCL library by\n");
  printf("  * Vincent Roca et al. (http://www.inrialpes.fr/planete/people/roca/mcl/)\n");
  printf("  *\n");
  printf("  * Copyright (c) 1999-2004 INRIA - Universite Paris 6 - All rights reserved\n");
  printf("  * (main author: Julien Laboure - julien.laboure@inrialpes.fr\n");
  printf("  *               Vincent Roca - vincent.roca@inrialpes.fr)\n\n");
  printf("  * fec.c & fec.h -- forward error correction based on Vandermonde matrices\n");
  printf("  * 980624\n");
  printf("  * (C) 1997-98 Luigi Rizzo (luigi@iet.unipi.it)\n");
  printf("  *\n");
  printf("  * Portions derived from code by Phil Karn (karn@ka9q.ampr.org),\n");
  printf("  * Robert Morelos-Zaragoza (robert@spectra.eng.hawaii.edu) and\n");
  printf("  * Hari Thirumoorthy (harit@spectra.eng.hawaii.edu), Aug 1995\n");
  printf("  *\n");
  printf("  * Redistribution and use in source and binary forms, with or without\n");
  printf("  * modification, are permitted provided that the following conditions\n");
  printf("  * are met:\n");
  printf("  *\n");
  printf("  * 1. Redistributions of source code must retain the above copyright\n");
  printf("  *    notice, this list of conditions and the following disclaimer.\n");
  printf("  * 2. Redistributions in binary form must reproduce the above\n");
  printf("  *    copyright notice, this list of conditions and the following\n");
  printf("  *    disclaimer in the documentation and/or other materials\n");
  printf("  *    provided with the distribution.\n");
  printf("  *\n");
  printf("  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND\n");
  printf("  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\n");
  printf("  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\n");
  printf("  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS\n");
  printf("  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,\n");
  printf("  * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n");
  printf("  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,\n");
  printf("  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n");
  printf("  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR\n");
  printf("  * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT\n");
  printf("  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY\n");
  printf("  * OF SUCH DAMAGE.\n\n");
  printf("Sender usage: flute [-a:str] [-B:str] [-c:int] [-C] [-d:str] [-D:ull] [-e:int]\n");
  printf("                    [-f:str] [-F:str,str,...] [-G] [-h] [-H] [-i:str] [-k:int] [-l:int]\n");
  printf("                    [-L:int] [-m:str] [-n:int] [-p:int] [-P:float,float]\n");
  printf("                    [-q:int] [-r:int]");
  printf(" [-R:str] [-S] [-t:ull] [-T:int] [-U]\n");
  printf("                    [-v:int] [-V:str] [-w:int] [-W] [-x:int] [-X:int] [-z:int]\n");
  printf("                    [-Z]\n\n");
  printf("Receiver usage: flute [-a:str] [-A] [-b:int] [-B:str] [-c:int] [-d:str] [-E]\n");
  printf("                      [-F:str,str,...] [-h] [-i:str]");
  printf(" [-I:str]");
  printf(" [-m:str]");
  printf(" [-M]\n");
  printf("                      [-N] [-o:ull]");
  printf(" [-p:int] [-P:float,float]");
  printf(" [-R:str]\n");
  printf("                      [-s:str] [-t:ull] [-U] [-v:int] [-V:str] [-w:int] [-W]\n\n");
  printf("Common options:\n\n");
  printf("   -a:str           Address family [IPv4 or IPv6], default: IPv4\n");
  printf("   -d:str           SDP file (start/join FLUTE session based on SDP file),\n");
  printf("                    default: no\n");
  printf("   -h               Print this help\n");
  printf("   -i:str           Local interface to bind to, default: INADDR_ANY\n");
  printf("   -m:str           IPv4 or IPv6 address for base channel,\n");
  printf("                    default: %s or %s\n", "226.10.40.1", "ff1a::1");
  printf("   -p:int           Port number for base channel, default: %s\n", "4001");
  printf("   -P[:float,float] Simulate packet losses, default packet loss\n");
  printf("                    percentages: %.1f,%.1f\n", (float)5, (float)50);
  printf("   -S               Act as sender, send data; otherwise receive data\n");
  printf("   -t:ull           TSI for the session, default: %i\n", 0);
  printf("   -U               Address type is unicast, default: multicast\n");
  printf("   -v:int           Log verbosity level [0 = No output, 1 = File level,\n");
  printf("                    2 = 1 + percent, 3 = 2 + blocks, 4 = 3 + FDT], default: 1\n");
  printf("   -V:str           Print logs to 'str' file, default: print to stdout\n");
  printf("   -w:int           Congestion control scheme [0 = Null, 1 = RLC],\n");
  printf("                    default: %i; the number of channels, defined by -c option,\n", 0);
  printf("                    are used with both schemes and bitrate of each channel is\n");
  printf("                    set according to RLC rules\n");
  printf("   -W               File table output mode. In receiver this work only with\n");
  printf("                    -A option\n\n");
  printf("Sender options:\n\n");
  printf("   -B:str           Base directory for files or directories to be sent,\n");
  printf("                    default: working directory\n");
  printf("   -c:int           Number of used channels, default: %i\n", 1);
  printf("   -C               Continuous transmission, default: not used\n");
  printf("   -D:ull           Duration of the session in seconds, default: %i\n", 604800);
  printf("   -e:int           FEC-OTI for file objects\n");
  printf("                    [0 = FEC-OTI in FDT, 1 = FEC-OTI in EXT_FTI], default: 0\n");
  printf("   -f:str           FDT file (send based on FDT), default: %s\n", "fdt.xml");
  printf("   -F:str,str,...   Files or directories to be sent. Given base directory is\n");
  printf("                    same for all entries.\n");
  printf("   -G               Calculate session size, but do not send anything\n");
  printf("   -H               Use Half-word (when used, TSI field can be 16, 32 or 48\n");
  printf("                    bits long and TOI field can be 16, 32, 48 or 64 bits\n");
  printf("                    long), default: not used\n");
  printf("   -k:int           Send a Complete FDT in the beginning of the session\n");
  printf("                    [0 = No, 1 = Yes, 2 = Yes, only Complete FDT], default: 0\n");
  printf("   -l:int           Encoding symbol length in bytes, default: %i\n", 1428);
  printf("   -L:int           Maximum source block length in multiple of encoding\n");
  printf("                    symbols, default: %i\n", 64);
  printf("   -n:int           Number of transmissions, default: %i\n", 1);
  printf("   -q:int           Send session close packets [0 = No, 1 = Yes], default: 1\n");
  printf("   -r:int           Transmission rate at base channel in kbits/s, default: %i\n", 250);
  printf("   -R[:str]         Save configuration to a file, default: %s\n", "flute.conf");
  printf("   -T:int           Time To Live or Hop Limit for the session, default: %i\n", 1);
  printf("   -x:int           FEC Encoding [0 = Null, 1 = Simple XOR, 2 = Reed-Solomon\n");
  printf("                    (old I-D) 3 = Reed-Solomon (new I-D), default: %i\n", 0);
  printf("   -X:int           FEC ratio percent, default: %i\n", 50);
  printf("   -z:int           Encode content [0 = no, 1 = ZLIB FDT,\n");
  printf("                    2 = ZLIB FDT and GZIP files,\n");
  printf("                    3 = PAD files], default: 0\n");
  printf("   -Z               Optimize transmission rate (use more CPU)\n\n");
  printf("Receiver options:\n\n");
  printf("   -A               Receive files automatically\n");
  printf("   -b:int           Receiver's memory consumption [0 = high, 1 = medium,\n");
  printf("                    2 = low], default: 1\n");
  printf("   -B:str           Base directory for downloaded files,\n");
  printf("                    default: %s\n", "flute-downloads");
  printf("   -c:int           Maximum number of channels, default: %i\n", 1);
  printf("   -E               Accept expired FDT Instances\n");
  printf("   -F:str,str,...   Files to be received\n");
  printf("   -I:str           Local interface name for IPv6 multicast join, use for\n");
  printf("                    example 'ifconfig' command to see interface names;\n");
  printf("                    otherwise OS default\n");
  printf("   -M               Use Source-Specific Multicast, default: no\n");
  printf("   -N               Name incomplete objects after the session has ended\n");
  printf("   -o:ull           TOI for the object to be received\n");
  printf("   -R[:str]         Use HTTP file repair with given config file, default:\n");
  printf("                    %s\n", "apd.xml");
  printf("   -s:str           Source IPv4 or IPv6 address of this session. If not set,\n");
  printf("                    receiver locks to the first IP address found from the\n");
  printf("                    FLUTE packets.\n");
  printf("\nExample use cases:\n\n");
  printf("1. Send a file or directory n times\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -F:files/flute-draft.txt\n");
  printf("\t      -n:2\n\n");
  printf("2. Send a file or directory in a loop\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -F:files/flute-draft.txt\n");
  printf("\t      -C\n\n");
  printf("3. Send files defined in an FDT file\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -f:fdt2.xml\n\n");
  printf("4. Send files defined in an FDT file in a loop\n\n\tflute -S -m:224.1.1.1 -p:4000 -t:2 -r:100 -f:fdt2.xml -C\n\n");
  printf("5. Send using unicast\n\n\tflute -S -U -m:1.2.3.4 -p:4000 -t:2 -r:100 -f:fdt2.xml -C\n\n");
  printf("6. Receive one object\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2 -o:1\n\n");
  printf("7. Receive file(s) defined by file name(s)\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2\n");
  printf("\t      -F:files/flute-man.txt,flute-draft.txt\n\n");
  printf("8. Receive file(s) defined by wild card option\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2 -F:*.jpg\n\n");
  printf("9. Receive file(s) with User Interface\n\n\tflute -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2\n\n");
  printf("10. Receive file(s) automatically from session\n\n\tflute -A -m:224.1.1.1 -p:4000 -t:2 -s:2.2.2.2\n\n");
  printf("11. Receive using unicast\n\n\tflute -A -U -p:4000 -t:2 -s:2.2.2.2\n\n");
  exit(1);
}


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // er12
int v5; // eax
int v6; // ebx
unsigned int v8; // eax
int v9; // eax
struct in_addr v10; // eax
char *v11; // rax
pthread_t th; // [rsp+0h] [rbp-3A68h] BYREF
pthread_t newthread; // [rsp+8h] [rbp-3A60h] BYREF
char s[8]; // [rsp+16h] [rbp-3A52h] BYREF
__int16 v15; // [rsp+1Eh] [rbp-3A4Ah]
char buf[24]; // [rsp+28h] [rbp-3A40h] BYREF
char dest[48]; // [rsp+40h] [rbp-3A28h] BYREF
__int64 arg[4]; // [rsp+70h] [rbp-39F8h] BYREF
char *cp; // [rsp+90h] [rbp-39D8h]
int v20; // [rsp+A8h] [rbp-39C0h]
int v21; // [rsp+1D48h] [rbp-1D20h]
__int64 v22[923]; // [rsp+1D60h] [rbp-1D08h] BYREF
int v23; // [rsp+3A38h] [rbp-30h]

if ( (unsigned int)start_up_flute(argc, argv, envp) )
return -1;
_sysv_signal(2, (__sighandler_t)signal_handler);
v3 = time(0LL);
srand(v3);
if ( (unsigned int)parse_args((unsigned int)argc, argv, arg) == -1
|| (v4 = parse_args((unsigned int)argc, argv, v22), v4 == -1) )
{
usage();
}
*(_QWORD *)s = 0LL;
v22[0] = arg[0] + 1;
v15 = 0;
v5 = atoi((const char *)arg[3]);
sprintf(s, "%i", (unsigned int)(v5 + 1000));
v22[3] = (__int64)s;
v6 = v20;
if ( v20 == 2 )
{
memset(dest, 0, 0x2EuLL);
v8 = inet_addr(cp);
v9 = _bswap_32(v8);
v10.s_addr = _bswap_32(v9 + 10);
v11 = inet_ntoa(v10);
strcpy(dest, v11);
LABEL_6:
v22[4] = (__int64)dest;
v21 = -1;
v23 = -1;
if ( pthread_create(&th, 0LL, (void *(*)(void *))start_flute_process, arg) )
{
v4 = -1;
perror("main.c: pthread_create 1");
}
else if ( pthread_create(&newthread, 0LL, (void *(*)(void *))start_flute_process, v22) )
{
v4 = -1;
perror("main.c: pthread_create 2");
}
else
{
if ( pthread_join(th, 0LL) )
_assert_fail("join_retval1 == 0", "main.c", 0x1E0u, "main");
pthread_detach(th);
if ( pthread_join(newthread, 0LL) )
_assert_fail("join_retval2 == 0", "main.c", 0x1E9u, "main");
pthread_detach(newthread);
free_args(arg);
free_args(v22);
shut_down_flute2();
}
return v4;
}
if ( v20 != 10 )
goto LABEL_6;
inet_pton(10, cp, buf);
while ( (unsigned int)increase_ipv6_address(buf) != -1 )
{
if ( !--v6 )
{
memset(dest, 0, 0x2EuLL);
inet_ntop(10, buf, dest, 0x2Eu);
goto LABEL_6;
}
}
v4 = -1;
puts("Increasing IPv6 address is not possible");
return v4;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // er12
int v5; // eax
int v6; // ebx
unsigned int v8; // eax
int v9; // eax
struct in_addr v10; // eax
char *v11; // rax
pthread_t th; // [rsp+0h] [rbp-3A68h] BYREF
pthread_t newthread; // [rsp+8h] [rbp-3A60h] BYREF
char s[8]; // [rsp+16h] [rbp-3A52h] BYREF
__int16 v15; // [rsp+1Eh] [rbp-3A4Ah]
char buf[24]; // [rsp+28h] [rbp-3A40h] BYREF
char dest[48]; // [rsp+40h] [rbp-3A28h] BYREF
__int64 arg[4]; // [rsp+70h] [rbp-39F8h] BYREF
char *cp; // [rsp+90h] [rbp-39D8h]
int v20; // [rsp+A8h] [rbp-39C0h]
int v21; // [rsp+1D48h] [rbp-1D20h]
__int64 v22[923]; // [rsp+1D60h] [rbp-1D08h] BYREF
int v23; // [rsp+3A38h] [rbp-30h]

if ( (unsigned int)start_up_flute(argc, argv, envp) )
return -1;
_sysv_signal(2, (__sighandler_t)signal_handler);
v3 = time(0LL);
srand(v3);
if ( (unsigned int)parse_args((unsigned int)argc, argv, arg) == -1
|| (v4 = parse_args((unsigned int)argc, argv, v22), v4 == -1) )
{
func3();
}
*(_QWORD *)s = 0LL;
v22[0] = arg[0] + 1;
v15 = 0;
v5 = atoi((const char *)arg[3]);
sprintf(s, "%i", (unsigned int)(v5 + 1000));
v22[3] = (__int64)s;
v6 = v20;
if ( v20 == 2 )
{
memset(dest, 0, 0x2EuLL);
v8 = inet_addr(cp);
v9 = func2(v8);
v10.s_addr = func2(v9 + 10);
v11 = inet_ntoa(v10);
strcpy(dest, v11);
LABEL_6:
v22[4] = (__int64)dest;
v21 = -1;
v23 = -1;
if ( pthread_create(&th, 0LL, (void *(*)(void *))start_flute_process, arg) )
{
v4 = -1;
perror("main.c: pthread_create 1");
}
else if ( pthread_create(&newthread, 0LL, (void *(*)(void *))start_flute_process, v22) )
{
v4 = -1;
perror("main.c: pthread_create 2");
}
else
{
if ( pthread_join(th, 0LL) )
_assert_fail("join_retval1 == 0", "main.c", 0x1E0u, "main");
pthread_detach(th);
if ( pthread_join(newthread, 0LL) )
_assert_fail("join_retval2 == 0", "main.c", 0x1E9u, "main");
pthread_detach(newthread);
free_args(arg);
free_args(v22);
shut_down_flute2();
}
return v4;
}
if ( v20 != 10 )
goto LABEL_6;
inet_pton(10, cp, buf);
while ( (unsigned int)increase_ipv6_address(buf) != -1 )
{
if ( !--v6 )
{
memset(dest, 0, 0x2EuLL);
inet_ntop(10, buf, dest, 0x2Eu);
goto LABEL_6;
}
}
v4 = -1;
puts("Increasing IPv6 address is not possible");
return v4;
}

original_code:
int main(int argc, char **argv) {
  int retval = 0;
  thread_params_t par1;
  thread_params_t par2;
  pthread_t thread_id1;
  int join_retval1;
  pthread_t thread_id2;
  int join_retval2;
  char tmp_port[10];
  char tmp_addr[46];
  struct sockaddr_in ipv4;
  struct sockaddr_in6 ipv6;
  int j;
  if(start_up_flute() != 0) {
    return -1;
  }
  signal(2, signal_handler);
  srand((unsigned)time(((void *)0)));
  retval = parse_args(argc, argv, &par1.a);
  if(retval == -1) {
    usage();
  }
  retval = parse_args(argc, argv, &par2.a);
  if(retval == -1) {
    usage();
  }
  par2.a.alc_a.tsi = par1.a.alc_a.tsi + 1;
  memset(tmp_port, 0, 10);
  sprintf(tmp_port, "%i", (atoi(par1.a.alc_a.port) + 1000));
  par2.a.alc_a.port = tmp_port;
  if(par1.a.alc_a.addr_family == 2) {
 memset(tmp_addr, 0, 46);
 ipv4.sin_addr.s_addr = htonl(ntohl(inet_addr(par1.a.alc_a.addr)) + 10);
 sprintf(tmp_addr, "%s", inet_ntoa(ipv4.sin_addr));
  }
  else if(par1.a.alc_a.addr_family == 10) {
 inet_pton(10, par1.a.alc_a.addr, &ipv6.sin6_addr);
 for(j = 0; j < 10; j++) {
  if(increase_ipv6_address(&ipv6.sin6_addr) == -1) {
   printf("Increasing IPv6 address is not possible\n");
   return -1;
  }
 }
 memset(tmp_addr, 0, 46);
 inet_ntop(10, &ipv6.sin6_addr, tmp_addr, sizeof(tmp_addr));
  }
  par2.a.alc_a.addr = tmp_addr;
  par1.s_id = -1;
  par2.s_id = -1;
    if(pthread_create(&thread_id1, ((void *)0), start_flute_process, (void*)&par1) != 0) {
      perror("main.c: pthread_create 1");
      return -1;
    }
    if(pthread_create(&thread_id2, ((void *)0), start_flute_process, (void*)&par2) != 0) {
      perror("main.c: pthread_create 2");
      return -1;
    }
    join_retval1 = pthread_join(thread_id1, ((void *)0));
    ((void) sizeof ((join_retval1 == 0) ? 1 : 0), __extension__ ({ if (join_retval1 == 0) ; else __assert_fail ("join_retval1 == 0", "main.c", 480, __extension__ __PRETTY_FUNCTION__); }));
    pthread_detach(thread_id1);
    join_retval2 = pthread_join(thread_id2, ((void *)0));
    ((void) sizeof ((join_retval2 == 0) ? 1 : 0), __extension__ ({ if (join_retval2 == 0) ; else __assert_fail ("join_retval2 == 0", "main.c", 489, __extension__ __PRETTY_FUNCTION__); }));
    pthread_detach(thread_id2);
  free_args(&par1.a);
  free_args(&par2.a);
  shut_down_flute2();
  return retval;
}

canonical_original_code:
int main(int argc, char **argv) {
  int retval = 0;
  struct thread_params par1;
  struct thread_params par2;
  unsigned long thread_id1;
  int join_retval1;
  unsigned long thread_id2;
  int join_retval2;
  char tmp_port[10];
  char tmp_addr[46];
  struct sockaddr_in ipv4;
  struct sockaddr_in6 ipv6;
  int j;
  if(start_up_flute() != 0) {
    return -1;
  }
  signal(2, signal_handler);
  srand((unsigned int)time(((void *)0)));
  retval = parse_args(argc, argv, &par1.a);
  if(retval == -1) {
    usage();
  }
  retval = parse_args(argc, argv, &par2.a);
  if(retval == -1) {
    usage();
  }
  par2.a.alc_a.tsi = par1.a.alc_a.tsi + 1;
  memset(tmp_port, 0, 10);
  sprintf(tmp_port, "%i", (atoi(par1.a.alc_a.port) + 1000));
  par2.a.alc_a.port = tmp_port;
  if(par1.a.alc_a.addr_family == 2) {
 memset(tmp_addr, 0, 46);
 ipv4.sin_addr.s_addr = htonl(ntohl(inet_addr(par1.a.alc_a.addr)) + 10);
 sprintf(tmp_addr, "%s", inet_ntoa(ipv4.sin_addr));
  }
  else if(par1.a.alc_a.addr_family == 10) {
 inet_pton(10, par1.a.alc_a.addr, &ipv6.sin6_addr);
 for(j = 0; j < 10; j++) {
  if(increase_ipv6_address(&ipv6.sin6_addr) == -1) {
   printf("Increasing IPv6 address is not possible\n");
   return -1;
  }
 }
 memset(tmp_addr, 0, 46);
 inet_ntop(10, &ipv6.sin6_addr, tmp_addr, sizeof(tmp_addr));
  }
  par2.a.alc_a.addr = tmp_addr;
  par1.s_id = -1;
  par2.s_id = -1;
    if(pthread_create(&thread_id1, ((void *)0), start_flute_process, (void *)&par1) != 0) {
      perror("main.c: pthread_create 1");
      return -1;
    }
    if(pthread_create(&thread_id2, ((void *)0), start_flute_process, (void *)&par2) != 0) {
      perror("main.c: pthread_create 2");
      return -1;
    }
    join_retval1 = pthread_join(thread_id1, ((void *)0));
    ((void) sizeof ((join_retval1 == 0) ? 1 : 0), __extension__ ({ if (join_retval1 == 0) ; else __assert_fail ("join_retval1 == 0", "main.c", 480, __extension__ __PRETTY_FUNCTION__); }));
    pthread_detach(thread_id1);
    join_retval2 = pthread_join(thread_id2, ((void *)0));
    ((void) sizeof ((join_retval2 == 0) ? 1 : 0), __extension__ ({ if (join_retval2 == 0) ; else __assert_fail ("join_retval2 == 0", "main.c", 489, __extension__ __PRETTY_FUNCTION__); }));
    pthread_detach(thread_id2);
  free_args(&par1.a);
  free_args(&par2.a);
  shut_down_flute2();
  return retval;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct thread_params { struct arguments { struct alc_arguments { unsigned long long tsi; unsigned long long start_time; unsigned long long stop_time; char *port; char *addr; char *intface; char *intface_name; unsigned int addr_family; unsigned char addr_type; unsigned char mode; unsigned char nb_channel; unsigned char cc_id; unsigned char rx_memory_mode; int verbosity; char *src_addr; char base_dir[1024]; int accept_expired_fdt_inst; int use_ssm; unsigned int tx_rate; unsigned char ttl; unsigned short nb_tx; int simul_losses; double loss_ratio1; double loss_ratio2; unsigned short fec_ratio; unsigned short es_len; unsigned int max_sb_len; unsigned char fec_enc_id; unsigned short fec_inst_id; int use_fec_oti_ext_hdr; unsigned char encode_content; int half_word; int optimize_tx_rate; int calculate_session_size; } alc_a; char repair[1024]; char file_path[1024]; int log_fd; int rx_automatic; int open_file; char sdp_file[1024]; int rx_object; int name_incomplete_objects; unsigned short complete_fdt; int file_table_output; unsigned long long toi; char fdt_file[1024]; int cont; int send_session_close_packets; char requested_blocks_file[1024]; char flute_conf_file[1024]; struct sdp_message { char *v_version; char *o_username; char *o_sess_id; char *o_sess_version; char *o_nettype; char *o_addrtype; char *o_addr; char *s_name; char *i_info; char *u_uri; struct osip_list { int nb_elt; struct __node { void *next; void *element; } *node; } *e_emails; struct osip_list *p_phones; struct sdp_connection { char *c_nettype; char *c_addrtype; char *c_addr; char *c_addr_multicast_ttl; char *c_addr_multicast_int; } *c_connection; struct osip_list *b_bandwidths; struct osip_list *t_descrs; char *z_adjustments; struct sdp_key { char *k_keytype; char *k_keydata; } *k_key; struct osip_list *a_attributes; struct osip_list *m_medias; } *sdp; struct sf { char *filter_mode; char *net_type; char *addr_type; char *dest_addr; char *src_addr; } *src_filt; } a; int s_id; unsigned long long session_size; }

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types: struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } sin6_addr; unsigned int sin6_scope_id; }

variable_types: j int

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr_in6 { unsigned short sin6_family; unsigned short sin6_port; unsigned int sin6_flowinfo; struct in6_addr sin6_addr; unsigned int sin6_scope_id; }


decompiled_code:
_DWORD *alc_init()
{
_DWORD *result; // rax

result = &lib_init;
lib_init = 1;
return result;
}

canonical_decompiled_code:
_DWORD *func0()
{
_DWORD *result; // rax

result = &lib_init;
lib_init = 1;
return result;
}

original_code:
void alc_init(void) {
 lib_init = 1;
}

canonical_original_code:
void alc_init() {
 lib_init = 1;
}


sec

decompiled_code:
double sec()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return (double)SLODWORD(v1.tv_usec) / 1000000.0 + (double)SLODWORD(v1.tv_sec);
}

canonical_decompiled_code:
double func1()
{
struct timeval v1; // [rsp+0h] [rbp-18h] BYREF

gettimeofday(&v1, 0LL);
return (double)SLODWORD(v1.tv_usec) / 1000000.0 + (double)SLODWORD(v1.tv_sec);
}

original_code:
double sec(void) {
 struct timeval tv;
 gettimeofday(&tv, 0);
 return tv.tv_sec + tv.tv_usec / 1000000.0;
}

canonical_original_code:
double sec() {
 struct timeval tv;
 gettimeofday(&tv, 0);
 return tv.tv_sec + tv.tv_usec / 1000000.0;
}

variable_types: struct timeval { long tv_sec; long tv_usec; }

return_type: double


variable_types: struct in6_addr { union { unsigned char __u6_addr8[16]; unsigned short __u6_addr16[8]; unsigned int __u6_addr32[4]; } __in6_u; } *


randomloss

decompiled_code:
_BOOL8 __fastcall randomloss(double a1)
{
int v2; // ebx

if ( a1 == 0.0 )
return 0LL;
v2 = rand();
return a1 > (double)(rand() % 10) / 10.0 + (double)(v2 % 100);
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(double a1)
{
int v2; // ebx

if ( a1 == 0.0 )
return 0LL;
v2 = rand();
return a1 > (double)(rand() % 10) / 10.0 + (double)(v2 % 100);
}

original_code:
int randomloss(double lossprob) {
 int loss = 0;
 double msb;
 double lsb;
 double tmp;
 if(lossprob == 0.0) {
  return loss;
 }
 msb = (double)(rand()%100);
 lsb = (double)(rand()%10);
 tmp = msb + (double)(lsb/(double)10);
 if(tmp < lossprob) {
  loss = 1;
 }
 return loss;
}

variable_types: lossprob double

variable_types: loss int

variable_types: msb double

variable_types: lsb double

variable_types: tmp double