#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 in_addr {
  int dummy;
};

/* Variables and functions */
int create_socket(struct in_addr *, int);
int /*<<< orphan*/ inet_aton(char *, struct in_addr *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ send_end_frame(int);
int /*<<< orphan*/ send_frames(int);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  struct in_addr remote_ip;
  inet_aton("172.16.50.1", &remote_ip);
  int mySocket = create_socket(&remote_ip, 2000);
  if (argc > 1 && strcmp(argv[1], "end") == 0) {
    send_end_frame(mySocket);
  } else {
    send_frames(mySocket);
  }
  printf("Sender finished\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe83(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <inet_aton@plt>
lea    -0x18(%rbp),%rdi
mov    $0x7d0,%esi
call   1080 <create_socket@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    11cc <main+0x6c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    11cc <main+0x6c>
mov    -0x1c(%rbp),%edi
call   1030 <send_end_frame@plt>
jmp    11d4 <main+0x74>
mov    -0x1c(%rbp),%edi
call   1050 <send_frames@plt>
lea    0xe35(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %edi,%ebp
lea    0xe8c(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1070 <inet_aton@plt>
mov    %rbx,%rdi
mov    $0x7d0,%esi
call   1080 <create_socket@plt>
mov    %eax,%ebx
cmp    $0x2,%ebp
jl     11aa <main+0x4a>
mov    0x8(%r14),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <strcmp@plt>
test   %rax,%rax
je     11b3 <main+0x53>
mov    %ebx,%edi
call   1050 <send_frames@plt>
jmp    11ba <main+0x5a>
mov    %ebx,%edi
call   1030 <send_end_frame@plt>
lea    0xe4f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@.str = [12 x i8] c"172.16.50.1\00"
@.str.1 = [4 x i8] c"end\00"
@.str.2 = [17 x i8] c"Sender finished\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.in_addr
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i32 @inet_aton(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.in_addr* %6)
%9 = call i32 @create_socket(%struct.in_addr* %6, i32 2000)
store i32 %9, i32* %7
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %21
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i32, i32* %7
%20 = call i32 @send_end_frame(i32 %19)
br label %24
21: ; preds = %12, %2
%22 = load i32, i32* %7
%23 = call i32 @send_frames(i32 %22)
br label %24
24: ; preds = %21, %18
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
%struct.in_addr = type { i32 }
@.str = [12 x i8] c"172.16.50.1\00"
@.str.1 = [4 x i8] c"end\00"
@str = [16 x i8] c"Sender finished\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.in_addr
%4 = bitcast %struct.in_addr* %3 to i8*
%5 = call i32 @inet_aton(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %struct.in_addr* %3)
%6 = call i32 @create_socket(%struct.in_addr* %3, i32 2000)
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @send_end_frame(i32 %6)
br label %17
15: ; preds = %8, %2
%16 = call i32 @send_frames(i32 %6)
br label %17
17: ; preds = %15, %13
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
ret i32 0
}