#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 */
typedef int /*<<< orphan*/ uint32_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  scalar_t__ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  scalar_t__ h_addrtype;
  scalar_t__ *h_addr_list;
};
typedef int /*<<< orphan*/ sa;
typedef int /*<<< orphan*/ msg;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ AF_INET;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main(int argc, char *argv[]) {
  int sock, msg_len, n;
  struct sockaddr_in sa;
  struct hostent *host;
  char msg[512], buf[1024];
  if (argc < 2) {
    fprintf(stderr, "too few argument\n");
    exit(1);
  } else if (argc > 3) {
    fprintf(stderr, "too many argument\n");
    exit(1);
  }
  host = gethostbyname(argv[1]);
  if (host == NULL) {
    fprintf(stderr, "gethostbyname() failuer\n");
    exit(1);
  } else if (host->h_addrtype != AF_INET) {
    fprintf(stderr, "h_addrtype is not AF_INET\n");
    exit(1);
  }
  sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  memset(&sa, 0, sizeof(sa));
  sa.sin_family = AF_INET;
  sa.sin_port = htons(80);
  sa.sin_addr.s_addr = *((uint32_t *)(host->h_addr_list[0]));
  if (connect(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
    fprintf(stderr, "connect() failuer\n");
    exit(1);
  }
  if (argc == 2) {
    snprintf(msg, sizeof(msg),
             "GET / HTTP/1.1\r\nHOST: %s\r\nConnection: close\r\n\r\n",
             argv[1]);
  } else if (argc == 3) {
    snprintf(msg, sizeof(msg),
             "GET / HTTP/1.1\r\nHOST: %s\r\nConnection: close\r\n\r\n", argv[2],
             argv[1]);
  }
  msg_len = strlen(msg);
  if (send(sock, msg, msg_len, 0) != msg_len) {
    fprintf(stderr, "send() failuer\n");
    exit(1);
  }
  while ((n = recv(sock, buf, sizeof(buf), 0)) > 0) {
    buf[n] = '\0';
    printf("%s", buf);
  }
  if (n < 0) {
    fprintf(stderr, "recv() failuer\n");
    exit(1);
  }
  printf("\n");
  close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x640,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1212 <main+0x42>
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
lea    0xdfd(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x3,-0x8(%rbp)
jle    123b <main+0x6b>
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
lea    0xde6(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    1240 <main+0x70>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <gethostbyname@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    127b <main+0xab>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
lea    0xdb9(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x2d5f(%rip),%rcx
cmp    (%rcx),%rax
je     12b1 <main+0xe1>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
lea    0xd9c(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    12b6 <main+0xe6>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
mov    0x2d02(%rip),%rax
mov    (%rax),%esi
mov    0x2d11(%rip),%rax
mov    (%rax),%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1090 <memset@plt>
mov    0x2cf8(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    $0x50,%edi
call   1050 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0x10,%edx
call   10e0 <connect@plt>
cmp    $0x0,%rax
jge    134e <main+0x17e>
mov    0x2c9a(%rip),%rax
mov    (%rax),%edi
lea    0xd1a(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
cmpl   $0x2,-0x8(%rbp)
jne    137f <main+0x1af>
lea    -0x240(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
mov    $0x200,%esi
lea    0xcf9(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
jmp    13b8 <main+0x1e8>
cmpl   $0x3,-0x8(%rbp)
jne    13b3 <main+0x1e3>
lea    -0x240(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8
mov    $0x200,%esi
lea    0xcc0(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
jmp    13b8 <main+0x1e8>
lea    -0x240(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x240(%rbp),%rsi
mov    -0x18(%rbp),%edx
xor    %ecx,%ecx
call   1060 <send@plt>
cmp    -0x18(%rbp),%eax
je     1403 <main+0x233>
mov    0x2be5(%rip),%rax
mov    (%rax),%edi
lea    0xca8(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    1408 <main+0x238>
mov    -0x14(%rbp),%edi
lea    -0x640(%rbp),%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jle    1450 <main+0x280>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x640(%rbp,%rax,1)
lea    -0x640(%rbp),%rsi
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    1408 <main+0x238>
cmpl   $0x0,-0x1c(%rbp)
jge    1479 <main+0x2a9>
mov    0x2b6f(%rip),%rax
mov    (%rax),%edi
lea    0xc45(%rip),%rsi
call   10c0 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xc1a(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x640,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x618,%rsp
cmp    $0x1,%edi
jle    139b <main+0x1bb>
mov    %edi,%r15d
cmp    $0x4,%edi
jae    13ad <main+0x1cd>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   10c0 <gethostbyname@plt>
test   %rax,%rax
je     13bf <main+0x1df>
mov    %rax,%rbp
mov    (%rax),%rax
mov    0x2dc0(%rip),%r13
cmp    0x0(%r13),%rax
jne    13d1 <main+0x1f1>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    0x2d86(%rip),%rax
mov    (%rax),%esi
mov    0x2d95(%rip),%rax
mov    (%rax),%edx
call   1100 <socket@plt>
mov    %eax,%r12d
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10a0 <memset@plt>
mov    0x0(%r13),%rax
mov    %rax,0x8(%rsp)
mov    $0x50,%edi
call   1060 <htons@plt>
mov    %eax,0x4(%rsp)
mov    0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x10,%edx
call   10f0 <connect@plt>
test   %rax,%rax
js     13e3 <main+0x203>
cmp    $0x2,%r15d
jne    12c7 <main+0xe7>
mov    0x8(%r14),%rcx
lea    0xdb8(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x200,%esi
xor    %eax,%eax
call   1090 <snprintf@plt>
jmp    12e7 <main+0x107>
mov    0x8(%r14),%r8
mov    0x10(%r14),%rcx
lea    0xd96(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x200,%esi
xor    %eax,%eax
call   1090 <snprintf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r12d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <send@plt>
cmp    %ebp,%eax
jne    13f5 <main+0x215>
lea    0x210(%rsp),%rsi
mov    %r12d,%edi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    136d <main+0x18d>
lea    0xd7d(%rip),%rbp
lea    0x210(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %eax,%eax
movb   $0x0,0x210(%rsp,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jg     1340 <main+0x160>
test   %eax,%eax
js     1407 <main+0x227>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    %r12d,%edi
call   10b0 <close@plt>
xor    %eax,%eax
add    $0x618,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c2e(%rip),%rax
mov    (%rax),%edi
lea    0xc55(%rip),%rsi
jmp    1417 <main+0x237>
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
lea    0xc55(%rip),%rsi
jmp    1417 <main+0x237>
mov    0x2c0a(%rip),%rax
mov    (%rax),%edi
lea    0xc56(%rip),%rsi
jmp    1417 <main+0x237>
mov    0x2bf8(%rip),%rax
mov    (%rax),%edi
lea    0xc5d(%rip),%rsi
jmp    1417 <main+0x237>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
lea    0xc66(%rip),%rsi
jmp    1417 <main+0x237>
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
lea    0xc97(%rip),%rsi
jmp    1417 <main+0x237>
mov    0x2bc2(%rip),%rax
mov    (%rax),%edi
lea    0xc98(%rip),%rsi
call   10d0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i64 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i64, i64* }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"too few argument\0A\00"
@.str.1 = [19 x i8] c"too many argument\0A\00"
@.str.2 = [25 x i8] c"gethostbyname() failuer\0A\00"
@AF_INET = global i64 0
@.str.3 = [27 x i8] c"h_addrtype is not AF_INET\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.4 = [19 x i8] c"connect() failuer\0A\00"
@.str.5 = [48 x i8] c"GET / HTTP/1.1\0D\0AHOST: %s\0D\0AConnection: close\0D\0A\0D\0A\00"
@.str.6 = [16 x i8] c"send() failuer\0A\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [16 x i8] c"recv() failuer\0A\00"
@.str.9 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca %struct.hostent*
%11 = alloca [512 x i8]
%12 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = load i32, i32* %4
%21 = icmp sgt i32 %20, 3
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %19
br label %27
27: ; preds = %26
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call %struct.hostent* @gethostbyname(i8* %30)
store %struct.hostent* %31, %struct.hostent** %10
%32 = load %struct.hostent*, %struct.hostent** %10
%33 = icmp eq %struct.hostent* %32, null
br i1 %33, label %34, label %38
34: ; preds = %27
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %27
%39 = load %struct.hostent*, %struct.hostent** %10
%40 = getelementptr inbounds %struct.hostent, %struct.hostent* %39, i32 0, i32 0
%41 = load i64, i64* %40
%42 = load i64, i64* @AF_INET
%43 = icmp ne i64 %41, %42
br i1 %43, label %44, label %48
44: ; preds = %38
%45 = load i32, i32* @stderr
%46 = call i32 @fprintf(i32 %45, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %38
br label %49
49: ; preds = %48
%50 = load i32, i32* @PF_INET
%51 = load i32, i32* @SOCK_STREAM
%52 = load i32, i32* @IPPROTO_TCP
%53 = call i32 @socket(i32 %50, i32 %51, i32 %52)
store i32 %53, i32* %6
%54 = call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 16)
%55 = load i64, i64* @AF_INET
%56 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i64 %55, i64* %56
%57 = call i32 @htons(i32 80)
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i32 %57, i32* %58
%59 = load %struct.hostent*, %struct.hostent** %10
%60 = getelementptr inbounds %struct.hostent, %struct.hostent* %59, i32 0, i32 1
%61 = load i64*, i64** %60
%62 = getelementptr inbounds i64, i64* %61, i64 0
%63 = load i64, i64* %62
%64 = inttoptr i64 %63 to i32*
%65 = load i32, i32* %64
%66 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%67 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %66, i32 0, i32 0
store i32 %65, i32* %67
%68 = load i32, i32* %6
%69 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%70 = call i64 @connect(i32 %68, %struct.sockaddr* %69, i32 16)
%71 = icmp slt i64 %70, 0
br i1 %71, label %72, label %76
72: ; preds = %49
%73 = load i32, i32* @stderr
%74 = call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %49
%77 = load i32, i32* %4
%78 = icmp eq i32 %77, 2
br i1 %78, label %79, label %85
79: ; preds = %76
%80 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 1
%83 = load i8*, i8** %82
%84 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %80, i32 512, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i8* %83)
br label %98
85: ; preds = %76
%86 = load i32, i32* %4
%87 = icmp eq i32 %86, 3
br i1 %87, label %88, label %97
88: ; preds = %85
%89 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%90 = load i8**, i8*** %5
%91 = getelementptr inbounds i8*, i8** %90, i64 2
%92 = load i8*, i8** %91
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 1
%95 = load i8*, i8** %94
%96 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %89, i32 512, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i8* %92, i8* %95)
br label %97
97: ; preds = %88, %85
br label %98
98: ; preds = %97, %79
%99 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%100 = call i32 @strlen(i8* %99)
store i32 %100, i32* %7
%101 = load i32, i32* %6
%102 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%103 = load i32, i32* %7
%104 = call i32 @send(i32 %101, i8* %102, i32 %103, i32 0)
%105 = load i32, i32* %7
%106 = icmp ne i32 %104, %105
br i1 %106, label %107, label %111
107: ; preds = %98
%108 = load i32, i32* @stderr
%109 = call i32 @fprintf(i32 %108, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%110 = call i32 @exit(i32 1)
unreachable
111: ; preds = %98
br label %112
112: ; preds = %117, %111
%113 = load i32, i32* %6
%114 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%115 = call i32 @recv(i32 %113, i8* %114, i32 1024, i32 0)
store i32 %115, i32* %8
%116 = icmp sgt i32 %115, 0
br i1 %116, label %117, label %123
117: ; preds = %112
%118 = load i32, i32* %8
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 %119
store i8 0, i8* %120
%121 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %121)
br label %112
123: ; preds = %112
%124 = load i32, i32* %8
%125 = icmp slt i32 %124, 0
br i1 %125, label %126, label %130
126: ; preds = %123
%127 = load i32, i32* @stderr
%128 = call i32 @fprintf(i32 %127, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%129 = call i32 @exit(i32 1)
unreachable
130: ; preds = %123
%131 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
%132 = load i32, i32* %6
%133 = call i32 @close(i32 %132)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i64 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i64, i64* }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"too few argument\0A\00"
@.str.1 = [19 x i8] c"too many argument\0A\00"
@.str.2 = [25 x i8] c"gethostbyname() failuer\0A\00"
@AF_INET = global i64 0
@.str.3 = [27 x i8] c"h_addrtype is not AF_INET\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.4 = [19 x i8] c"connect() failuer\0A\00"
@.str.5 = [48 x i8] c"GET / HTTP/1.1\0D\0AHOST: %s\0D\0AConnection: close\0D\0A\0D\0A\00"
@.str.6 = [16 x i8] c"send() failuer\0A\00"
@.str.7 = [3 x i8] c"%s\00"
@.str.8 = [16 x i8] c"recv() failuer\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [512 x i8]
%5 = alloca [1024 x i8]
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = icmp slt i32 %0, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = icmp ugt i32 %0, 3
br i1 %15, label %16, label %20
16: ; preds = %14
%17 = load i32, i32* @stderr
%18 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i32 @exit(i32 1)
unreachable
20: ; preds = %14
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = tail call %struct.hostent* @gethostbyname(i8* %22)
%24 = icmp eq %struct.hostent* %23, null
br i1 %24, label %25, label %29
25: ; preds = %20
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%28 = tail call i32 @exit(i32 1)
unreachable
29: ; preds = %20
%30 = getelementptr inbounds %struct.hostent, %struct.hostent* %23, i64 0, i32 0
%31 = load i64, i64* %30
%32 = load i64, i64* @AF_INET
%33 = icmp eq i64 %31, %32
br i1 %33, label %38, label %34
34: ; preds = %29
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%37 = tail call i32 @exit(i32 1)
unreachable
38: ; preds = %29
%39 = load i32, i32* @PF_INET
%40 = load i32, i32* @SOCK_STREAM
%41 = load i32, i32* @IPPROTO_TCP
%42 = tail call i32 @socket(i32 %39, i32 %40, i32 %41)
%43 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 16)
%44 = load i64, i64* @AF_INET
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i64 %44, i64* %45
%46 = call i32 @htons(i32 80)
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
store i32 %46, i32* %47
%48 = getelementptr inbounds %struct.hostent, %struct.hostent* %23, i64 0, i32 1
%49 = load i64*, i64** %48
%50 = load i64, i64* %49
%51 = inttoptr i64 %50 to i32*
%52 = load i32, i32* %51
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
store i32 %52, i32* %53
%54 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%55 = call i64 @connect(i32 %42, %struct.sockaddr* %54, i32 16)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %38
%58 = load i32, i32* @stderr
%59 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %38
%62 = icmp eq i32 %0, 2
br i1 %62, label %63, label %66
63: ; preds = %61
%64 = load i8*, i8** %21
%65 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %7, i32 512, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i8* %64)
br label %71
66: ; preds = %61
%67 = getelementptr inbounds i8*, i8** %1, i64 2
%68 = load i8*, i8** %67
%69 = load i8*, i8** %21
%70 = call i32 (i8*, i32, i8*, i8*, ...) @snprintf(i8* %7, i32 512, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.5, i64 0, i64 0), i8* %68, i8* %69)
br label %71
71: ; preds = %66, %63
%72 = call i32 @strlen(i8* %7)
%73 = call i32 @send(i32 %42, i8* %7, i32 %72, i32 0)
%74 = icmp eq i32 %73, %72
br i1 %74, label %75, label %78
75: ; preds = %71
%76 = call i32 @recv(i32 %42, i8* %8, i32 1024, i32 0)
%77 = icmp sgt i32 %76, 0
br i1 %77, label %82, label %89
78: ; preds = %71
%79 = load i32, i32* @stderr
%80 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %75, %82
%83 = phi i32 [ %87, %82 ], [ %76, %75 ]
%84 = zext i32 %83 to i64
%85 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 %84
store i8 0, i8* %85
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %8)
%87 = call i32 @recv(i32 %42, i8* %8, i32 1024, i32 0)
%88 = icmp sgt i32 %87, 0
br i1 %88, label %82, label %89
89: ; preds = %82, %75
%90 = phi i32 [ %76, %75 ], [ %87, %82 ]
%91 = icmp slt i32 %90, 0
br i1 %91, label %92, label %96
92: ; preds = %89
%93 = load i32, i32* @stderr
%94 = call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
%95 = call i32 @exit(i32 1)
unreachable
96: ; preds = %89
%97 = call i32 @putchar(i32 10)
%98 = call i32 @close(i32 %42)
ret i32 0
}