#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ dest;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EXIT_SUCCESS;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *, int);
int send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  char buffer[] = "GET /versionP HTTP/1.1\n\n";
  int len, mysocket;
  struct sockaddr_in dest;
  mysocket = socket(AF_INET, SOCK_STREAM, 0);
  memset(&dest, 0, sizeof(dest));
  dest.sin_family = AF_INET;
  dest.sin_addr.s_addr = inet_addr(argv[1]);
  dest.sin_port = htons(atoi(argv[2]));
  connect(mysocket, (struct sockaddr *)&dest, sizeof(struct sockaddr));
  perror("connect");
  len = send(mysocket, buffer, strlen(buffer), 0);
  perror("len\n");
  buffer[len] = '\0';
  printf("sent %s (%d bytes).\n", buffer, len);
  close(mysocket);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xe33(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe30(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe2d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe2b(%rip),%al
mov    %al,-0x18(%rbp)
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    0x2dd8(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,-0x38(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,-0x48(%rbp)
mov    -0x38(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0x4,%edx
call   10c0 <connect@plt>
lea    0xdb2(%rip),%rdi
call   10a0 <perror@plt>
mov    -0x38(%rbp),%eax
mov    %eax,-0x54(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %eax,-0x34(%rbp)
lea    0xd84(%rip),%rdi
call   10a0 <perror@plt>
movslq -0x34(%rbp),%rax
movb   $0x0,-0x30(%rbp,%rax,1)
lea    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
lea    0xd6d(%rip),%rdi
call   1060 <printf@plt>
mov    -0x38(%rbp),%edi
call   1080 <close@plt>
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
movups 0xe45(%rip),%xmm0
movups %xmm0,0x19(%rsp)
movaps 0xe30(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    0x2e0c(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2df2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10d0 <socket@plt>
mov    %eax,%r15d
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    0x8(%rbx),%rdi
call   1090 <inet_addr@plt>
mov    %eax,0x4(%rsp)
mov    0x10(%rbx),%rdi
call   10b0 <atoi@plt>
mov    %eax,%edi
call   1040 <htons@plt>
mov    %eax,(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   10c0 <connect@plt>
lea    0xdd7(%rip),%rdi
call   10a0 <perror@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    %eax,%ebp
lea    0xdb5(%rip),%rdi
call   10a0 <perror@plt>
movslq %ebp,%rdx
movb   $0x0,0x10(%rsp,%rdx,1)
lea    0xda6(%rip),%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %r15d,%edi
call   1080 <close@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.buffer = [25 x i8] c"GET /versionP HTTP/1.1\0A\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [8 x i8] c"connect\00"
@.str.1 = [5 x i8] c"len\0A\00"
@.str.2 = [21 x i8] c"sent %s (%d bytes).\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [25 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = bitcast [25 x i8]* %6 to i8*
%11 = load i32, i32* @AF_INET
%12 = load i32, i32* @SOCK_STREAM
%13 = call i32 @socket(i32 %11, i32 %12, i32 0)
store i32 %13, i32* %8
%14 = call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 12)
%15 = load i32, i32* @AF_INET
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %15, i32* %16
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @inet_addr(i8* %19)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
store i32 %20, i32* %22
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @atoi(i8* %25)
%27 = call i32 @htons(i32 %26)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
store i32 %27, i32* %28
%29 = load i32, i32* %8
%30 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%31 = call i32 @connect(i32 %29, %struct.sockaddr* %30, i32 4)
%32 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%33 = load i32, i32* %8
%34 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%35 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%36 = call i32 @strlen(i8* %35)
%37 = call i32 @send(i32 %33, i8* %34, i32 %36, i32 0)
store i32 %37, i32* %7
%38 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 %40
store i8 0, i8* %41
%42 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%43 = load i32, i32* %7
%44 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %42, i32 %43)
%45 = load i32, i32* %8
%46 = call i32 @close(i32 %45)
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@__const.main.buffer = [25 x i8] c"GET /versionP HTTP/1.1\0A\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [8 x i8] c"connect\00"
@.str.1 = [5 x i8] c"len\0A\00"
@.str.2 = [21 x i8] c"sent %s (%d bytes).\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [25 x i8]
%4 = alloca %struct.sockaddr_in
%5 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.sockaddr_in* %4 to i8*
%7 = load i32, i32* @AF_INET
%8 = load i32, i32* @SOCK_STREAM
%9 = tail call i32 @socket(i32 %7, i32 %8, i32 0)
%10 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 12)
%11 = load i32, i32* @AF_INET
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %11, i32* %12
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @inet_addr(i8* %14)
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1, i32 0
store i32 %15, i32* %16
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @atoi(i8* %18)
%20 = call i32 @htons(i32 %19)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %20, i32* %21
%22 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%23 = call i32 @connect(i32 %9, %struct.sockaddr* %22, i32 4)
%24 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @strlen(i8* %5)
%26 = call i32 @send(i32 %9, i8* %5, i32 %25, i32 0)
%27 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%28 = sext i32 %26 to i64
%29 = getelementptr inbounds [25 x i8], [25 x i8]* %3, i64 0, i64 %28
store i8 0, i8* %29
%30 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8* %5, i32 %26)
%31 = call i32 @close(i32 %9)
%32 = load i32, i32* @EXIT_SUCCESS
ret i32 %32
}