#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 */

/* Type definitions */
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
};
typedef int /*<<< orphan*/ buffer;

/* Variables and functions */
struct addrinfo *createAddressInfo(char const *, char const *);
int createSocket(struct addrinfo *);
int /*<<< orphan*/ printf(char *, ...);
int sendto(int, int *, int, int /*<<< orphan*/, int /*<<< orphan*/,
           int /*<<< orphan*/);
int /*<<< orphan*/ sleep(int);
int strtol(char *, char **, int);
int main(int argc, char **argv) {
  char *pEnd;
  char str[15];
  const char *ipTx = argv[1];
  const char *ipRx = argv[2];
  const char *portTx = argv[3];
  const char *portRx = argv[4];
  const int rateTx = strtol(argv[5], &pEnd, 10);
  printf("Transmit IP: %s\n", ipTx);
  printf("Receive IP: %s\n", ipRx);
  printf("Transmit Port: %s\n", portTx);
  printf("Receive Port: %s\n", portRx);
  printf("Transport Rate: %ld\n", rateTx);
  struct addrinfo *addr = createAddressInfo(ipTx, portTx);
  int socket = createSocket(addr);
  int tmp = 3;
  int *buffer = &tmp;
  while (1) {
    printf("Sending\n");
    int success = sendto(socket, buffer, sizeof(buffer), 0, addr->ai_addr,
                         addr->ai_addrlen);
    if (success == -1) {
      printf("Error occurred sending so now I am sad");
      return -1;
    }
    sleep(1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rsi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rsi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rsi
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4c(%rbp),%esi
lea    0xe35(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1050 <createAddressInfo@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
call   1030 <createSocket@plt>
mov    %eax,-0x5c(%rbp)
movl   $0x3,-0x60(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x5c(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    -0x58(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x58(%rbp),%rax
mov    (%rax),%r9d
mov    $0x8,%edx
xor    %ecx,%ecx
call   1060 <sendto@plt>
mov    %eax,-0x6c(%rbp)
cmpl   $0xffffffff,-0x6c(%rbp)
jne    129a <main+0x13a>
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0xffffffff,%eax
add    $0x70,%rsp
pop    %rbp
ret
mov    $0x1,%edi
call   1080 <sleep@plt>
jmp    1244 <main+0xe4>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%r12
mov    0x10(%rsi),%rbx
mov    0x18(%rsi),%rbp
mov    0x20(%rsi),%r14
mov    0x28(%rsi),%rdi
lea    0x8(%rsp),%rsi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %eax,%r15d
lea    0xe57(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe57(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe56(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe58(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe59(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   1060 <createAddressInfo@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1030 <createSocket@plt>
mov    %eax,%ebp
movl   $0x3,0x4(%rsp)
lea    0xe64(%rip),%rdi
call   1040 <puts@plt>
mov    (%rbx),%r9d
mov    0x4(%rbx),%r8d
lea    0x4(%rsp),%rsi
mov    %ebp,%edi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1070 <sendto@plt>
cmp    $0xffffffff,%eax
je     127f <main+0x10f>
lea    0xe39(%rip),%r14
lea    0x4(%rsp),%r15
xchg   %ax,%ax
mov    $0x1,%edi
call   1090 <sleep@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    (%rbx),%r9d
mov    0x4(%rbx),%r8d
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x8,%edx
xor    %ecx,%ecx
call   1070 <sendto@plt>
cmp    $0xffffffff,%eax
jne    1250 <main+0xe0>
lea    0xdd5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32 }
@.str = [17 x i8] c"Transmit IP: %s\0A\00"
@.str.1 = [16 x i8] c"Receive IP: %s\0A\00"
@.str.2 = [19 x i8] c"Transmit Port: %s\0A\00"
@.str.3 = [18 x i8] c"Receive Port: %s\0A\00"
@.str.4 = [21 x i8] c"Transport Rate: %ld\0A\00"
@.str.5 = [9 x i8] c"Sending\0A\00"
@.str.6 = [39 x i8] c"Error occurred sending so now I am sad\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca [15 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca %struct.addrinfo*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32*
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
store i8* %20, i8** %8
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
store i8* %23, i8** %9
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 3
%26 = load i8*, i8** %25
store i8* %26, i8** %10
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 4
%29 = load i8*, i8** %28
store i8* %29, i8** %11
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 5
%32 = load i8*, i8** %31
%33 = call i32 @strtol(i8* %32, i8** %6, i32 10)
store i32 %33, i32* %12
%34 = load i8*, i8** %8
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %34)
%36 = load i8*, i8** %9
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = load i8*, i8** %10
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %38)
%40 = load i8*, i8** %11
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %40)
%42 = load i32, i32* %12
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %42)
%44 = load i8*, i8** %8
%45 = load i8*, i8** %10
%46 = call %struct.addrinfo* @createAddressInfo(i8* %44, i8* %45)
store %struct.addrinfo* %46, %struct.addrinfo** %13
%47 = load %struct.addrinfo*, %struct.addrinfo** %13
%48 = call i32 @createSocket(%struct.addrinfo* %47)
store i32 %48, i32* %14
store i32 3, i32* %15
store i32* %15, i32** %16
br label %49
49: ; preds = %2, %64
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%51 = load i32, i32* %14
%52 = load i32*, i32** %16
%53 = load %struct.addrinfo*, %struct.addrinfo** %13
%54 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %53, i32 0, i32 1
%55 = load i32, i32* %54
%56 = load %struct.addrinfo*, %struct.addrinfo** %13
%57 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %56, i32 0, i32 0
%58 = load i32, i32* %57
%59 = call i32 @sendto(i32 %51, i32* %52, i32 8, i32 0, i32 %55, i32 %58)
store i32 %59, i32* %17
%60 = load i32, i32* %17
%61 = icmp eq i32 %60, -1
br i1 %61, label %62, label %64
62: ; preds = %49
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
ret i32 -1
64: ; preds = %49
%65 = call i32 @sleep(i32 1)
br label %49
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32 }
@.str = [17 x i8] c"Transmit IP: %s\0A\00"
@.str.1 = [16 x i8] c"Receive IP: %s\0A\00"
@.str.2 = [19 x i8] c"Transmit Port: %s\0A\00"
@.str.3 = [18 x i8] c"Receive Port: %s\0A\00"
@.str.4 = [21 x i8] c"Transport Rate: %ld\0A\00"
@.str.6 = [39 x i8] c"Error occurred sending so now I am sad\00"
@str = [8 x i8] c"Sending\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = bitcast i8** %3 to i8*
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
%8 = getelementptr inbounds i8*, i8** %1, i64 2
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 3
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 4
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 5
%15 = load i8*, i8** %14
%16 = call i32 @strtol(i8* %15, i8** %3, i32 10)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %7)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%22 = tail call %struct.addrinfo* @createAddressInfo(i8* %7, i8* %11)
%23 = tail call i32 @createSocket(%struct.addrinfo* %22)
%24 = bitcast i32* %4 to i8*
store i32 3, i32* %4
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%26 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 1
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %22, i64 0, i32 0
%29 = load i32, i32* %28
%30 = call i32 @sendto(i32 %23, i32* %4, i32 8, i32 0, i32 %27, i32 %29)
%31 = icmp eq i32 %30, -1
br i1 %31, label %39, label %32
32: ; preds = %2, %32
%33 = call i32 @sleep(i32 1)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%35 = load i32, i32* %26
%36 = load i32, i32* %28
%37 = call i32 @sendto(i32 %23, i32* %4, i32 8, i32 0, i32 %35, i32 %36)
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %32
39: ; preds = %32, %2
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
ret i32 -1
}