#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 /*<<< orphan*/ close(int);
int create_socket(struct in_addr *, int);
int /*<<< orphan*/ inet_aton(char *, struct in_addr *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ send_frames(int);
int main(int argc, char *argv[]) {
  char *ip = "172.16.50.1";
  if (argc >= 2)
    ip = argv[1];
  struct in_addr remote_ip;
  inet_aton(ip, &remote_ip);
  int port = 1000;
  int mySocket = create_socket(&remote_ip, port);
  send_frames(mySocket);
  close(mySocket);
  printf("Sender finished\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe93(%rip),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     1187 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <inet_aton@plt>
movl   $0x3e8,-0x24(%rbp)
mov    -0x24(%rbp),%esi
lea    -0x20(%rbp),%rdi
call   1070 <create_socket@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
call   1040 <send_frames@plt>
mov    -0x28(%rbp),%edi
call   1050 <close@plt>
lea    0xe4b(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jl     1160 <main+0x10>
mov    0x8(%rsi),%rdi
jmp    1167 <main+0x17>
lea    0xe99(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
call   1060 <inet_aton@plt>
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1070 <create_socket@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1040 <send_frames@plt>
mov    %ebx,%edi
call   1050 <close@plt>
lea    0xe74(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.in_addr = type { i32 }
@.str = [12 x i8] c"172.16.50.1\00"
@.str.1 = [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 i8*
%7 = alloca %struct.in_addr
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %6
%10 = load i32, i32* %4
%11 = icmp sge i32 %10, 2
br i1 %11, label %12, label %16
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
store i8* %15, i8** %6
br label %16
16: ; preds = %12, %2
%17 = load i8*, i8** %6
%18 = call i32 @inet_aton(i8* %17, %struct.in_addr* %7)
store i32 1000, i32* %8
%19 = load i32, i32* %8
%20 = call i32 @create_socket(%struct.in_addr* %7, i32 %19)
store i32 %20, i32* %9
%21 = load i32, i32* %9
%22 = call i32 @send_frames(i32 %21)
%23 = load i32, i32* %9
%24 = call i32 @close(i32 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, 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 = [16 x i8] c"Sender finished\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.in_addr
%4 = icmp sgt i32 %0, 1
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
br label %8
8: ; preds = %5, %2
%9 = phi i8* [ %7, %5 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), %2 ]
%10 = bitcast %struct.in_addr* %3 to i8*
%11 = call i32 @inet_aton(i8* %9, %struct.in_addr* %3)
%12 = call i32 @create_socket(%struct.in_addr* %3, i32 1000)
%13 = call i32 @send_frames(i32 %12)
%14 = call i32 @close(i32 %12)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
ret i32 0
}