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

/* Variables and functions */
int /*<<< orphan*/ close(int);
int createClientConnection(int, char *, struct sockaddr_in6 *);
int /*<<< orphan*/ getAnswer(int, struct sockaddr_in6 *);
int /*<<< orphan*/ sendRequest(int, struct sockaddr_in6);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int main(int argc, char **argv) {
  struct sockaddr_in6 server_addr, client_addr;
  int port;
  sscanf(argv[2], "%d", &port);
  int sock = createClientConnection(port, argv[1], &server_addr);
  sendRequest(sock, server_addr);
  getAnswer(sock, &client_addr);
  close(sock);
  return 0;
}


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)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe8b(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x24(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x18(%rbp),%rdx
call   1070 <createClientConnection@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <sendRequest@plt>
mov    -0x28(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1040 <getAnswer@plt>
mov    -0x28(%rbp),%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    0x10(%rsi),%rdi
lea    0xe9d(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1050 <sscanf@plt>
mov    0x4(%rsp),%edi
mov    0x8(%rbx),%rsi
mov    %rsp,%rdx
call   1070 <createClientConnection@plt>
mov    %eax,%ebx
mov    (%rsp),%esi
mov    %eax,%edi
call   1060 <sendRequest@plt>
lea    0x8(%rsp),%rsi
mov    %ebx,%edi
call   1040 <getAnswer@plt>
mov    %ebx,%edi
call   1030 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i32 }
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in6
%7 = alloca %struct.sockaddr_in6
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 2
%12 = load i8*, i8** %11
%13 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %8)
%14 = load i32, i32* %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @createClientConnection(i32 %14, i8* %17, %struct.sockaddr_in6* %6)
store i32 %18, i32* %9
%19 = load i32, i32* %9
%20 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %6, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @sendRequest(i32 %19, i32 %21)
%23 = load i32, i32* %9
%24 = call i32 @getAnswer(i32 %23, %struct.sockaddr_in6* %7)
%25 = load i32, i32* %9
%26 = call i32 @close(i32 %25)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i32 }
@.str = [3 x i8] c"%d\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in6
%4 = alloca %struct.sockaddr_in6
%5 = alloca i32
%6 = bitcast %struct.sockaddr_in6* %3 to i8*
%7 = bitcast %struct.sockaddr_in6* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = call i32 @sscanf(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %5)
%12 = load i32, i32* %5
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @createClientConnection(i32 %12, i8* %14, %struct.sockaddr_in6* %3)
%16 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %3, i64 0, i32 0
%17 = load i32, i32* %16
%18 = call i32 @sendRequest(i32 %15, i32 %17)
%19 = call i32 @getAnswer(i32 %15, %struct.sockaddr_in6* %4)
%20 = call i32 @close(i32 %15)
ret i32 0
}