#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_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct in_addr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ *h_addr_list;
};
typedef int /*<<< orphan*/ host_address;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ display_result(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ http_get(int, char *, char *, char *, char *, char *);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ parse_proxy_param(char *, char **, int *, char **, char **);
int parse_url(char *, char **, char **);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  int client_connection;
  char *proxy_host, *proxy_user, *proxy_password;
  int proxy_port;
  char *host, *path;
  struct hostent *host_name;
  struct sockaddr_in host_address;
  int ind;
  if (argc < 2) {
    fprintf(stderr,
            "Usage: %s: [-p http://[username:password@]proxy-host:proxy-port]  "
            "      <URL>\n",
            argv[0]);
    return 1;
  }
  proxy_host = proxy_user = proxy_password = host = path = NULL;
  ind = 1;
  if (!strcmp("-p", argv[ind])) {
    if (!parse_proxy_param(argv[++ind], &proxy_host, &proxy_port, &proxy_user,
                           &proxy_password)) {
      fprintf(stderr, "Error - malformed proxy parameter '%s'.\n", argv[ind]);
      return 2;
    }
    ind++;
  }
  if (parse_url(argv[ind], &host, &path) == -1) {
    fprintf(stderr, "Error - malformed URL '%s'.\n", argv[1]);
    return 1;
  }
  if (proxy_host) {
    printf("Conntecting to host '%s'\n", proxy_host);
    host_name = gethostbyname(proxy_host);
  } else {
    printf("Connecting to host '%s'\n", host);
    host_name = gethostbyname(host);
  }
  if (!host_name) {
    perror("Error in name resolution");
    return 2;
  }
  client_connection = socket(PF_INET, SOCK_STREAM, 0);
  if (!client_connection) {
    perror("Unable to create local socket");
    return 3;
  }
  host_address.sin_family = AF_INET;
  host_address.sin_port = htons(proxy_host ? proxy_port : 80);
  memcpy(&host_address.sin_addr, host_name->h_addr_list[0],
         sizeof(struct in_addr));
  if (connect(client_connection, (struct sockaddr *)&host_address,
              sizeof(host_address)) == -1) {
    perror("Unable to connect to host");
    return 4;
  }
  printf("Retrieving document: '%s'\n", path);
  http_get(client_connection, path, host, proxy_host, proxy_user,
           proxy_password);
  display_result(client_connection);
  printf("Shutting down\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1218 <main+0x48>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdf9(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1498 <main+0x2c8>
movq   $0x0,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x1,-0x64(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdf5(%rip),%rdi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    12d0 <main+0x100>
mov    -0x10(%rbp),%rax
mov    -0x64(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,-0x64(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   10c0 <parse_proxy_param@plt>
cmp    $0x0,%eax
jne    12c7 <main+0xf7>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xd9c(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    1498 <main+0x2c8>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x64(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x48(%rbp),%rdx
call   10e0 <parse_url@plt>
cmp    $0xffffffff,%eax
jne    131b <main+0x14b>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd71(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1498 <main+0x2c8>
cmpq   $0x0,-0x20(%rbp)
je     134a <main+0x17a>
mov    -0x20(%rbp),%rsi
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <gethostbyname@plt>
mov    %rax,-0x50(%rbp)
jmp    1369 <main+0x199>
mov    -0x40(%rbp),%rsi
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1060 <gethostbyname@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    138c <main+0x1bc>
lea    0xd50(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    1498 <main+0x2c8>
mov    0x2c35(%rip),%rax
mov    (%rax),%edi
mov    0x2c34(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    13ca <main+0x1fa>
lea    0xd2b(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x3,-0x4(%rbp)
jmp    1498 <main+0x2c8>
mov    0x2c17(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     13ec <main+0x21c>
mov    -0x34(%rbp),%eax
mov    %eax,-0x68(%rbp)
jmp    13f9 <main+0x229>
mov    $0x50,%eax
mov    %eax,-0x68(%rbp)
jmp    13f9 <main+0x229>
mov    -0x68(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,-0x5c(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x50(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%esi
mov    $0x4,%edx
call   1080 <memcpy@plt>
mov    -0x14(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <connect@plt>
cmp    $0xffffffff,%eax
jne    144d <main+0x27d>
lea    0xcc6(%rip),%rdi
call   10b0 <perror@plt>
movl   $0x4,-0x4(%rbp)
jmp    1498 <main+0x2c8>
mov    -0x48(%rbp),%rsi
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
call   10a0 <http_get@plt>
mov    -0x14(%rbp),%edi
call   1090 <display_result@plt>
lea    0xcad(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1208 <main+0x28>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdfd(%rip),%rsi
jmp    12bc <main+0xdc>
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movq   $0x0,0x28(%rsp)
movq   $0x0,(%rsp)
mov    0x8(%rbx),%rbp
lea    0xe10(%rip),%rdi
mov    %rbp,%rsi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    1272 <main+0x92>
mov    0x10(%rbx),%rdi
mov    %rsp,%rsi
lea    0x1c(%rsp),%rdx
lea    0x28(%rsp),%rcx
lea    0x20(%rsp),%r8
call   10d0 <parse_proxy_param@plt>
test   %eax,%eax
je     13b8 <main+0x1d8>
mov    0x18(%rbx),%rbp
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%rdx
mov    %rbp,%rdi
mov    %r14,%rsi
call   10f0 <parse_url@plt>
cmp    $0xffffffff,%eax
je     12a8 <main+0xc8>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     12cb <main+0xeb>
lea    0xdfc(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%r14
jmp    12de <main+0xfe>
mov    0x2d29(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xdbf(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%ebx
jmp    13d6 <main+0x1f6>
mov    0x10(%rsp),%rsi
lea    0xddb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r14),%rdi
call   1070 <gethostbyname@plt>
test   %rax,%rax
je     13e1 <main+0x201>
mov    %rax,%rbx
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
mov    0x2cce(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
test   %eax,%eax
je     13ef <main+0x20f>
mov    %eax,%ebp
mov    0x2ccc(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x38(%rsp)
cmpq   $0x0,(%rsp)
mov    $0x50,%edi
je     1332 <main+0x152>
mov    0x1c(%rsp),%edi
call   1040 <htons@plt>
mov    %eax,0x34(%rsp)
mov    (%rbx),%rax
mov    (%rax),%esi
lea    0x30(%rsp),%r14
mov    $0x4,%ebx
mov    %r14,%rdi
mov    $0x4,%edx
call   1090 <memcpy@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   10e0 <connect@plt>
cmp    $0xffffffff,%eax
je     1402 <main+0x222>
mov    0x8(%rsp),%rsi
lea    0xda1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    (%rsp),%rcx
mov    0x28(%rsp),%r8
mov    0x20(%rsp),%r9
mov    %ebp,%edi
call   10b0 <http_get@plt>
mov    %ebp,%edi
call   10a0 <display_result@plt>
lea    0xd86(%rip),%rdi
call   1030 <puts@plt>
jmp    13d6 <main+0x1f6>
mov    0x2c19(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xc86(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x2,%ebx
mov    %ebx,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xce3(%rip),%rdi
call   10c0 <perror@plt>
jmp    13d1 <main+0x1f1>
lea    0xcee(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x3,%ebx
jmp    13d6 <main+0x1f6>
lea    0xcf9(%rip),%rdi
call   10c0 <perror@plt>
jmp    13d6 <main+0x1f6>

LLVM IR (-O0):
%struct.hostent = type { i32* }
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [79 x i8] c"Usage: %s: [-p http://[username:password@]proxy-host:proxy-port] <URL>\0A\00"
@.str.1 = [3 x i8] c"-p\00"
@.str.2 = [41 x i8] c"Error - malformed proxy parameter '%s'.\0A\00"
@.str.3 = [29 x i8] c"Error - malformed URL '%s'.\0A\00"
@.str.4 = [26 x i8] c"Conntecting to host '%s'\0A\00"
@.str.5 = [25 x i8] c"Connecting to host '%s'\0A\00"
@.str.6 = [25 x i8] c"Error in name resolution\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.7 = [30 x i8] c"Unable to create local socket\00"
@AF_INET = global i32 0
@.str.8 = [26 x i8] c"Unable to connect to host\00"
@.str.9 = [27 x i8] c"Retrieving document: '%s'\0A\00"
@.str.10 = [15 x i8] c"Shutting down\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca %struct.hostent*
%14 = alloca %struct.sockaddr_in
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0), i8* %22)
store i32 1, i32* %3
br label %130
24: ; preds = %2
store i8* null, i8** %12
store i8* null, i8** %11
store i8* null, i8** %9
store i8* null, i8** %8
store i8* null, i8** %7
store i32 1, i32* %15
%25 = load i8**, i8*** %5
%26 = load i32, i32* %15
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @strcmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %52, label %32
32: ; preds = %24
%33 = load i8**, i8*** %5
%34 = load i32, i32* %15
%35 = add nsw i32 %34, 1
store i32 %35, i32* %15
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8*, i8** %33, i64 %36
%38 = load i8*, i8** %37
%39 = call i32 @parse_proxy_param(i8* %38, i8** %7, i32* %10, i8** %8, i8** %9)
%40 = icmp ne i32 %39, 0
br i1 %40, label %49, label %41
41: ; preds = %32
%42 = load i32, i32* @stderr
%43 = load i8**, i8*** %5
%44 = load i32, i32* %15
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8*, i8** %43, i64 %45
%47 = load i8*, i8** %46
%48 = call i32 @fprintf(i32 %42, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %47)
store i32 2, i32* %3
br label %130
49: ; preds = %32
%50 = load i32, i32* %15
%51 = add nsw i32 %50, 1
store i32 %51, i32* %15
br label %52
52: ; preds = %49, %24
%53 = load i8**, i8*** %5
%54 = load i32, i32* %15
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8*, i8** %53, i64 %55
%57 = load i8*, i8** %56
%58 = call i32 @parse_url(i8* %57, i8** %11, i8** %12)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %66
60: ; preds = %52
%61 = load i32, i32* @stderr
%62 = load i8**, i8*** %5
%63 = getelementptr inbounds i8*, i8** %62, i64 1
%64 = load i8*, i8** %63
%65 = call i32 @fprintf(i32 %61, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %64)
store i32 1, i32* %3
br label %130
66: ; preds = %52
%67 = load i8*, i8** %7
%68 = icmp ne i8* %67, null
br i1 %68, label %69, label %74
69: ; preds = %66
%70 = load i8*, i8** %7
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %70)
%72 = load i8*, i8** %7
%73 = call %struct.hostent* @gethostbyname(i8* %72)
store %struct.hostent* %73, %struct.hostent** %13
br label %79
74: ; preds = %66
%75 = load i8*, i8** %11
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %75)
%77 = load i8*, i8** %11
%78 = call %struct.hostent* @gethostbyname(i8* %77)
store %struct.hostent* %78, %struct.hostent** %13
br label %79
79: ; preds = %74, %69
%80 = load %struct.hostent*, %struct.hostent** %13
%81 = icmp ne %struct.hostent* %80, null
br i1 %81, label %84, label %82
82: ; preds = %79
%83 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
store i32 2, i32* %3
br label %130
84: ; preds = %79
%85 = load i32, i32* @PF_INET
%86 = load i32, i32* @SOCK_STREAM
%87 = call i32 @socket(i32 %85, i32 %86, i32 0)
store i32 %87, i32* %6
%88 = load i32, i32* %6
%89 = icmp ne i32 %88, 0
br i1 %89, label %92, label %90
90: ; preds = %84
%91 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
store i32 3, i32* %3
br label %130
92: ; preds = %84
%93 = load i32, i32* @AF_INET
%94 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 2
store i32 %93, i32* %94
%95 = load i8*, i8** %7
%96 = icmp ne i8* %95, null
br i1 %96, label %97, label %99
97: ; preds = %92
%98 = load i32, i32* %10
br label %100
99: ; preds = %92
br label %100
100: ; preds = %99, %97
%101 = phi i32 [ %98, %97 ], [ 80, %99 ]
%102 = call i32 @htons(i32 %101)
%103 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 1
store i32 %102, i32* %103
%104 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 0
%105 = load %struct.hostent*, %struct.hostent** %13
%106 = getelementptr inbounds %struct.hostent, %struct.hostent* %105, i32 0, i32 0
%107 = load i32*, i32** %106
%108 = getelementptr inbounds i32, i32* %107, i64 0
%109 = load i32, i32* %108
%110 = call i32 @memcpy(i32* %104, i32 %109, i32 4)
%111 = load i32, i32* %6
%112 = bitcast %struct.sockaddr_in* %14 to %struct.sockaddr*
%113 = call i32 @connect(i32 %111, %struct.sockaddr* %112, i32 12)
%114 = icmp eq i32 %113, -1
br i1 %114, label %115, label %117
115: ; preds = %100
%116 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
store i32 4, i32* %3
br label %130
117: ; preds = %100
%118 = load i8*, i8** %12
%119 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i8* %118)
%120 = load i32, i32* %6
%121 = load i8*, i8** %12
%122 = load i8*, i8** %11
%123 = load i8*, i8** %7
%124 = load i8*, i8** %8
%125 = load i8*, i8** %9
%126 = call i32 @http_get(i32 %120, i8* %121, i8* %122, i8* %123, i8* %124, i8* %125)
%127 = load i32, i32* %6
%128 = call i32 @display_result(i32 %127)
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %3
br label %130
130: ; preds = %117, %115, %90, %82, %60, %41, %18
%131 = load i32, i32* %3
ret i32 %131
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.hostent = type { i32* }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [79 x i8] c"Usage: %s: [-p http://[username:password@]proxy-host:proxy-port] <URL>\0A\00"
@.str.1 = [3 x i8] c"-p\00"
@.str.2 = [41 x i8] c"Error - malformed proxy parameter '%s'.\0A\00"
@.str.3 = [29 x i8] c"Error - malformed URL '%s'.\0A\00"
@.str.4 = [26 x i8] c"Conntecting to host '%s'\0A\00"
@.str.5 = [25 x i8] c"Connecting to host '%s'\0A\00"
@.str.6 = [25 x i8] c"Error in name resolution\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.7 = [30 x i8] c"Unable to create local socket\00"
@AF_INET = global i32 0
@.str.8 = [26 x i8] c"Unable to connect to host\00"
@.str.9 = [27 x i8] c"Retrieving document: '%s'\0A\00"
@str = [14 x i8] c"Shutting down\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.sockaddr_in
%10 = bitcast i8** %3 to i8*
%11 = bitcast i8** %4 to i8*
%12 = bitcast i8** %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i8** %7 to i8*
%15 = bitcast i8** %8 to i8*
%16 = bitcast %struct.sockaddr_in* %9 to i8*
%17 = icmp slt i32 %0, 2
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8*, i8** %1
%21 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %99
22: ; preds = %2
store i8* null, i8** %8
store i8* null, i8** %7
store i8* null, i8** %5
store i8* null, i8** %4
store i8* null, i8** %3
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = tail call i32 @strcmp(i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %24)
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %39
27: ; preds = %22
%28 = getelementptr inbounds i8*, i8** %1, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @parse_proxy_param(i8* %29, i8** %3, i32* %6, i8** %4, i8** %5)
%31 = icmp eq i32 %30, 0
br i1 %31, label %35, label %32
32: ; preds = %27
%33 = getelementptr inbounds i8*, i8** %1, i64 3
%34 = load i8*, i8** %33
br label %39
35: ; preds = %27
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %28
%38 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %37)
br label %99
39: ; preds = %32, %22
%40 = phi i8* [ %24, %22 ], [ %34, %32 ]
%41 = call i32 @parse_url(i8* %40, i8** %7, i8** %8)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %47
43: ; preds = %39
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %23
%46 = call i32 @fprintf(i32 %44, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i8* %45)
br label %99
47: ; preds = %39
%48 = load i8*, i8** %3
%49 = icmp eq i8* %48, null
br i1 %49, label %52, label %50
50: ; preds = %47
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i8* %48)
br label %55
52: ; preds = %47
%53 = load i8*, i8** %7
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %53)
br label %55
55: ; preds = %52, %50
%56 = phi i8** [ %7, %52 ], [ %3, %50 ]
%57 = load i8*, i8** %56
%58 = call %struct.hostent* @gethostbyname(i8* %57)
%59 = icmp eq %struct.hostent* %58, null
br i1 %59, label %60, label %62
60: ; preds = %55
%61 = call i32 @perror(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0))
br label %99
62: ; preds = %55
%63 = load i32, i32* @PF_INET
%64 = load i32, i32* @SOCK_STREAM
%65 = call i32 @socket(i32 %63, i32 %64, i32 0)
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %62
%68 = call i32 @perror(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0))
br label %99
69: ; preds = %62
%70 = load i32, i32* @AF_INET
%71 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i64 0, i32 2
store i32 %70, i32* %71
%72 = load i8*, i8** %3
%73 = icmp eq i8* %72, null
%74 = load i32, i32* %6
%75 = select i1 %73, i32 80, i32 %74
%76 = call i32 @htons(i32 %75)
%77 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i64 0, i32 1
store i32 %76, i32* %77
%78 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i64 0, i32 0
%79 = getelementptr inbounds %struct.hostent, %struct.hostent* %58, i64 0, i32 0
%80 = load i32*, i32** %79
%81 = load i32, i32* %80
%82 = call i32 @memcpy(i32* %78, i32 %81, i32 4)
%83 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%84 = call i32 @connect(i32 %65, %struct.sockaddr* %83, i32 12)
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %88
86: ; preds = %69
%87 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.8, i64 0, i64 0))
br label %99
88: ; preds = %69
%89 = load i8*, i8** %8
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i8* %89)
%91 = load i8*, i8** %8
%92 = load i8*, i8** %7
%93 = load i8*, i8** %3
%94 = load i8*, i8** %4
%95 = load i8*, i8** %5
%96 = call i32 @http_get(i32 %65, i8* %91, i8* %92, i8* %93, i8* %94, i8* %95)
%97 = call i32 @display_result(i32 %65)
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %99
99: ; preds = %88, %86, %67, %60, %43, %35, %18
%100 = phi i32 [ 1, %18 ], [ 1, %43 ], [ 4, %86 ], [ 0, %88 ], [ 3, %67 ], [ 2, %60 ], [ 2, %35 ]
ret i32 %100
}