#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ F_OK;
int /*<<< orphan*/ INADDR_ANY;
int RUDP_Start_Send(char *, int, struct sockaddr_in *, int, int, double);
int /*<<< orphan*/ SOCK_DGRAM;
int access(char *, int /*<<< orphan*/);
double atof(char *);
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
char *calloc(int, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int fileSize(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int getpid();
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ logit(char *, int, int, int, int);
void *malloc(int);
int /*<<< orphan*/ memcpy(char *, int *, int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *,
                    int *);
scalar_t__ sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
int /*<<< orphan*/ usleep(int);
int RUDP_Send(int sockServe, struct sockaddr_in *addrConnClient, char *filePath,
              int fifo_TOlog, int whoIam) {
  char *buf_LOG = calloc(150, sizeof(char));
  char *cmdPkt = calloc(100, sizeof(char));
  int cantAccess = 0;
  cantAccess = access(filePath, F_OK);
  if (!cantAccess) {
    if (fifo_TOlog) {
      snprintf(buf_LOG + 8, 150 - 8, "%d: : -> Start Transfer Send Session\n",
               getpid());
      logit(buf_LOG, fifo_TOlog, 150, 1, 1);
    }
    int WindowSize;
    char *AuxString = malloc(10 * sizeof(char));
    double lossProb;
    FILE *param;
    int IntSendTime;
    char *windowSizePath = calloc(100, sizeof(char));
    char *intervalTimePath = calloc(100, sizeof(char));
    char *lossProbPath = calloc(100, sizeof(char));
    if (whoIam == 2) {
      strncpy(windowSizePath, "ClientParams/WindowSize.param", 100);
      strncpy(intervalTimePath, "ClientParams/IntervalSendTime.param", 100);
      strncpy(lossProbPath, "ClientParams/LossProb.param", 100);
    }
    if (whoIam == 1) {
      strncpy(windowSizePath, "ServerParams/WindowSize.param", 100);
      strncpy(intervalTimePath, "ServerParams/IntervalSendTime.param", 100);
      strncpy(lossProbPath, "ServerParams/LossProb.param", 100);
    }
    if (!(param = fopen(windowSizePath, "r"))) {
      WindowSize = 10;
      printf("Error in Open WindowSize.param, setted as Default: %d\n",
             WindowSize);
      fflush(stdout);
    } else {
      memset(AuxString, 0, 10);
      fgets(AuxString, 10, param);
      WindowSize = atoi(AuxString);
    }
    if (!(param = fopen(intervalTimePath, "r"))) {
      IntSendTime = 5000;
      printf("Error in Open IntervalSendTime.param, setted as Default: %d",
             IntSendTime);
      fflush(stdout);
    } else {
      memset(AuxString, 0, 10);
      fgets(AuxString, 10, param);
      IntSendTime = atoi(AuxString);
    }
    if (!(param = fopen(lossProbPath, "r"))) {
      printf("Error in Open LossProb.param, setted as Default");
      fflush(stdout);
      lossProb = 0.8;
    } else {
      memset(AuxString, 0, 10);
      fgets(AuxString, 10, param);
      lossProb = atof(AuxString);
    }
    struct sockaddr_in *addrTrasfSender = malloc(sizeof(struct sockaddr_in));
    memset((void *)addrTrasfSender, 0, sizeof(*addrTrasfSender));
    addrTrasfSender->sin_family = AF_INET;
    addrTrasfSender->sin_addr.s_addr = htonl(INADDR_ANY);
    socklen_t lenTrasf = sizeof(*addrTrasfSender);
    int sockTrasf;
    if ((sockTrasf = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
      perror("RUDP: Error in socket TRANSFER SOCKET:");
      return 2;
    }
    if (bind(sockTrasf, (struct sockaddr *)addrTrasfSender,
             sizeof(*addrTrasfSender)) < 0) {
      perror("RUDP: Error in bind TRANSFER SOCKET\n");
      return 2;
    }
    if (fifo_TOlog) {
      snprintf(buf_LOG + 8, 150 - 8, "%d:%d: -> RUDP: new Transfer Socket\n",
               getpid(), sockTrasf);
      logit(buf_LOG, fifo_TOlog, 150, 1, 1);
    }
    memset(cmdPkt, 0, 100);
    strncpy(cmdPkt, "RDY ", 4);
    int filesize = fileSize(filePath);
    memcpy(cmdPkt + 4, &filesize, sizeof(int));
    if (sendto(sockTrasf, cmdPkt, 100, 0, (struct sockaddr *)addrConnClient,
               lenTrasf) < 0) {
      perror("RUDP: Error in sendto");
      return 2;
    }
    struct sockaddr_in *addrTrasfRcver = malloc(sizeof(struct sockaddr_in));
    socklen_t lenTrasfrcv = sizeof(*addrTrasfRcver);
    if (recvfrom(sockTrasf, cmdPkt, 100, 0, (struct sockaddr *)addrTrasfRcver,
                 &lenTrasfrcv) < 0) {
      perror("RUDP: Error in recvfrom in 2nd Transf Step");
      return 2;
    }
    if (strncmp(cmdPkt, "OK  ", 4) == 0) {
      if (fifo_TOlog) {
        snprintf(buf_LOG + 8, 150 - 8,
                 "%d:%d: -> RUDP: Starting RUDP Transfer\n", getpid(),
                 sockTrasf);
        logit(buf_LOG, fifo_TOlog, 150, 1, 1);
      }
      usleep(5000);
      int ret = RUDP_Start_Send(filePath, sockTrasf, addrTrasfRcver, WindowSize,
                                IntSendTime, lossProb);
      return ret;
    } else {
      if (1 >= 1) {
        printf("%d:%d: -> RUDP: Connection with Recver Failed \"%s\"\n",
               getpid(), sockTrasf, cmdPkt);
        fflush(stdout);
        return 2;
      }
    }
  } else {
    usleep(5000);
    memset(cmdPkt, 0, 100);
    strncpy(cmdPkt, "NOTF", 4);
    if (fifo_TOlog) {
      snprintf(buf_LOG + 8, 150 - 8, "%d: : -> RUDP: File Not Found\n",
               getpid());
      logit(buf_LOG, fifo_TOlog, 150, 1, 1);
    }
    if (sendto(sockServe, cmdPkt, 100, 0, (struct sockaddr *)addrConnClient,
               sizeof(*addrConnClient)) < 0) {
      perror("Errore in sendto");
      return 2;
    }
    return 1;
  }
}


x86 assembly (clang, -O0):
<RUDP_Send>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    $0x96,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x64,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2cd3(%rip),%rax
mov    (%rax),%esi
call   1160 <access@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jne    187d <RUDP_Send+0x5ed>
cmpl   $0x0,-0x1c(%rbp)
je     134f <RUDP_Send+0xbf>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0xa0(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0xa0(%rbp),%rdi
mov    %eax,%ecx
mov    $0x8e,%esi
lea    0xcda(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x96,%edx
mov    $0x1,%r8d
mov    %r8d,%ecx
call   10a0 <logit@plt>
mov    $0xa,%edi
call   1110 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x64,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,-0x60(%rbp)
mov    $0x64,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,-0x68(%rbp)
mov    $0x64,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,-0x70(%rbp)
cmpl   $0x2,-0x20(%rbp)
jne    13df <RUDP_Send+0x14f>
mov    -0x60(%rbp),%rdi
lea    0xc83(%rip),%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
mov    -0x68(%rbp),%rdi
lea    0xc8c(%rip),%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
mov    -0x70(%rbp),%rdi
lea    0xc9b(%rip),%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
cmpl   $0x1,-0x20(%rbp)
jne    1428 <RUDP_Send+0x198>
mov    -0x60(%rbp),%rdi
lea    0xc98(%rip),%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
mov    -0x68(%rbp),%rdi
lea    0xca1(%rip),%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
mov    -0x70(%rbp),%rdi
lea    0xcb0(%rip),%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
mov    -0x60(%rbp),%rdi
lea    0xcb7(%rip),%rsi
call   1170 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    1471 <RUDP_Send+0x1e1>
movl   $0xa,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xc95(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2b63(%rip),%rax
mov    (%rax),%edi
call   1120 <fflush@plt>
jmp    149f <RUDP_Send+0x20f>
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10c0 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    $0xa,%esi
call   10e0 <fgets@plt>
mov    -0x40(%rbp),%rdi
call   1190 <atoi@plt>
mov    %eax,-0x38(%rbp)
mov    -0x68(%rbp),%rdi
lea    0xc40(%rip),%rsi
call   1170 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    14e8 <RUDP_Send+0x258>
movl   $0x1388,-0x54(%rbp)
mov    -0x54(%rbp),%esi
lea    0xc55(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2aec(%rip),%rax
mov    (%rax),%edi
call   1120 <fflush@plt>
jmp    1516 <RUDP_Send+0x286>
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10c0 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    $0xa,%esi
call   10e0 <fgets@plt>
mov    -0x40(%rbp),%rdi
call   1190 <atoi@plt>
mov    %eax,-0x54(%rbp)
mov    -0x70(%rbp),%rdi
lea    0xbc9(%rip),%rsi
call   1170 <fopen@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    1562 <RUDP_Send+0x2d2>
lea    0xc24(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x2a7f(%rip),%rax
mov    (%rax),%edi
call   1120 <fflush@plt>
movsd  0xaa8(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    1592 <RUDP_Send+0x302>
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10c0 <memset@plt>
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rdx
mov    $0xa,%esi
call   10e0 <fgets@plt>
mov    -0x40(%rbp),%rdi
call   1050 <atof@plt>
movsd  %xmm0,-0x48(%rbp)
mov    $0x8,%edi
call   1110 <malloc@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10c0 <memset@plt>
mov    0x2a31(%rip),%rax
mov    (%rax),%ecx
mov    -0x78(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    0x2a19(%rip),%rax
mov    (%rax),%edi
call   10b0 <htonl@plt>
mov    %eax,%ecx
mov    -0x78(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x8,-0x7c(%rbp)
mov    0x2a04(%rip),%rax
mov    (%rax),%edi
mov    0x29eb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   11b0 <socket@plt>
mov    %eax,-0x80(%rbp)
cmp    $0x0,%eax
jge    161a <RUDP_Send+0x38a>
lea    0xb86(%rip),%rdi
call   1180 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1948 <RUDP_Send+0x6b8>
mov    -0x80(%rbp),%edi
mov    -0x78(%rbp),%rsi
mov    $0x8,%edx
call   1150 <bind@plt>
cmp    $0x0,%rax
jge    164d <RUDP_Send+0x3bd>
lea    0xb7a(%rip),%rdi
call   1180 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1948 <RUDP_Send+0x6b8>
cmpl   $0x0,-0x1c(%rbp)
je     16a7 <RUDP_Send+0x417>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0xa8(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%ecx
mov    -0x80(%rbp),%r8d
mov    $0x8e,%esi
lea    0xb55(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x96,%edx
mov    $0x1,%r8d
mov    %r8d,%ecx
call   10a0 <logit@plt>
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   10c0 <memset@plt>
mov    -0x30(%rbp),%rdi
lea    0xb3e(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rdi
call   1070 <fileSize@plt>
mov    %eax,-0x84(%rbp)
mov    -0x30(%rbp),%rdi
add    $0x4,%rdi
lea    -0x84(%rbp),%rsi
mov    $0x4,%edx
call   1100 <memcpy@plt>
mov    -0x80(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%r8
mov    -0x7c(%rbp),%r9d
mov    $0x64,%edx
xor    %ecx,%ecx
call   10d0 <sendto@plt>
cmp    $0x0,%rax
jge    1731 <RUDP_Send+0x4a1>
lea    0xae5(%rip),%rdi
call   1180 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1948 <RUDP_Send+0x6b8>
mov    $0x8,%edi
call   1110 <malloc@plt>
mov    %rax,-0x90(%rbp)
movl   $0x8,-0x94(%rbp)
mov    -0x80(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x90(%rbp),%r8
mov    $0x64,%edx
xor    %ecx,%ecx
lea    -0x94(%rbp),%r9
call   1140 <recvfrom@plt>
cmp    $0x0,%rax
jge    178f <RUDP_Send+0x4ff>
lea    0xa9d(%rip),%rdi
call   1180 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1948 <RUDP_Send+0x6b8>
mov    -0x30(%rbp),%rdi
lea    0xaac(%rip),%rsi
mov    $0x4,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    1845 <RUDP_Send+0x5b5>
cmpl   $0x0,-0x1c(%rbp)
je     1808 <RUDP_Send+0x578>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0xb0(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0xb0(%rbp),%rdi
mov    %eax,%ecx
mov    -0x80(%rbp),%r8d
mov    $0x8e,%esi
lea    0xa64(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x96,%edx
mov    $0x1,%r8d
mov    %r8d,%ecx
call   10a0 <logit@plt>
mov    $0x1388,%edi
call   11a0 <usleep@plt>
mov    -0x18(%rbp),%rdi
mov    -0x80(%rbp),%esi
mov    -0x90(%rbp),%rdx
mov    -0x38(%rbp),%ecx
mov    -0x54(%rbp),%r8d
movsd  -0x48(%rbp),%xmm0
call   1130 <RUDP_Start_Send@plt>
mov    %eax,-0x98(%rbp)
mov    -0x98(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1948 <RUDP_Send+0x6b8>
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,%esi
mov    -0x80(%rbp),%edx
mov    -0x30(%rbp),%rcx
lea    0xa17(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    0x275e(%rip),%rax
mov    (%rax),%edi
call   1120 <fflush@plt>
movl   $0x2,-0x4(%rbp)
jmp    1948 <RUDP_Send+0x6b8>
mov    $0x1388,%edi
call   11a0 <usleep@plt>
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   10c0 <memset@plt>
mov    -0x30(%rbp),%rdi
lea    0xa05(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncpy@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1902 <RUDP_Send+0x672>
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0xb8(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    -0xb8(%rbp),%rdi
mov    %eax,%ecx
mov    $0x8e,%esi
lea    0x9cb(%rip),%rdx
mov    $0x0,%al
call   1090 <snprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x96,%edx
mov    $0x1,%r8d
mov    %r8d,%ecx
call   10a0 <logit@plt>
mov    -0x8(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%r8
mov    $0x64,%edx
xor    %ecx,%ecx
mov    $0x8,%r9d
call   10d0 <sendto@plt>
cmp    $0x0,%rax
jge    1941 <RUDP_Send+0x6b1>
lea    0x99b(%rip),%rdi
call   1180 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1948 <RUDP_Send+0x6b8>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RUDP_Send>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8d,%r14d
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,0x10(%rsp)
mov    %edi,%r15d
mov    $0x96,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%r13
mov    $0x64,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%r12
mov    0x2cdf(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1160 <access@plt>
test   %eax,%eax
je     1396 <RUDP_Send+0x106>
mov    $0x1388,%edi
call   11a0 <usleep@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   10c0 <memset@plt>
lea    0xf9c(%rip),%rsi
mov    %r12,%rdi
mov    $0x4,%edx
call   1030 <strncpy@plt>
test   %ebp,%ebp
je     135c <RUDP_Send+0xcc>
mov    %r13,%rbx
add    $0x8,%rbx
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xf7b(%rip),%rdx
mov    %rbx,%rdi
mov    $0x8e,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %r13,%rdi
mov    %ebp,%esi
mov    $0x96,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
call   10a0 <logit@plt>
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
mov    0x10(%rsp),%r8
mov    $0x8,%r9d
call   10d0 <sendto@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jns    1835 <RUDP_Send+0x5a5>
lea    0xf3a(%rip),%rdi
jmp    182b <RUDP_Send+0x59b>
test   %ebp,%ebp
mov    %rbx,0x30(%rsp)
je     13dc <RUDP_Send+0x14c>
lea    0x8(%r13),%rbx
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xc57(%rip),%rdx
mov    %rbx,%rdi
mov    $0x8e,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %r13,%rdi
mov    %ebp,%esi
mov    $0x96,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
call   10a0 <logit@plt>
mov    %r13,0x28(%rsp)
mov    %ebp,0x4(%rsp)
mov    $0xa,%edi
call   1110 <malloc@plt>
mov    %rax,%r13
mov    $0x64,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%rbp
mov    $0x64,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,%r15
mov    $0x64,%edi
mov    $0x1,%esi
call   10f0 <calloc@plt>
mov    %rax,0x8(%rsp)
cmp    $0x2,%r14d
je     144d <RUDP_Send+0x1bd>
cmp    $0x1,%r14d
jne    1491 <RUDP_Send+0x201>
lea    0xc91(%rip),%r14
lea    0xc66(%rip),%rbx
lea    0xc41(%rip),%rsi
jmp    1462 <RUDP_Send+0x1d2>
lea    0xc1c(%rip),%r14
lea    0xbf1(%rip),%rbx
lea    0xbcc(%rip),%rsi
mov    %rbp,%rdi
mov    $0x64,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
mov    0x8(%rsp),%rdi
mov    %r14,%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
lea    0xc52(%rip),%rsi
mov    %rbp,%rdi
call   1170 <fopen@plt>
test   %rax,%rax
je     14d4 <RUDP_Send+0x244>
mov    %rax,%rbx
mov    %r13,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10c0 <memset@plt>
mov    %r13,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
call   10e0 <fgets@plt>
mov    %r13,%rdi
call   1190 <atoi@plt>
mov    %eax,%r14d
jmp    14fb <RUDP_Send+0x26b>
lea    0xc11(%rip),%rdi
mov    $0xa,%r14d
mov    $0xa,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2ad4(%rip),%rax
mov    (%rax),%edi
call   1120 <fflush@plt>
lea    0xbe8(%rip),%rsi
mov    %r15,%rdi
call   1170 <fopen@plt>
test   %rax,%rax
je     153e <RUDP_Send+0x2ae>
mov    %rax,%rbx
mov    %r13,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10c0 <memset@plt>
mov    %r13,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
call   10e0 <fgets@plt>
mov    %r13,%rdi
call   1190 <atoi@plt>
mov    %eax,%r15d
jmp    1565 <RUDP_Send+0x2d5>
lea    0xbde(%rip),%rdi
mov    $0x1388,%r15d
mov    $0x1388,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2a6a(%rip),%rax
mov    (%rax),%edi
call   1120 <fflush@plt>
lea    0xb7e(%rip),%rsi
mov    0x8(%rsp),%rdi
call   1170 <fopen@plt>
test   %rax,%rax
je     15a7 <RUDP_Send+0x317>
mov    %rax,%rbx
mov    %r13,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10c0 <memset@plt>
mov    %r13,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
call   10e0 <fgets@plt>
mov    %r13,%rdi
call   1050 <atof@plt>
jmp    15cb <RUDP_Send+0x33b>
lea    0xbb1(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2a0c(%rip),%rax
mov    (%rax),%edi
call   1120 <fflush@plt>
movsd  0xa35(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
mov    $0x8,%edi
call   1110 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10c0 <memset@plt>
mov    0x29f4(%rip),%rax
mov    (%rax),%ebp
mov    %ebp,0x4(%rbx)
mov    0x29e0(%rip),%rax
mov    (%rax),%edi
call   10b0 <htonl@plt>
mov    %eax,(%rbx)
mov    0x29c8(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   11b0 <socket@plt>
test   %eax,%eax
js     1809 <RUDP_Send+0x579>
mov    %eax,%ebp
mov    %eax,%edi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1150 <bind@plt>
test   %rax,%rax
js     1812 <RUDP_Send+0x582>
mov    %r14d,0x8(%rsp)
mov    0x4(%rsp),%r14d
test   %r14d,%r14d
je     1692 <RUDP_Send+0x402>
mov    0x28(%rsp),%r13
lea    0x8(%r13),%rbx
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xb78(%rip),%rdx
mov    %rbx,%rdi
mov    $0x8e,%esi
mov    %eax,%ecx
mov    %ebp,%r8d
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %r13,%rdi
mov    %r14d,%esi
mov    $0x96,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
call   10a0 <logit@plt>
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   10c0 <memset@plt>
lea    0xb58(%rip),%rsi
mov    %r12,%rdi
mov    $0x4,%edx
call   1030 <strncpy@plt>
mov    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <fileSize@plt>
mov    %eax,0x1c(%rsp)
mov    %r12,%rdi
add    $0x4,%rdi
lea    0x1c(%rsp),%rsi
mov    $0x4,%edx
call   1100 <memcpy@plt>
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
mov    0x10(%rsp),%r8
mov    $0x8,%r9d
call   10d0 <sendto@plt>
test   %rax,%rax
js     181b <RUDP_Send+0x58b>
mov    %r15d,0x10(%rsp)
mov    0x8(%rsp),%r15d
mov    $0x8,%edi
call   1110 <malloc@plt>
mov    %rax,%r14
movl   $0x8,0x18(%rsp)
lea    0x18(%rsp),%r9
mov    %ebp,%edi
mov    %r12,%rsi
mov    $0x64,%edx
xor    %ecx,%ecx
mov    %rax,%r8
call   1140 <recvfrom@plt>
test   %rax,%rax
js     1824 <RUDP_Send+0x594>
lea    0xafd(%rip),%rsi
mov    %r12,%rdi
mov    $0x4,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
je     178a <RUDP_Send+0x4fa>
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xb0a(%rip),%rdi
mov    %eax,%esi
mov    %ebp,%edx
mov    %r12,%rcx
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x284a(%rip),%rax
mov    (%rax),%edi
call   1120 <fflush@plt>
jmp    1830 <RUDP_Send+0x5a0>
mov    0x4(%rsp),%r12d
test   %r12d,%r12d
je     17e2 <RUDP_Send+0x552>
mov    0x28(%rsp),%r13
mov    %r13,%rbx
add    $0x8,%rbx
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xa9d(%rip),%rdx
mov    %rbx,%rdi
mov    0x30(%rsp),%rbx
mov    $0x8e,%esi
mov    %eax,%ecx
mov    %ebp,%r8d
xor    %eax,%eax
call   1090 <snprintf@plt>
mov    %r13,%rdi
mov    %r12d,%esi
mov    $0x96,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
call   10a0 <logit@plt>
mov    $0x1388,%edi
call   11a0 <usleep@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    %r15d,%ecx
mov    0x10(%rsp),%r8d
movsd  0x20(%rsp),%xmm0
call   1130 <RUDP_Start_Send@plt>
jmp    1835 <RUDP_Send+0x5a5>
lea    0x97f(%rip),%rdi
jmp    182b <RUDP_Send+0x59b>
lea    0x99d(%rip),%rdi
jmp    182b <RUDP_Send+0x59b>
lea    0x9e3(%rip),%rdi
jmp    182b <RUDP_Send+0x59b>
lea    0x9f0(%rip),%rdi
call   1180 <perror@plt>
mov    $0x2,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@F_OK = global i32 0
@.str = [38 x i8] c"%d: : -> Start Transfer Send Session\0A\00"
@.str.1 = [30 x i8] c"ClientParams/WindowSize.param\00"
@.str.2 = [36 x i8] c"ClientParams/IntervalSendTime.param\00"
@.str.3 = [28 x i8] c"ClientParams/LossProb.param\00"
@.str.4 = [30 x i8] c"ServerParams/WindowSize.param\00"
@.str.5 = [36 x i8] c"ServerParams/IntervalSendTime.param\00"
@.str.6 = [28 x i8] c"ServerParams/LossProb.param\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [55 x i8] c"Error in Open WindowSize.param, setted as Default: %d\0A\00"
@stdout = global i32 0
@.str.9 = [60 x i8] c"Error in Open IntervalSendTime.param, setted as Default: %d\00"
@.str.10 = [48 x i8] c"Error in Open LossProb.param, setted as Default\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_DGRAM = global i32 0
@.str.11 = [39 x i8] c"RUDP: Error in socket TRANSFER SOCKET:\00"
@.str.12 = [37 x i8] c"RUDP: Error in bind TRANSFER SOCKET\0A\00"
@.str.13 = [37 x i8] c"%d:%d: -> RUDP: new Transfer Socket\0A\00"
@.str.14 = [5 x i8] c"RDY \00"
@.str.15 = [22 x i8] c"RUDP: Error in sendto\00"
@.str.16 = [43 x i8] c"RUDP: Error in recvfrom in 2nd Transf Step\00"
@.str.17 = [5 x i8] c"OK \00"
@.str.18 = [40 x i8] c"%d:%d: -> RUDP: Starting RUDP Transfer\0A\00"
@.str.19 = [52 x i8] c"%d:%d: -> RUDP: Connection with Recver Failed \22%s\22\0A\00"
@.str.20 = [5 x i8] c"NOTF\00"
@.str.21 = [31 x i8] c"%d: : -> RUDP: File Not Found\0A\00"
@.str.22 = [17 x i8] c"Errore in sendto\00"
define i32 @RUDP_Send(i32 %0, %struct.sockaddr_in* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.sockaddr_in*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8*
%17 = alloca double
%18 = alloca i32*
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i8*
%22 = alloca i8*
%23 = alloca %struct.sockaddr_in*
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca %struct.sockaddr_in*
%28 = alloca i32
%29 = alloca i32
store i32 %0, i32* %7
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%30 = call i8* @calloc(i32 150, i32 1)
store i8* %30, i8** %12
%31 = call i8* @calloc(i32 100, i32 1)
store i8* %31, i8** %13
store i32 0, i32* %14
%32 = load i8*, i8** %9
%33 = load i32, i32* @F_OK
%34 = call i32 @access(i8* %32, i32 %33)
store i32 %34, i32* %14
%35 = load i32, i32* %14
%36 = icmp ne i32 %35, 0
br i1 %36, label %225, label %37
37: ; preds = %5
%38 = load i32, i32* %10
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %37
%41 = load i8*, i8** %12
%42 = getelementptr inbounds i8, i8* %41, i64 8
%43 = call i32 (...) @getpid()
%44 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %42, i32 142, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %43)
%45 = load i8*, i8** %12
%46 = load i32, i32* %10
%47 = call i32 @logit(i8* %45, i32 %46, i32 150, i32 1, i32 1)
br label %48
48: ; preds = %40, %37
%49 = call i8* @malloc(i32 10)
store i8* %49, i8** %16
%50 = call i8* @calloc(i32 100, i32 1)
store i8* %50, i8** %20
%51 = call i8* @calloc(i32 100, i32 1)
store i8* %51, i8** %21
%52 = call i8* @calloc(i32 100, i32 1)
store i8* %52, i8** %22
%53 = load i32, i32* %11
%54 = icmp eq i32 %53, 2
br i1 %54, label %55, label %62
55: ; preds = %48
%56 = load i8*, i8** %20
%57 = call i32 @strncpy(i8* %56, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 100)
%58 = load i8*, i8** %21
%59 = call i32 @strncpy(i8* %58, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 100)
%60 = load i8*, i8** %22
%61 = call i32 @strncpy(i8* %60, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 100)
br label %62
62: ; preds = %55, %48
%63 = load i32, i32* %11
%64 = icmp eq i32 %63, 1
br i1 %64, label %65, label %72
65: ; preds = %62
%66 = load i8*, i8** %20
%67 = call i32 @strncpy(i8* %66, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 100)
%68 = load i8*, i8** %21
%69 = call i32 @strncpy(i8* %68, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i32 100)
%70 = load i8*, i8** %22
%71 = call i32 @strncpy(i8* %70, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 100)
br label %72
72: ; preds = %65, %62
%73 = load i8*, i8** %20
%74 = call i32* @fopen(i8* %73, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %74, i32** %18
%75 = icmp ne i32* %74, null
br i1 %75, label %81, label %76
76: ; preds = %72
store i32 10, i32* %15
%77 = load i32, i32* %15
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0), i32 %77)
%79 = load i32, i32* @stdout
%80 = call i32 @fflush(i32 %79)
br label %89
81: ; preds = %72
%82 = load i8*, i8** %16
%83 = call i32 @memset(i8* %82, i32 0, i32 10)
%84 = load i8*, i8** %16
%85 = load i32*, i32** %18
%86 = call i32 @fgets(i8* %84, i32 10, i32* %85)
%87 = load i8*, i8** %16
%88 = call i32 @atoi(i8* %87)
store i32 %88, i32* %15
br label %89
89: ; preds = %81, %76
%90 = load i8*, i8** %21
%91 = call i32* @fopen(i8* %90, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %91, i32** %18
%92 = icmp ne i32* %91, null
br i1 %92, label %98, label %93
93: ; preds = %89
store i32 5000, i32* %19
%94 = load i32, i32* %19
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i32 %94)
%96 = load i32, i32* @stdout
%97 = call i32 @fflush(i32 %96)
br label %106
98: ; preds = %89
%99 = load i8*, i8** %16
%100 = call i32 @memset(i8* %99, i32 0, i32 10)
%101 = load i8*, i8** %16
%102 = load i32*, i32** %18
%103 = call i32 @fgets(i8* %101, i32 10, i32* %102)
%104 = load i8*, i8** %16
%105 = call i32 @atoi(i8* %104)
store i32 %105, i32* %19
br label %106
106: ; preds = %98, %93
%107 = load i8*, i8** %22
%108 = call i32* @fopen(i8* %107, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
store i32* %108, i32** %18
%109 = icmp ne i32* %108, null
br i1 %109, label %114, label %110
110: ; preds = %106
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0))
%112 = load i32, i32* @stdout
%113 = call i32 @fflush(i32 %112)
store double 8.000000e-01, double* %17
br label %122
114: ; preds = %106
%115 = load i8*, i8** %16
%116 = call i32 @memset(i8* %115, i32 0, i32 10)
%117 = load i8*, i8** %16
%118 = load i32*, i32** %18
%119 = call i32 @fgets(i8* %117, i32 10, i32* %118)
%120 = load i8*, i8** %16
%121 = call double @atof(i8* %120)
store double %121, double* %17
br label %122
122: ; preds = %114, %110
%123 = call i8* @malloc(i32 8)
%124 = bitcast i8* %123 to %struct.sockaddr_in*
store %struct.sockaddr_in* %124, %struct.sockaddr_in** %23
%125 = load %struct.sockaddr_in*, %struct.sockaddr_in** %23
%126 = bitcast %struct.sockaddr_in* %125 to i8*
%127 = call i32 @memset(i8* %126, i32 0, i32 8)
%128 = load i32, i32* @AF_INET
%129 = load %struct.sockaddr_in*, %struct.sockaddr_in** %23
%130 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %129, i32 0, i32 1
store i32 %128, i32* %130
%131 = load i32, i32* @INADDR_ANY
%132 = call i32 @htonl(i32 %131)
%133 = load %struct.sockaddr_in*, %struct.sockaddr_in** %23
%134 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %133, i32 0, i32 0
%135 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %134, i32 0, i32 0
store i32 %132, i32* %135
store i32 8, i32* %24
%136 = load i32, i32* @AF_INET
%137 = load i32, i32* @SOCK_DGRAM
%138 = call i32 @socket(i32 %136, i32 %137, i32 0)
store i32 %138, i32* %25
%139 = icmp slt i32 %138, 0
br i1 %139, label %140, label %142
140: ; preds = %122
%141 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0))
store i32 2, i32* %6
br label %251
142: ; preds = %122
%143 = load i32, i32* %25
%144 = load %struct.sockaddr_in*, %struct.sockaddr_in** %23
%145 = bitcast %struct.sockaddr_in* %144 to %struct.sockaddr*
%146 = call i64 @bind(i32 %143, %struct.sockaddr* %145, i32 8)
%147 = icmp slt i64 %146, 0
br i1 %147, label %148, label %150
148: ; preds = %142
%149 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0))
store i32 2, i32* %6
br label %251
150: ; preds = %142
%151 = load i32, i32* %10
%152 = icmp ne i32 %151, 0
br i1 %152, label %153, label %162
153: ; preds = %150
%154 = load i8*, i8** %12
%155 = getelementptr inbounds i8, i8* %154, i64 8
%156 = call i32 (...) @getpid()
%157 = load i32, i32* %25
%158 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %155, i32 142, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0), i32 %156, i32 %157)
%159 = load i8*, i8** %12
%160 = load i32, i32* %10
%161 = call i32 @logit(i8* %159, i32 %160, i32 150, i32 1, i32 1)
br label %162
162: ; preds = %153, %150
%163 = load i8*, i8** %13
%164 = call i32 @memset(i8* %163, i32 0, i32 100)
%165 = load i8*, i8** %13
%166 = call i32 @strncpy(i8* %165, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 4)
%167 = load i8*, i8** %9
%168 = call i32 @fileSize(i8* %167)
store i32 %168, i32* %26
%169 = load i8*, i8** %13
%170 = getelementptr inbounds i8, i8* %169, i64 4
%171 = call i32 @memcpy(i8* %170, i32* %26, i32 4)
%172 = load i32, i32* %25
%173 = load i8*, i8** %13
%174 = load %struct.sockaddr_in*, %struct.sockaddr_in** %8
%175 = bitcast %struct.sockaddr_in* %174 to %struct.sockaddr*
%176 = load i32, i32* %24
%177 = call i64 @sendto(i32 %172, i8* %173, i32 100, i32 0, %struct.sockaddr* %175, i32 %176)
%178 = icmp slt i64 %177, 0
br i1 %178, label %179, label %181
179: ; preds = %162
%180 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0))
store i32 2, i32* %6
br label %251
181: ; preds = %162
%182 = call i8* @malloc(i32 8)
%183 = bitcast i8* %182 to %struct.sockaddr_in*
store %struct.sockaddr_in* %183, %struct.sockaddr_in** %27
store i32 8, i32* %28
%184 = load i32, i32* %25
%185 = load i8*, i8** %13
%186 = load %struct.sockaddr_in*, %struct.sockaddr_in** %27
%187 = bitcast %struct.sockaddr_in* %186 to %struct.sockaddr*
%188 = call i64 @recvfrom(i32 %184, i8* %185, i32 100, i32 0, %struct.sockaddr* %187, i32* %28)
%189 = icmp slt i64 %188, 0
br i1 %189, label %190, label %192
190: ; preds = %181
%191 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.16, i64 0, i64 0))
store i32 2, i32* %6
br label %251
192: ; preds = %181
%193 = load i8*, i8** %13
%194 = call i64 @strncmp(i8* %193, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i32 4)
%195 = icmp eq i64 %194, 0
br i1 %195, label %196, label %218
196: ; preds = %192
%197 = load i32, i32* %10
%198 = icmp ne i32 %197, 0
br i1 %198, label %199, label %208
199: ; preds = %196
%200 = load i8*, i8** %12
%201 = getelementptr inbounds i8, i8* %200, i64 8
%202 = call i32 (...) @getpid()
%203 = load i32, i32* %25
%204 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %201, i32 142, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.18, i64 0, i64 0), i32 %202, i32 %203)
%205 = load i8*, i8** %12
%206 = load i32, i32* %10
%207 = call i32 @logit(i8* %205, i32 %206, i32 150, i32 1, i32 1)
br label %208
208: ; preds = %199, %196
%209 = call i32 @usleep(i32 5000)
%210 = load i8*, i8** %9
%211 = load i32, i32* %25
%212 = load %struct.sockaddr_in*, %struct.sockaddr_in** %27
%213 = load i32, i32* %15
%214 = load i32, i32* %19
%215 = load double, double* %17
%216 = call i32 @RUDP_Start_Send(i8* %210, i32 %211, %struct.sockaddr_in* %212, i32 %213, i32 %214, double %215)
store i32 %216, i32* %29
%217 = load i32, i32* %29
store i32 %217, i32* %6
br label %251
218: ; preds = %192
%219 = call i32 (...) @getpid()
%220 = load i32, i32* %25
%221 = load i8*, i8** %13
%222 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.19, i64 0, i64 0), i32 %219, i32 %220, i8* %221)
%223 = load i32, i32* @stdout
%224 = call i32 @fflush(i32 %223)
store i32 2, i32* %6
br label %251
225: ; preds = %5
%226 = call i32 @usleep(i32 5000)
%227 = load i8*, i8** %13
%228 = call i32 @memset(i8* %227, i32 0, i32 100)
%229 = load i8*, i8** %13
%230 = call i32 @strncpy(i8* %229, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i32 4)
%231 = load i32, i32* %10
%232 = icmp ne i32 %231, 0
br i1 %232, label %233, label %241
233: ; preds = %225
%234 = load i8*, i8** %12
%235 = getelementptr inbounds i8, i8* %234, i64 8
%236 = call i32 (...) @getpid()
%237 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %235, i32 142, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.21, i64 0, i64 0), i32 %236)
%238 = load i8*, i8** %12
%239 = load i32, i32* %10
%240 = call i32 @logit(i8* %238, i32 %239, i32 150, i32 1, i32 1)
br label %241
241: ; preds = %233, %225
%242 = load i32, i32* %7
%243 = load i8*, i8** %13
%244 = load %struct.sockaddr_in*, %struct.sockaddr_in** %8
%245 = bitcast %struct.sockaddr_in* %244 to %struct.sockaddr*
%246 = call i64 @sendto(i32 %242, i8* %243, i32 100, i32 0, %struct.sockaddr* %245, i32 8)
%247 = icmp slt i64 %246, 0
br i1 %247, label %248, label %250
248: ; preds = %241
%249 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.22, i64 0, i64 0))
store i32 2, i32* %6
br label %251
250: ; preds = %241
store i32 1, i32* %6
br label %251
251: ; preds = %250, %248, %218, %208, %190, %179, %148, %140
%252 = load i32, i32* %6
ret i32 %252
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@F_OK = global i32 0
@.str = [38 x i8] c"%d: : -> Start Transfer Send Session\0A\00"
@.str.1 = [30 x i8] c"ClientParams/WindowSize.param\00"
@.str.2 = [36 x i8] c"ClientParams/IntervalSendTime.param\00"
@.str.3 = [28 x i8] c"ClientParams/LossProb.param\00"
@.str.4 = [30 x i8] c"ServerParams/WindowSize.param\00"
@.str.5 = [36 x i8] c"ServerParams/IntervalSendTime.param\00"
@.str.6 = [28 x i8] c"ServerParams/LossProb.param\00"
@.str.7 = [2 x i8] c"r\00"
@.str.8 = [55 x i8] c"Error in Open WindowSize.param, setted as Default: %d\0A\00"
@stdout = global i32 0
@.str.9 = [60 x i8] c"Error in Open IntervalSendTime.param, setted as Default: %d\00"
@.str.10 = [48 x i8] c"Error in Open LossProb.param, setted as Default\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOCK_DGRAM = global i32 0
@.str.11 = [39 x i8] c"RUDP: Error in socket TRANSFER SOCKET:\00"
@.str.12 = [37 x i8] c"RUDP: Error in bind TRANSFER SOCKET\0A\00"
@.str.13 = [37 x i8] c"%d:%d: -> RUDP: new Transfer Socket\0A\00"
@.str.14 = [5 x i8] c"RDY \00"
@.str.15 = [22 x i8] c"RUDP: Error in sendto\00"
@.str.16 = [43 x i8] c"RUDP: Error in recvfrom in 2nd Transf Step\00"
@.str.17 = [5 x i8] c"OK \00"
@.str.18 = [40 x i8] c"%d:%d: -> RUDP: Starting RUDP Transfer\0A\00"
@.str.19 = [52 x i8] c"%d:%d: -> RUDP: Connection with Recver Failed \22%s\22\0A\00"
@.str.20 = [5 x i8] c"NOTF\00"
@.str.21 = [31 x i8] c"%d: : -> RUDP: File Not Found\0A\00"
@.str.22 = [17 x i8] c"Errore in sendto\00"
define i32 @RUDP_Send(i32 %0, %struct.sockaddr_in* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = tail call dereferenceable_or_null(150) i8* @calloc(i32 150, i32 1)
%9 = tail call dereferenceable_or_null(100) i8* @calloc(i32 100, i32 1)
%10 = load i32, i32* @F_OK
%11 = tail call i32 @access(i8* %2, i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %137
13: ; preds = %5
%14 = icmp eq i32 %3, 0
br i1 %14, label %20, label %15
15: ; preds = %13
%16 = getelementptr inbounds i8, i8* %8, i64 8
%17 = tail call i32 (...) @getpid()
%18 = tail call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %16, i32 142, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %17)
%19 = tail call i32 @logit(i8* %8, i32 %3, i32 150, i32 1, i32 1)
br label %20
20: ; preds = %15, %13
%21 = tail call dereferenceable_or_null(10) i8* @malloc(i32 10)
%22 = tail call dereferenceable_or_null(100) i8* @calloc(i32 100, i32 1)
%23 = tail call dereferenceable_or_null(100) i8* @calloc(i32 100, i32 1)
%24 = tail call dereferenceable_or_null(100) i8* @calloc(i32 100, i32 1)
switch i32 %4, label %33 [
i32 2, label %26
i32 1, label %25
]
25: ; preds = %20
br label %26
26: ; preds = %20, %25
%27 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), %25 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), %20 ]
%28 = phi i8* [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), %25 ], [ getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), %20 ]
%29 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), %25 ], [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), %20 ]
%30 = tail call i32 @strncpy(i8* %22, i8* %27, i32 100)
%31 = tail call i32 @strncpy(i8* %23, i8* %28, i32 100)
%32 = tail call i32 @strncpy(i8* %24, i8* %29, i32 100)
br label %33
33: ; preds = %26, %20
%34 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0), i32 10)
%38 = load i32, i32* @stdout
%39 = tail call i32 @fflush(i32 %38)
br label %44
40: ; preds = %33
%41 = tail call i32 @memset(i8* %21, i32 0, i32 10)
%42 = tail call i32 @fgets(i8* %21, i32 10, i32* %34)
%43 = tail call i32 @atoi(i8* %21)
br label %44
44: ; preds = %40, %36
%45 = phi i32 [ %43, %40 ], [ 10, %36 ]
%46 = tail call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%47 = icmp eq i32* %46, null
br i1 %47, label %48, label %52
48: ; preds = %44
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @.str.9, i64 0, i64 0), i32 5000)
%50 = load i32, i32* @stdout
%51 = tail call i32 @fflush(i32 %50)
br label %56
52: ; preds = %44
%53 = tail call i32 @memset(i8* %21, i32 0, i32 10)
%54 = tail call i32 @fgets(i8* %21, i32 10, i32* %46)
%55 = tail call i32 @atoi(i8* %21)
br label %56
56: ; preds = %52, %48
%57 = phi i32 [ %55, %52 ], [ 5000, %48 ]
%58 = tail call i32* @fopen(i8* %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %64
60: ; preds = %56
%61 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0))
%62 = load i32, i32* @stdout
%63 = tail call i32 @fflush(i32 %62)
br label %68
64: ; preds = %56
%65 = tail call i32 @memset(i8* %21, i32 0, i32 10)
%66 = tail call i32 @fgets(i8* %21, i32 10, i32* %58)
%67 = tail call double @atof(i8* %21)
br label %68
68: ; preds = %64, %60
%69 = phi double [ %67, %64 ], [ 8.000000e-01, %60 ]
%70 = tail call dereferenceable_or_null(8) i8* @malloc(i32 8)
%71 = bitcast i8* %70 to %struct.sockaddr_in*
%72 = tail call i32 @memset(i8* %70, i32 0, i32 8)
%73 = load i32, i32* @AF_INET
%74 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %71, i64 0, i32 1
store i32 %73, i32* %74
%75 = load i32, i32* @INADDR_ANY
%76 = tail call i32 @htonl(i32 %75)
%77 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %71, i64 0, i32 0, i32 0
store i32 %76, i32* %77
%78 = load i32, i32* @SOCK_DGRAM
%79 = tail call i32 @socket(i32 %73, i32 %78, i32 0)
%80 = icmp slt i32 %79, 0
br i1 %80, label %81, label %83
81: ; preds = %68
%82 = tail call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0))
br label %153
83: ; preds = %68
%84 = bitcast i8* %70 to %struct.sockaddr*
%85 = tail call i64 @bind(i32 %79, %struct.sockaddr* %84, i32 8)
%86 = icmp slt i64 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %83
%88 = tail call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0))
br label %153
89: ; preds = %83
br i1 %14, label %95, label %90
90: ; preds = %89
%91 = getelementptr inbounds i8, i8* %8, i64 8
%92 = tail call i32 (...) @getpid()
%93 = tail call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %91, i32 142, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0), i32 %92, i32 %79)
%94 = tail call i32 @logit(i8* %8, i32 %3, i32 150, i32 1, i32 1)
br label %95
95: ; preds = %90, %89
%96 = tail call i32 @memset(i8* %9, i32 0, i32 100)
%97 = tail call i32 @strncpy(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.14, i64 0, i64 0), i32 4)
%98 = bitcast i32* %6 to i8*
%99 = tail call i32 @fileSize(i8* %2)
store i32 %99, i32* %6
%100 = getelementptr inbounds i8, i8* %9, i64 4
%101 = call i32 @memcpy(i8* %100, i32* %6, i32 4)
%102 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%103 = call i64 @sendto(i32 %79, i8* %9, i32 100, i32 0, %struct.sockaddr* %102, i32 8)
%104 = icmp slt i64 %103, 0
br i1 %104, label %105, label %107
105: ; preds = %95
%106 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.15, i64 0, i64 0))
br label %135
107: ; preds = %95
%108 = call dereferenceable_or_null(8) i8* @malloc(i32 8)
%109 = bitcast i8* %108 to %struct.sockaddr_in*
%110 = bitcast i32* %7 to i8*
store i32 8, i32* %7
%111 = bitcast i8* %108 to %struct.sockaddr*
%112 = call i64 @recvfrom(i32 %79, i8* %9, i32 100, i32 0, %struct.sockaddr* %111, i32* %7)
%113 = icmp slt i64 %112, 0
br i1 %113, label %114, label %116
114: ; preds = %107
%115 = call i32 @perror(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.16, i64 0, i64 0))
br label %133
116: ; preds = %107
%117 = call i64 @strncmp(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.17, i64 0, i64 0), i32 4)
%118 = icmp eq i64 %117, 0
br i1 %118, label %119, label %128
119: ; preds = %116
br i1 %14, label %125, label %120
120: ; preds = %119
%121 = getelementptr inbounds i8, i8* %8, i64 8
%122 = call i32 (...) @getpid()
%123 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %121, i32 142, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.18, i64 0, i64 0), i32 %122, i32 %79)
%124 = call i32 @logit(i8* %8, i32 %3, i32 150, i32 1, i32 1)
br label %125
125: ; preds = %120, %119
%126 = call i32 @usleep(i32 5000)
%127 = call i32 @RUDP_Start_Send(i8* %2, i32 %79, %struct.sockaddr_in* %109, i32 %45, i32 %57, double %69)
br label %133
128: ; preds = %116
%129 = call i32 (...) @getpid()
%130 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.19, i64 0, i64 0), i32 %129, i32 %79, i8* %9)
%131 = load i32, i32* @stdout
%132 = call i32 @fflush(i32 %131)
br label %133
133: ; preds = %128, %125, %114
%134 = phi i32 [ 2, %114 ], [ %127, %125 ], [ 2, %128 ]
br label %135
135: ; preds = %133, %105
%136 = phi i32 [ 2, %105 ], [ %134, %133 ]
br label %153
137: ; preds = %5
%138 = tail call i32 @usleep(i32 5000)
%139 = tail call i32 @memset(i8* %9, i32 0, i32 100)
%140 = tail call i32 @strncpy(i8* %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.20, i64 0, i64 0), i32 4)
%141 = icmp eq i32 %3, 0
br i1 %141, label %147, label %142
142: ; preds = %137
%143 = getelementptr inbounds i8, i8* %8, i64 8
%144 = tail call i32 (...) @getpid()
%145 = tail call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %143, i32 142, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.21, i64 0, i64 0), i32 %144)
%146 = tail call i32 @logit(i8* %8, i32 %3, i32 150, i32 1, i32 1)
br label %147
147: ; preds = %142, %137
%148 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%149 = tail call i64 @sendto(i32 %0, i8* %9, i32 100, i32 0, %struct.sockaddr* %148, i32 8)
%150 = icmp slt i64 %149, 0
br i1 %150, label %151, label %153
151: ; preds = %147
%152 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.22, i64 0, i64 0))
br label %153
153: ; preds = %147, %81, %87, %135, %151
%154 = phi i32 [ 2, %151 ], [ 2, %81 ], [ 2, %87 ], [ %136, %135 ], [ 1, %147 ]
ret i32 %154
}