#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;
  void *sin_port;
  void *sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ out_addr;
typedef int /*<<< orphan*/ opt;
typedef int /*<<< orphan*/ in_addr;

/* Variables and functions */
void *AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_PRIORITY;
int /*<<< orphan*/ SO_REUSEADDR;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
void *htons(unsigned int);
scalar_t__ inet_aton(char *, TYPE_1__ *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, size_t);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *);
size_t recv(int, unsigned char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sendto(int, unsigned char *, size_t, int /*<<< orphan*/,
                          struct sockaddr *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int launch_rtp_proxy(unsigned int in_port, unsigned int out_port,
                     int misorder_p, int lost_p) {
  unsigned char buffer[8192];
  unsigned char mis[8192];
  struct sockaddr_in out_addr;
  struct sockaddr_in in_addr;
  int out_sock;
  int in_sock;
  size_t size;
  size_t mis_size = 0;
  int opt;
  int i = 0;
  int k = 0;
  int l = 0;
  in_sock = socket(AF_INET, SOCK_DGRAM, 0);
  out_sock = socket(AF_INET, SOCK_DGRAM, 0);
  if (in_sock < 0 || out_sock < 0)
    return -1;
  opt = 6;
  if (setsockopt(in_sock, SOL_SOCKET, SO_PRIORITY, (const void *)&opt,
                 sizeof(opt)) < 0)
    fprintf(stderr, "Can't change socket priority!\n");
  opt = 6;
  if (setsockopt(out_sock, SOL_SOCKET, SO_PRIORITY, (const void *)&opt,
                 sizeof(opt)) < 0)
    fprintf(stderr, "Can't change socket priority!\n");
  opt = 1;
  if (setsockopt(in_sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)) < 0)
    return -1;
  memset(&in_addr, 0, sizeof(in_addr));
  in_addr.sin_family = AF_INET;
  in_addr.sin_port = htons(in_port);
  in_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  if (bind(in_sock, (struct sockaddr *)&in_addr, sizeof(in_addr)) != 0)
    return -1;
  memset(&out_addr, 0, sizeof(out_addr));
  out_addr.sin_family = AF_INET;
  out_addr.sin_port = htons(out_port);
  if (inet_aton("127.0.0.1", &out_addr.sin_addr) == 0)
    return -1;
  while (1) {
    size = recv(in_sock, buffer, 8192, 0);
    if (size <= 0)
      continue;
    if (lost_p > 0 && i >= lost_p) {
      i = 0;
      printf("Packet Lost\n");
      continue;
    }
    i++;
    if (misorder_p > 0 && k >= misorder_p) {
      printf("Pick a packet...\n");
      memcpy(mis, buffer, size);
      mis_size = size;
      l = 0;
      k = 0;
      continue;
    }
    k++;
    sendto(out_sock, buffer, size, 0, (struct sockaddr *)&out_addr,
           sizeof(out_addr));
    if (mis_size > 0) {
      if (l >= 4) {
        sendto(out_sock, mis, mis_size, 0, (struct sockaddr *)&out_addr,
               sizeof(out_addr));
        mis_size = 0;
        printf("Release a packet\n");
        l = 0;
      }
      l++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<launch_rtp_proxy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4080,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movq   $0x0,-0x4068(%rbp)
movl   $0x0,-0x4070(%rbp)
movl   $0x0,-0x4074(%rbp)
movl   $0x0,-0x4078(%rbp)
mov    0x2dd1(%rip),%rax
mov    (%rax),%rdi
mov    0x2db7(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x4058(%rbp)
mov    0x2db1(%rip),%rax
mov    (%rax),%rdi
mov    0x2d97(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x4054(%rbp)
cmpl   $0x0,-0x4058(%rbp)
jl     125a <launch_rtp_proxy+0x9a>
cmpl   $0x0,-0x4054(%rbp)
jge    1266 <launch_rtp_proxy+0xa6>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b6 <launch_rtp_proxy+0x3f6>
movl   $0x6,-0x406c(%rbp)
mov    -0x4058(%rbp),%edi
mov    0x2d63(%rip),%rax
mov    (%rax),%esi
mov    0x2d6a(%rip),%rax
mov    (%rax),%edx
lea    -0x406c(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    12b9 <launch_rtp_proxy+0xf9>
mov    0x2d0d(%rip),%rax
mov    (%rax),%edi
lea    0xd4c(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x6,-0x406c(%rbp)
mov    -0x4054(%rbp),%edi
mov    0x2d10(%rip),%rax
mov    (%rax),%esi
mov    0x2d17(%rip),%rax
mov    (%rax),%edx
lea    -0x406c(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    130c <launch_rtp_proxy+0x14c>
mov    0x2cba(%rip),%rax
mov    (%rax),%edi
lea    0xcf9(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x1,-0x406c(%rbp)
mov    -0x4058(%rbp),%edi
mov    0x2cbd(%rip),%rax
mov    (%rax),%esi
mov    0x2c84(%rip),%rax
mov    (%rax),%edx
lea    -0x406c(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0x0,%rax
jge    1356 <launch_rtp_proxy+0x196>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b6 <launch_rtp_proxy+0x3f6>
lea    -0x4050(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2c68(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x4040(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0x4048(%rbp)
mov    0x2c40(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x4050(%rbp)
mov    -0x4058(%rbp),%edi
lea    -0x4050(%rbp),%rsi
mov    $0x18,%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
je     13ca <launch_rtp_proxy+0x20a>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b6 <launch_rtp_proxy+0x3f6>
lea    -0x4038(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2bf4(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x4028(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0x4030(%rbp)
lea    -0x4038(%rbp),%rsi
lea    0xc14(%rip),%rdi
call   10c0 <inet_aton@plt>
cmp    $0x0,%rax
jne    1426 <launch_rtp_proxy+0x266>
movl   $0xffffffff,-0x4(%rbp)
jmp    15b6 <launch_rtp_proxy+0x3f6>
jmp    142b <launch_rtp_proxy+0x26b>
mov    -0x4058(%rbp),%edi
lea    -0x2020(%rbp),%rsi
mov    $0x2000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %rax,-0x4060(%rbp)
cmpq   $0x0,-0x4060(%rbp)
ja     145e <launch_rtp_proxy+0x29e>
jmp    142b <launch_rtp_proxy+0x26b>
cmpl   $0x0,-0x14(%rbp)
jle    1492 <launch_rtp_proxy+0x2d2>
mov    -0x4070(%rbp),%eax
cmp    -0x14(%rbp),%eax
jl     1492 <launch_rtp_proxy+0x2d2>
movl   $0x0,-0x4070(%rbp)
lea    0xba1(%rip),%rdi
call   1060 <printf@plt>
jmp    142b <launch_rtp_proxy+0x26b>
mov    -0x4070(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4070(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    1507 <launch_rtp_proxy+0x347>
mov    -0x4074(%rbp),%eax
cmp    -0x10(%rbp),%eax
jl     1507 <launch_rtp_proxy+0x347>
lea    0xb75(%rip),%rdi
call   1060 <printf@plt>
lea    -0x4020(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
mov    -0x4060(%rbp),%rdx
call   10b0 <memcpy@plt>
mov    -0x4060(%rbp),%rax
mov    %rax,-0x4068(%rbp)
movl   $0x0,-0x4078(%rbp)
movl   $0x0,-0x4074(%rbp)
jmp    142b <launch_rtp_proxy+0x26b>
mov    -0x4074(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4074(%rbp)
mov    -0x4054(%rbp),%edi
lea    -0x2020(%rbp),%rsi
mov    -0x4060(%rbp),%rdx
lea    -0x4038(%rbp),%r8
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1090 <sendto@plt>
cmpq   $0x0,-0x4068(%rbp)
jbe    15b1 <launch_rtp_proxy+0x3f1>
cmpl   $0x4,-0x4078(%rbp)
jl     15a2 <launch_rtp_proxy+0x3e2>
mov    -0x4054(%rbp),%edi
lea    -0x4020(%rbp),%rsi
mov    -0x4068(%rbp),%rdx
lea    -0x4038(%rbp),%r8
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1090 <sendto@plt>
movq   $0x0,-0x4068(%rbp)
lea    0xab5(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4078(%rbp)
mov    -0x4078(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4078(%rbp)
jmp    142b <launch_rtp_proxy+0x26b>
mov    -0x4(%rbp),%eax
add    $0x4080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<launch_rtp_proxy>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4068,%rsp
mov    %ecx,%r13d
mov    %edx,0x24(%rsp)
mov    %esi,0xc(%rsp)
mov    %edi,%r14d
mov    0x2df2(%rip),%r12
mov    (%r12),%rdi
mov    0x2dd7(%rip),%rbx
mov    (%rbx),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,%ebp
mov    (%r12),%rdi
mov    (%rbx),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,0x14(%rsp)
test   %ebp,%ebp
js     131d <launch_rtp_proxy+0x15d>
cmpl   $0x0,0x14(%rsp)
js     131d <launch_rtp_proxy+0x15d>
movl   $0x6,0x10(%rsp)
mov    0x2db1(%rip),%r15
mov    (%r15),%esi
mov    0x2db7(%rip),%rbx
mov    (%rbx),%edx
lea    0x10(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
test   %rax,%rax
jns    1267 <launch_rtp_proxy+0xa7>
mov    0x2d5f(%rip),%rax
mov    (%rax),%edi
lea    0xd9e(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x6,0x10(%rsp)
mov    (%r15),%esi
mov    (%rbx),%edx
lea    0x10(%rsp),%rcx
mov    0x14(%rsp),%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
test   %rax,%rax
jns    12a2 <launch_rtp_proxy+0xe2>
mov    0x2d24(%rip),%rax
mov    (%rax),%edi
lea    0xd63(%rip),%rsi
call   10a0 <fprintf@plt>
movl   $0x1,0x10(%rsp)
mov    (%r15),%esi
mov    0x2cfc(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
test   %rax,%rax
js     131d <launch_rtp_proxy+0x15d>
lea    0x48(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    (%r12),%rax
mov    %rax,0x58(%rsp)
mov    %r14d,%edi
call   1060 <htons@plt>
mov    %rax,0x50(%rsp)
mov    0x2cd2(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,0x48(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x18,%edx
call   10d0 <bind@plt>
test   %rax,%rax
je     1334 <launch_rtp_proxy+0x174>
mov    $0xffffffff,%eax
add    $0x4068,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x30(%rsp),%r15
xor    %r14d,%r14d
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    (%r12),%rax
mov    %rax,0x40(%rsp)
mov    0xc(%rsp),%edi
call   1060 <htons@plt>
mov    %rax,0x38(%rsp)
lea    0xcb6(%rip),%rdi
mov    %r15,%rsi
call   10c0 <inet_aton@plt>
test   %rax,%rax
je     131d <launch_rtp_proxy+0x15d>
lea    0x2060(%rsp),%rbx
lea    0xcc6(%rip),%r12
xor    %r15d,%r15d
jmp    13ac <launch_rtp_proxy+0x1ec>
nopw   0x0(%rax,%rax,1)
lea    0xca3(%rip),%rdi
call   1040 <puts@plt>
lea    0x60(%rsp),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10b0 <memcpy@plt>
xor    %eax,%eax
xor    %ecx,%ecx
mov    %rcx,0x18(%rsp)
mov    %eax,0xc(%rsp)
jmp    13f3 <launch_rtp_proxy+0x233>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ecx
mov    %ecx,0xc(%rsp)
mov    0x14(%rsp),%edi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %ecx,%ecx
lea    0x30(%rsp),%r8
mov    $0x18,%r9d
call   1090 <sendto@plt>
mov    $0x0,%r15d
mov    0x28(%rsp),%rdx
test   %rdx,%rdx
jne    1450 <launch_rtp_proxy+0x290>
mov    %r15,0x28(%rsp)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x2000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
je     1400 <launch_rtp_proxy+0x240>
mov    %rax,%r15
test   %r13d,%r13d
jle    1430 <launch_rtp_proxy+0x270>
cmp    %r13d,%r14d
jl     1430 <launch_rtp_proxy+0x270>
mov    %r12,%rdi
call   1040 <puts@plt>
xor    %r14d,%r14d
jmp    1400 <launch_rtp_proxy+0x240>
add    $0x1,%r14d
mov    0x24(%rsp),%eax
test   %eax,%eax
mov    0xc(%rsp),%ecx
jle    13c0 <launch_rtp_proxy+0x200>
cmp    %eax,%ecx
jl     13c0 <launch_rtp_proxy+0x200>
jmp    1390 <launch_rtp_proxy+0x1d0>
nopl   (%rax)
mov    0x18(%rsp),%r15
cmp    $0x4,%r15d
jl     1487 <launch_rtp_proxy+0x2c7>
xor    %r15d,%r15d
mov    0x14(%rsp),%edi
lea    0x60(%rsp),%rsi
xor    %ecx,%ecx
lea    0x30(%rsp),%r8
mov    $0x18,%r9d
call   1090 <sendto@plt>
lea    0xba9(%rip),%rdi
call   1040 <puts@plt>
xor    %edx,%edx
mov    0xc(%rsp),%eax
add    $0x1,%r15d
mov    %r15,0x18(%rsp)
mov    %rdx,%r15
jmp    13b5 <launch_rtp_proxy+0x1f5>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_PRIORITY = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"Can't change socket priority!\0A\00"
@SO_REUSEADDR = global i32 0
@INADDR_ANY = global i32 0
@.str.1 = [10 x i8] c"127.0.0.1\00"
@.str.2 = [13 x i8] c"Packet Lost\0A\00"
@.str.3 = [18 x i8] c"Pick a packet...\0A\00"
@.str.4 = [18 x i8] c"Release a packet\0A\00"
define i32 @launch_rtp_proxy(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [8192 x i8]
%11 = alloca [8192 x i8]
%12 = alloca %struct.sockaddr_in
%13 = alloca %struct.sockaddr_in
%14 = alloca i32
%15 = alloca i32
%16 = alloca i64
%17 = alloca i64
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i64 0, i64* %17
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
%22 = load i8*, i8** @AF_INET
%23 = load i32, i32* @SOCK_DGRAM
%24 = call i32 @socket(i8* %22, i32 %23, i32 0)
store i32 %24, i32* %15
%25 = load i8*, i8** @AF_INET
%26 = load i32, i32* @SOCK_DGRAM
%27 = call i32 @socket(i8* %25, i32 %26, i32 0)
store i32 %27, i32* %14
%28 = load i32, i32* %15
%29 = icmp slt i32 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %4
%31 = load i32, i32* %14
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %30, %4
store i32 -1, i32* %5
br label %147
34: ; preds = %30
store i32 6, i32* %18
%35 = load i32, i32* %15
%36 = load i32, i32* @SOL_SOCKET
%37 = load i32, i32* @SO_PRIORITY
%38 = bitcast i32* %18 to i8*
%39 = bitcast i8* %38 to i32*
%40 = call i64 @setsockopt(i32 %35, i32 %36, i32 %37, i32* %39, i32 4)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %34
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %45
45: ; preds = %42, %34
store i32 6, i32* %18
%46 = load i32, i32* %14
%47 = load i32, i32* @SOL_SOCKET
%48 = load i32, i32* @SO_PRIORITY
%49 = bitcast i32* %18 to i8*
%50 = bitcast i8* %49 to i32*
%51 = call i64 @setsockopt(i32 %46, i32 %47, i32 %48, i32* %50, i32 4)
%52 = icmp slt i64 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %45
%54 = load i32, i32* @stderr
%55 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %56
56: ; preds = %53, %45
store i32 1, i32* %18
%57 = load i32, i32* %15
%58 = load i32, i32* @SOL_SOCKET
%59 = load i32, i32* @SO_REUSEADDR
%60 = call i64 @setsockopt(i32 %57, i32 %58, i32 %59, i32* %18, i32 4)
%61 = icmp slt i64 %60, 0
br i1 %61, label %62, label %63
62: ; preds = %56
store i32 -1, i32* %5
br label %147
63: ; preds = %56
%64 = call i32 @memset(%struct.sockaddr_in* %13, i32 0, i32 24)
%65 = load i8*, i8** @AF_INET
%66 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 2
store i8* %65, i8** %66
%67 = load i32, i32* %6
%68 = call i8* @htons(i32 %67)
%69 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
store i8* %68, i8** %69
%70 = load i32, i32* @INADDR_ANY
%71 = call i32 @htonl(i32 %70)
%72 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
%73 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %72, i32 0, i32 0
store i32 %71, i32* %73
%74 = load i32, i32* %15
%75 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%76 = call i64 @bind(i32 %74, %struct.sockaddr* %75, i32 24)
%77 = icmp ne i64 %76, 0
br i1 %77, label %78, label %79
78: ; preds = %63
store i32 -1, i32* %5
br label %147
79: ; preds = %63
%80 = call i32 @memset(%struct.sockaddr_in* %12, i32 0, i32 24)
%81 = load i8*, i8** @AF_INET
%82 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 2
store i8* %81, i8** %82
%83 = load i32, i32* %7
%84 = call i8* @htons(i32 %83)
%85 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
store i8* %84, i8** %85
%86 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%87 = call i64 @inet_aton(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %struct.TYPE_2__* %86)
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %90
89: ; preds = %79
store i32 -1, i32* %5
br label %147
90: ; preds = %79
br label %91
91: ; preds = %90, %97, %105, %116, %146
%92 = load i32, i32* %15
%93 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%94 = call i64 @recv(i32 %92, i8* %93, i32 8192, i32 0)
store i64 %94, i64* %16
%95 = load i64, i64* %16
%96 = icmp ule i64 %95, 0
br i1 %96, label %97, label %98
97: ; preds = %91
br label %91
98: ; preds = %91
%99 = load i32, i32* %9
%100 = icmp sgt i32 %99, 0
br i1 %100, label %101, label %107
101: ; preds = %98
%102 = load i32, i32* %19
%103 = load i32, i32* %9
%104 = icmp sge i32 %102, %103
br i1 %104, label %105, label %107
105: ; preds = %101
store i32 0, i32* %19
%106 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %91
107: ; preds = %101, %98
%108 = load i32, i32* %19
%109 = add nsw i32 %108, 1
store i32 %109, i32* %19
%110 = load i32, i32* %8
%111 = icmp sgt i32 %110, 0
br i1 %111, label %112, label %123
112: ; preds = %107
%113 = load i32, i32* %20
%114 = load i32, i32* %8
%115 = icmp sge i32 %113, %114
br i1 %115, label %116, label %123
116: ; preds = %112
%117 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%118 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%119 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%120 = load i64, i64* %16
%121 = call i32 @memcpy(i8* %118, i8* %119, i64 %120)
%122 = load i64, i64* %16
store i64 %122, i64* %17
store i32 0, i32* %21
store i32 0, i32* %20
br label %91
123: ; preds = %112, %107
%124 = load i32, i32* %20
%125 = add nsw i32 %124, 1
store i32 %125, i32* %20
%126 = load i32, i32* %14
%127 = getelementptr inbounds [8192 x i8], [8192 x i8]* %10, i64 0, i64 0
%128 = load i64, i64* %16
%129 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%130 = call i32 @sendto(i32 %126, i8* %127, i64 %128, i32 0, %struct.sockaddr* %129, i32 24)
%131 = load i64, i64* %17
%132 = icmp ugt i64 %131, 0
br i1 %132, label %133, label %146
133: ; preds = %123
%134 = load i32, i32* %21
%135 = icmp sge i32 %134, 4
br i1 %135, label %136, label %143
136: ; preds = %133
%137 = load i32, i32* %14
%138 = getelementptr inbounds [8192 x i8], [8192 x i8]* %11, i64 0, i64 0
%139 = load i64, i64* %17
%140 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%141 = call i32 @sendto(i32 %137, i8* %138, i64 %139, i32 0, %struct.sockaddr* %140, i32 24)
store i64 0, i64* %17
%142 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %21
br label %143
143: ; preds = %136, %133
%144 = load i32, i32* %21
%145 = add nsw i32 %144, 1
store i32 %145, i32* %21
br label %146
146: ; preds = %143, %123
br label %91
147: ; preds = %89, %78, %62, %33
%148 = load i32, i32* %5
ret i32 %148
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i8*, i8* }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i8* null
@SOCK_DGRAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_PRIORITY = global i32 0
@stderr = global i32 0
@.str = [31 x i8] c"Can't change socket priority!\0A\00"
@SO_REUSEADDR = global i32 0
@INADDR_ANY = global i32 0
@.str.1 = [10 x i8] c"127.0.0.1\00"
@str = [17 x i8] c"Release a packet\00"
@str.5 = [17 x i8] c"Pick a packet...\00"
@str.6 = [12 x i8] c"Packet Lost\00"
define i32 @launch_rtp_proxy(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [8192 x i8]
%6 = alloca [8192 x i8]
%7 = alloca %struct.sockaddr_in
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = getelementptr inbounds [8192 x i8], [8192 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [8192 x i8], [8192 x i8]* %6, i64 0, i64 0
%12 = bitcast %struct.sockaddr_in* %7 to i8*
%13 = bitcast %struct.sockaddr_in* %8 to i8*
%14 = bitcast i32* %9 to i8*
%15 = load i8*, i8** @AF_INET
%16 = load i32, i32* @SOCK_DGRAM
%17 = tail call i32 @socket(i8* %15, i32 %16, i32 0)
%18 = load i8*, i8** @AF_INET
%19 = load i32, i32* @SOCK_DGRAM
%20 = tail call i32 @socket(i8* %18, i32 %19, i32 0)
%21 = icmp slt i32 %17, 0
%22 = icmp slt i32 %20, 0
%23 = select i1 %21, i1 true, i1 %22
br i1 %23, label %113, label %24
24: ; preds = %4
store i32 6, i32* %9
%25 = load i32, i32* @SOL_SOCKET
%26 = load i32, i32* @SO_PRIORITY
%27 = call i64 @setsockopt(i32 %17, i32 %25, i32 %26, i32* %9, i32 4)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %32
32: ; preds = %29, %24
store i32 6, i32* %9
%33 = load i32, i32* @SOL_SOCKET
%34 = load i32, i32* @SO_PRIORITY
%35 = call i64 @setsockopt(i32 %20, i32 %33, i32 %34, i32* %9, i32 4)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i32, i32* @stderr
%39 = call i32 @fprintf(i32 %38, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %40
40: ; preds = %37, %32
store i32 1, i32* %9
%41 = load i32, i32* @SOL_SOCKET
%42 = load i32, i32* @SO_REUSEADDR
%43 = call i64 @setsockopt(i32 %17, i32 %41, i32 %42, i32* %9, i32 4)
%44 = icmp slt i64 %43, 0
br i1 %44, label %113, label %45
45: ; preds = %40
%46 = call i32 @memset(%struct.sockaddr_in* %8, i32 0, i32 24)
%47 = load i8*, i8** @AF_INET
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 2
store i8* %47, i8** %48
%49 = call i8* @htons(i32 %0)
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 1
store i8* %49, i8** %50
%51 = load i32, i32* @INADDR_ANY
%52 = call i32 @htonl(i32 %51)
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i64 0, i32 0, i32 0
store i32 %52, i32* %53
%54 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%55 = call i64 @bind(i32 %17, %struct.sockaddr* %54, i32 24)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %113
57: ; preds = %45
%58 = call i32 @memset(%struct.sockaddr_in* %7, i32 0, i32 24)
%59 = load i8*, i8** @AF_INET
%60 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 2
store i8* %59, i8** %60
%61 = call i8* @htons(i32 %1)
%62 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 1
store i8* %61, i8** %62
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i64 0, i32 0
%64 = call i64 @inet_aton(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), %struct.TYPE_2__* %63)
%65 = icmp eq i64 %64, 0
br i1 %65, label %113, label %66
66: ; preds = %57
%67 = icmp slt i32 %3, 1
%68 = icmp slt i32 %2, 1
%69 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
br label %70
70: ; preds = %96, %66
%71 = phi i64 [ 0, %66 ], [ %97, %96 ]
%72 = phi i32 [ 0, %66 ], [ %90, %96 ]
%73 = phi i32 [ 0, %66 ], [ %98, %96 ]
%74 = phi i32 [ 0, %66 ], [ %99, %96 ]
br label %75
75: ; preds = %70, %100
%76 = phi i64 [ 0, %100 ], [ %71, %70 ]
%77 = phi i32 [ %90, %100 ], [ %72, %70 ]
%78 = phi i32 [ %101, %100 ], [ %73, %70 ]
br label %79
79: ; preds = %75, %87
%80 = phi i32 [ %77, %75 ], [ 0, %87 ]
br label %81
81: ; preds = %79, %81
%82 = call i64 @recv(i32 %17, i8* %10, i32 8192, i32 0)
%83 = icmp eq i64 %82, 0
br i1 %83, label %81, label %84
84: ; preds = %81
%85 = icmp slt i32 %80, %3
%86 = select i1 %67, i1 true, i1 %85
br i1 %86, label %89, label %87
87: ; preds = %84
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0))
br label %79
89: ; preds = %84
%90 = add nsw i32 %80, 1
%91 = icmp slt i32 %78, %2
%92 = select i1 %68, i1 true, i1 %91
br i1 %92, label %100, label %93
93: ; preds = %89
%94 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.5, i64 0, i64 0))
%95 = call i32 @memcpy(i8* %11, i8* %10, i64 %82)
br label %96
96: ; preds = %93, %109
%97 = phi i64 [ %110, %109 ], [ %82, %93 ]
%98 = phi i32 [ %101, %109 ], [ 0, %93 ]
%99 = phi i32 [ %112, %109 ], [ 0, %93 ]
br label %70
100: ; preds = %89
%101 = add nsw i32 %78, 1
%102 = call i32 @sendto(i32 %20, i8* %10, i64 %82, i32 0, %struct.sockaddr* %69, i32 24)
%103 = icmp eq i64 %76, 0
br i1 %103, label %75, label %104
104: ; preds = %100
%105 = icmp sgt i32 %74, 3
br i1 %105, label %106, label %109
106: ; preds = %104
%107 = call i32 @sendto(i32 %20, i8* %11, i64 %76, i32 0, %struct.sockaddr* %69, i32 24)
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %109
109: ; preds = %106, %104
%110 = phi i64 [ 0, %106 ], [ %76, %104 ]
%111 = phi i32 [ 0, %106 ], [ %74, %104 ]
%112 = add nsw i32 %111, 1
br label %96
113: ; preds = %57, %45, %40, %4
ret i32 -1
}