#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*/ SHUT_RDWR;
int /*<<< orphan*/ atoi(char *);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
int read(int, char *, int);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int socket_connect(char *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int fd, n;
  char sendline[4096 + 1], recvline[4096 + 1];
  if (argc < 3) {
    fprintf(stderr, "Usage: %s <hostname> <port>\n", argv[0]);
    exit(1);
  }
  snprintf(sendline, 300,
           "GET %s HTTP/1.1\r\n"
           "Host: %s\r\n"
           "Accept: "
           "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n"
           "Accept-Encoding: gzip, deflate\r\n"
           "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:30.0) "
           "Gecko/20100101 Firefox/30.0\r\n"
           "Pragma: no-cache\r\n"
           "Cache-Control: no-cache\r\n"
           "Connection: close\r\n\r\n",
           "/config.ini", argv[1]);
  fd = socket_connect(argv[1], atoi(argv[2]));
  if (fd <= 0) {
    fprintf(stderr, "socket connect error! %d\n", fd);
    exit(1);
  }
  write(fd, sendline, strlen(sendline));
  bzero(recvline, 4096);
  while ((n = read(fd, recvline, 4096)) > 0) {
    recvline[n] = '\0';
    printf("%s", recvline);
    bzero(recvline, 4096);
  }
  shutdown(fd, SHUT_RDWR);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    120b <main+0x4b>
mov    0x2dee(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe06(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8
mov    $0x12c,%esi
lea    0xdf7(%rip),%rdx
lea    0xf0b(%rip),%rcx
call   1070 <snprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x2038(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10d0 <atoi@plt>
mov    -0x2038(%rbp),%rdi
mov    %eax,%esi
call   10b0 <socket_connect@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     128d <main+0xcd>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xec8(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2044(%rbp)
lea    -0x1020(%rbp),%rax
mov    %rax,-0x2040(%rbp)
lea    -0x1020(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2044(%rbp),%edi
mov    -0x2040(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    -0x2030(%rbp),%rdi
mov    $0x1000,%esi
call   10c0 <bzero@plt>
mov    -0x14(%rbp),%edi
lea    -0x2030(%rbp),%rsi
mov    $0x1000,%edx
call   1090 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    132a <main+0x16a>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x2030(%rbp,%rax,1)
lea    -0x2030(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1060 <printf@plt>
lea    -0x2030(%rbp),%rdi
mov    $0x1000,%esi
call   10c0 <bzero@plt>
jmp    12d5 <main+0x115>
mov    -0x14(%rbp),%edi
mov    0x2cbc(%rip),%rax
mov    (%rax),%esi
call   1040 <shutdown@plt>
mov    -0x14(%rbp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x2050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x2020,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jle    12c6 <main+0x106>
mov    0x8(%rbx),%r8
lea    0xe3b(%rip),%rdx
lea    0xf4f(%rip),%rcx
lea    0x1010(%rsp),%rdi
mov    $0x12c,%esi
call   1070 <snprintf@plt>
mov    0x8(%rbx),%rbp
mov    0x10(%rbx),%rdi
call   10d0 <atoi@plt>
mov    %rbp,%rdi
mov    %eax,%esi
call   10b0 <socket_connect@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    12ea <main+0x12a>
lea    0x1010(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   10c0 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1090 <read@plt>
test   %eax,%eax
jle    12a1 <main+0xe1>
lea    0xefc(%rip),%r14
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %eax,%eax
movb   $0x0,(%rsp,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
call   10c0 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1090 <read@plt>
test   %eax,%eax
jg     1270 <main+0xb0>
mov    0x2d48(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   1040 <shutdown@plt>
mov    %ebp,%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x2020,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd27(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    0x2ce7(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: %s <hostname> <port>\0A\00"
@.str.1 = [283 x i8] c"GET %s HTTP/1.1\0D\0AHost: %s\0D\0AAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\0D\0AAccept-Encoding: gzip, deflate\0D\0AUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0\0D\0APragma: no-cache\0D\0ACache-Control: no-cache\0D\0AConnection: close\0D\0A\0D\0A\00"
@.str.2 = [12 x i8] c"/config.ini\00"
@.str.3 = [26 x i8] c"socket connect error! %d\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@SHUT_RDWR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [4097 x i8]
%9 = alloca [4097 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 3
br i1 %11, label %12, label %19
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds [4097 x i8], [4097 x i8]* %8, i64 0, i64 0
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @snprintf(i8* %20, i32 300, i8* getelementptr inbounds ([283 x i8], [283 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
%32 = call i32 @socket_connect(i8* %27, i32 %31)
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp sle i32 %33, 0
br i1 %34, label %35, label %40
35: ; preds = %19
%36 = load i32, i32* @stderr
%37 = load i32, i32* %6
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %19
%41 = load i32, i32* %6
%42 = getelementptr inbounds [4097 x i8], [4097 x i8]* %8, i64 0, i64 0
%43 = getelementptr inbounds [4097 x i8], [4097 x i8]* %8, i64 0, i64 0
%44 = call i32 @strlen(i8* %43)
%45 = call i32 @write(i32 %41, i8* %42, i32 %44)
%46 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%47 = call i32 @bzero(i8* %46, i32 4096)
br label %48
48: ; preds = %53, %40
%49 = load i32, i32* %6
%50 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%51 = call i32 @read(i32 %49, i8* %50, i32 4096)
store i32 %51, i32* %7
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %61
53: ; preds = %48
%54 = load i32, i32* %7
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 %55
store i8 0, i8* %56
%57 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%58 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %57)
%59 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%60 = call i32 @bzero(i8* %59, i32 4096)
br label %48
61: ; preds = %48
%62 = load i32, i32* %6
%63 = load i32, i32* @SHUT_RDWR
%64 = call i32 @shutdown(i32 %62, i32 %63)
%65 = load i32, i32* %6
%66 = call i32 @close(i32 %65)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [29 x i8] c"Usage: %s <hostname> <port>\0A\00"
@.str.1 = [283 x i8] c"GET %s HTTP/1.1\0D\0AHost: %s\0D\0AAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\0D\0AAccept-Encoding: gzip, deflate\0D\0AUser-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0\0D\0APragma: no-cache\0D\0ACache-Control: no-cache\0D\0AConnection: close\0D\0A\0D\0A\00"
@.str.2 = [12 x i8] c"/config.ini\00"
@.str.3 = [26 x i8] c"socket connect error! %d\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@SHUT_RDWR = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4097 x i8]
%4 = alloca [4097 x i8]
%5 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%7 = icmp slt i32 %0, 3
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @snprintf(i8* %5, i32 300, i8* getelementptr inbounds ([283 x i8], [283 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = load i8*, i8** %14
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
%21 = call i32 @socket_connect(i8* %17, i32 %20)
%22 = icmp slt i32 %21, 1
br i1 %22, label %23, label %27
23: ; preds = %13
%24 = load i32, i32* @stderr
%25 = call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %21)
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %13
%28 = call i32 @strlen(i8* %5)
%29 = call i32 @write(i32 %21, i8* %5, i32 %28)
%30 = call i32 @bzero(i8* %6, i32 4096)
%31 = call i32 @read(i32 %21, i8* %6, i32 4096)
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %41
33: ; preds = %27, %33
%34 = phi i32 [ %39, %33 ], [ %31, %27 ]
%35 = zext i32 %34 to i64
%36 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 %35
store i8 0, i8* %36
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%38 = call i32 @bzero(i8* %6, i32 4096)
%39 = call i32 @read(i32 %21, i8* %6, i32 4096)
%40 = icmp sgt i32 %39, 0
br i1 %40, label %33, label %41
41: ; preds = %33, %27
%42 = load i32, i32* @SHUT_RDWR
%43 = call i32 @shutdown(i32 %21, i32 %42)
%44 = call i32 @close(i32 %21)
ret i32 0
}