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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int socketConnect(int, char *, int);
int socketCreate();
int socketDisconnect(int);
int socketReceive(int, char *, int);
int socketSend(int, char *, int);
int main() {
  char google[] = "173.194.79.103";
  char message[] = "GET / HTTP/1.1\r\n\r\n";
  char reply[2000];
  int port = 80;
  int ret, sd;
  sd = socketCreate();
  printf("Created socket wrapper with descriptor %d.\n", sd);
  ret = socketConnect(sd, google, port);
  printf(
      "Socket wrapper connected to '%s' on port '%d' with return value %d.\n",
      google, port, ret);
  ret = socketSend(sd, message, -1);
  printf("Socket wrapper sent: \n\n'%s'\n\nto '%s' on port '%d' with return "
         "value %d.\n",
         message, google, port, ret);
  ret = socketReceive(sd, reply, 2000);
  printf("Socket wrapper received: \n\n'%s'\n\nfrom '%s' on port '%d' with "
         "return value %d.\n",
         reply, google, port, ret);
  ret = socketDisconnect(sd);
  printf("Socket wrapper disconnected from '%s' on port '%d' with return value "
         "%d.\n",
         google, port, ret);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe87(%rip),%rax
mov    %rax,-0x13(%rbp)
mov    0xe85(%rip),%eax
mov    %eax,-0xb(%rbp)
mov    0xe7f(%rip),%ax
mov    %ax,-0x7(%rbp)
mov    0xe77(%rip),%al
mov    %al,-0x5(%rbp)
mov    0xfcf(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xfcc(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xfc9(%rip),%ax
mov    %ax,-0x20(%rbp)
mov    0xfc1(%rip),%al
mov    %al,-0x1e(%rbp)
movl   $0x50,-0x804(%rbp)
mov    $0x0,%al
call   1040 <socketCreate@plt>
mov    %eax,-0x80c(%rbp)
mov    -0x80c(%rbp),%esi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x80c(%rbp),%edi
lea    -0x13(%rbp),%rsi
mov    -0x804(%rbp),%edx
call   1050 <socketConnect@plt>
mov    %eax,-0x808(%rbp)
lea    -0x13(%rbp),%rsi
mov    -0x804(%rbp),%edx
mov    -0x808(%rbp),%ecx
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x80c(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xffffffff,%edx
call   1080 <socketSend@plt>
mov    %eax,-0x808(%rbp)
lea    -0x30(%rbp),%rsi
lea    -0x13(%rbp),%rdx
mov    -0x804(%rbp),%ecx
mov    -0x808(%rbp),%r8d
lea    0xe22(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x80c(%rbp),%edi
lea    -0x800(%rbp),%rsi
mov    $0x7d0,%edx
call   1030 <socketReceive@plt>
mov    %eax,-0x808(%rbp)
lea    -0x800(%rbp),%rsi
lea    -0x13(%rbp),%rdx
mov    -0x804(%rbp),%ecx
mov    -0x808(%rbp),%r8d
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x80c(%rbp),%edi
call   1070 <socketDisconnect@plt>
mov    %eax,-0x808(%rbp)
lea    -0x13(%rbp),%rsi
mov    -0x804(%rbp),%edx
mov    -0x808(%rbp),%ecx
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x800,%rsp
movabs $0x3330312e39372e,%rax
mov    %rax,0x7(%rsp)
movabs $0x2e3439312e333731,%rax
39 34 2e
mov    %rax,(%rsp)
movaps 0xfe0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0xa0d0a,0x1f(%rsp)
xor    %eax,%eax
call   1040 <socketCreate@plt>
mov    %eax,%ebx
lea    0xe62(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rsp,%r14
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x50,%edx
call   1050 <socketConnect@plt>
lea    0xe6c(%rip),%rdi
mov    %r14,%rsi
mov    $0x50,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%r15
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0xffffffff,%edx
call   1080 <socketSend@plt>
lea    0xe85(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x50,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x30(%rsp),%r15
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x7d0,%edx
call   1030 <socketReceive@plt>
lea    0xe9e(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
mov    $0x50,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1070 <socketDisconnect@plt>
lea    0xeca(%rip),%rdi
mov    %r14,%rsi
mov    $0x50,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x800,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.google = [15 x i8] c"173.194.79.103\00"
@__const.main.message = [19 x i8] c"GET / HTTP/1.1\0D\0A\0D\0A\00"
@.str = [44 x i8] c"Created socket wrapper with descriptor %d.\0A\00"
@.str.1 = [69 x i8] c"Socket wrapper connected to '%s' on port '%d' with return value %d.\0A\00"
@.str.2 = [73 x i8] c"Socket wrapper sent: \0A\0A'%s'\0A\0Ato '%s' on port '%d' with return value %d.\0A\00"
@.str.3 = [79 x i8] c"Socket wrapper received: \0A\0A'%s'\0A\0Afrom '%s' on port '%d' with return value %d.\0A\00"
@.str.4 = [74 x i8] c"Socket wrapper disconnected from '%s' on port '%d' with return value %d.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [15 x i8]
%3 = alloca [19 x i8]
%4 = alloca [2000 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [15 x i8]* %2 to i8*
%9 = bitcast [19 x i8]* %3 to i8*
store i32 80, i32* %5
%10 = call i32 (...) @socketCreate()
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = load i32, i32* %7
%14 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%15 = load i32, i32* %5
%16 = call i32 @socketConnect(i32 %13, i8* %14, i32 %15)
store i32 %16, i32* %6
%17 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), i8* %17, i32 %18, i32 %19)
%21 = load i32, i32* %7
%22 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%23 = call i32 @socketSend(i32 %21, i8* %22, i32 -1)
store i32 %23, i32* %6
%24 = getelementptr inbounds [19 x i8], [19 x i8]* %3, i64 0, i64 0
%25 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0), i8* %24, i8* %25, i32 %26, i32 %27)
%29 = load i32, i32* %7
%30 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 0
%31 = call i32 @socketReceive(i32 %29, i8* %30, i32 2000)
store i32 %31, i32* %6
%32 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 0
%33 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%34 = load i32, i32* %5
%35 = load i32, i32* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i8* %32, i8* %33, i32 %34, i32 %35)
%37 = load i32, i32* %7
%38 = call i32 @socketDisconnect(i32 %37)
store i32 %38, i32* %6
%39 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.4, i64 0, i64 0), i8* %39, i32 %40, i32 %41)
ret i32 0
}

LLVM IR (-O2):
@__const.main.google = [15 x i8] c"173.194.79.103\00"
@__const.main.message = [19 x i8] c"GET / HTTP/1.1\0D\0A\0D\0A\00"
@.str = [44 x i8] c"Created socket wrapper with descriptor %d.\0A\00"
@.str.1 = [69 x i8] c"Socket wrapper connected to '%s' on port '%d' with return value %d.\0A\00"
@.str.2 = [73 x i8] c"Socket wrapper sent: \0A\0A'%s'\0A\0Ato '%s' on port '%d' with return value %d.\0A\00"
@.str.3 = [79 x i8] c"Socket wrapper received: \0A\0A'%s'\0A\0Afrom '%s' on port '%d' with return value %d.\0A\00"
@.str.4 = [74 x i8] c"Socket wrapper disconnected from '%s' on port '%d' with return value %d.\0A\00"
define i32 @main() {
%1 = alloca [15 x i8]
%2 = alloca [19 x i8]
%3 = alloca [2000 x i8]
%4 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [19 x i8], [19 x i8]* %2, i64 0, i64 0
%6 = getelementptr inbounds [2000 x i8], [2000 x i8]* %3, i64 0, i64 0
%7 = tail call i32 (...) @socketCreate()
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @socketConnect(i32 %7, i8* %4, i32 80)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([69 x i8], [69 x i8]* @.str.1, i64 0, i64 0), i8* %4, i32 80, i32 %9)
%11 = call i32 @socketSend(i32 %7, i8* %5, i32 -1)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([73 x i8], [73 x i8]* @.str.2, i64 0, i64 0), i8* %5, i8* %4, i32 80, i32 %11)
%13 = call i32 @socketReceive(i32 %7, i8* %6, i32 2000)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* %4, i32 80, i32 %13)
%15 = call i32 @socketDisconnect(i32 %7)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.4, i64 0, i64 0), i8* %4, i32 80, i32 %15)
ret i32 0
}