#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 in_addr {
  int dummy;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_zero;
  struct in_addr sin_addr;
  void *sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ recvbuf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ MSG_WAITALL;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ bzero(int /*<<< orphan*/ *, int);
char *calloc(int, int);
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
struct hostent *gethostbyname(char *);
void *htons(int);
char *inet_convert(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int inet_send(char *sendbuf) {
  extern char *proxyaddr;
  extern char *google_server;
  extern char recvbuf[65000];
  extern char mid_query[1024];
  extern char out_query[1024];
  extern int proxyport;
  extern int cooked, vflag, pflag, dflag;
  char *get_line;
  int sock;
  struct sockaddr_in http;
  extern struct hostent *he;
  if ((get_line = calloc(1024, sizeof(char))) == NULL) {
    printf("Error allocating memory for get_line. Aborting.\n");
    exit(1);
  }
  if (cooked)
    strncpy(get_line, out_query, 1024);
  else {
    strncpy(out_query, inet_convert(sendbuf, dflag), 1024);
    if (!pflag)
      sprintf(get_line, "GET /search?%s HTTP/1.0\n\n", out_query);
    else
      sprintf(get_line, "GET http://%s/search?%s HTTP/1.0\n\n", google_server,
              out_query);
  }
  if (vflag)
    printf("(verbose) GET Line => %s\n", get_line);
  if (he == NULL) {
    printf("doing lookup of %s...\n", google_server);
    if (pflag) {
      if ((he = gethostbyname(proxyaddr)) == NULL) {
        perror("gethostbyname");
        exit(1);
      }
    } else {
      if ((he = gethostbyname(google_server)) == NULL) {
        printf("Host not found: %s\n", google_server);
        exit(1);
      }
    }
  }
  if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
    perror("socket");
    exit(1);
  }
  http.sin_family = AF_INET;
  if (pflag)
    http.sin_port = htons(proxyport);
  else
    http.sin_port = htons(80);
  http.sin_addr = *((struct in_addr *)he->h_addr);
  bzero(&(http.sin_zero), 8);
  if (connect(sock, (struct sockaddr *)&http, sizeof(struct sockaddr)) == -1) {
    close(sock);
    perror("connect");
    return (1);
  }
  send(sock, get_line, strlen(get_line), 0);
  recv(sock, recvbuf, sizeof(recvbuf), MSG_WAITALL);
  close(sock);
  return (0);
}


x86 assembly (clang, -O0):
<inet_send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x400,%edi
mov    $0x1,%esi
call   10b0 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1241 <inet_send+0x41>
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x2d88(%rip),%rax
cmpl   $0x0,(%rax)
je     126b <inet_send+0x6b>
mov    -0x18(%rbp),%rdi
mov    0x2d64(%rip),%rsi
mov    $0x400,%edx
call   1050 <strncpy@plt>
jmp    12e7 <inet_send+0xe7>
mov    -0x10(%rbp),%rdi
mov    0x2d52(%rip),%rax
mov    (%rax),%esi
call   1030 <inet_convert@plt>
mov    %rax,%rsi
mov    0x2d39(%rip),%rdi
mov    $0x400,%edx
call   1050 <strncpy@plt>
mov    0x2d08(%rip),%rax
cmpl   $0x0,(%rax)
jne    12bf <inet_send+0xbf>
mov    -0x18(%rbp),%rdi
lea    0xd85(%rip),%rsi
mov    0x2d0d(%rip),%rdx
mov    $0x0,%al
call   10f0 <sprintf@plt>
jmp    12e2 <inet_send+0xe2>
mov    -0x18(%rbp),%rdi
mov    0x2cb6(%rip),%rax
mov    (%rax),%rdx
lea    0xd77(%rip),%rsi
mov    0x2ce5(%rip),%rcx
mov    $0x0,%al
call   10f0 <sprintf@plt>
jmp    12e7 <inet_send+0xe7>
mov    0x2cca(%rip),%rax
cmpl   $0x0,(%rax)
je     1309 <inet_send+0x109>
mov    -0x18(%rbp),%rsi
lea    0xd6c(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    0x2cd8(%rip),%rax
cmpq   $0x0,(%rax)
jne    13cf <inet_send+0x1cf>
mov    0x2c5f(%rip),%rax
mov    (%rax),%rsi
lea    0xd5d(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    0x2c67(%rip),%rax
cmpl   $0x0,(%rax)
je     1380 <inet_send+0x180>
mov    0x2c2f(%rip),%rax
mov    (%rax),%rdi
call   10c0 <gethostbyname@plt>
mov    0x2c90(%rip),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    137b <inet_send+0x17b>
lea    0xd33(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    13ca <inet_send+0x1ca>
mov    0x2bf9(%rip),%rax
mov    (%rax),%rdi
call   10c0 <gethostbyname@plt>
mov    0x2c52(%rip),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    13c5 <inet_send+0x1c5>
mov    0x2bd6(%rip),%rax
mov    (%rax),%rsi
lea    0xcf9(%rip),%rdi
mov    $0x0,%al
call   1090 <printf@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
jmp    13ca <inet_send+0x1ca>
jmp    13cf <inet_send+0x1cf>
mov    0x2c02(%rip),%rax
mov    (%rax),%edi
mov    0x2bc9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0xffffffff,%eax
jne    140a <inet_send+0x20a>
lea    0xcc6(%rip),%rdi
call   10d0 <perror@plt>
mov    $0x1,%edi
call   1100 <exit@plt>
mov    0x2bc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2b83(%rip),%rax
cmpl   $0x0,(%rax)
je     143d <inet_send+0x23d>
mov    0x2b6b(%rip),%rax
mov    (%rax),%edi
call   1070 <htons@plt>
mov    %rax,-0x30(%rbp)
jmp    144b <inet_send+0x24b>
mov    $0x50,%edi
call   1070 <htons@plt>
mov    %rax,-0x30(%rbp)
mov    0x2b96(%rip),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
lea    -0x38(%rbp),%rdi
mov    $0x8,%esi
call   10e0 <bzero@plt>
mov    -0x1c(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x4,%edx
call   1110 <connect@plt>
cmp    $0xffffffff,%eax
jne    14a5 <inet_send+0x2a5>
mov    -0x1c(%rbp),%edi
call   10a0 <close@plt>
lea    0xc34(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    14f8 <inet_send+0x2f8>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x44(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    -0x1c(%rbp),%edi
mov    0x2ab2(%rip),%rax
mov    (%rax),%ecx
mov    0x2b01(%rip),%rsi
mov    $0xfde8,%edx
call   1040 <recv@plt>
mov    -0x1c(%rbp),%edi
call   10a0 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet_send>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    $0x400,%edi
mov    $0x1,%esi
call   10c0 <calloc@plt>
test   %rax,%rax
je     142e <inet_send+0x21e>
mov    %rax,%r14
mov    0x2d91(%rip),%rax
cmpl   $0x0,(%rax)
je     125a <inet_send+0x4a>
mov    0x2d75(%rip),%rsi
mov    %r14,%rdi
mov    $0x400,%edx
call   1050 <strncpy@plt>
jmp    12c7 <inet_send+0xb7>
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <inet_convert@plt>
mov    0x2d4e(%rip),%rdi
mov    %rax,%rsi
mov    $0x400,%edx
call   1050 <strncpy@plt>
mov    0x2d1a(%rip),%rax
cmpl   $0x0,(%rax)
je     12af <inet_send+0x9f>
mov    0x2cee(%rip),%rax
mov    (%rax),%rdx
lea    0xd7e(%rip),%rsi
mov    0x2d1d(%rip),%rcx
mov    %r14,%rdi
xor    %eax,%eax
call   1100 <sprintf@plt>
jmp    12c7 <inet_send+0xb7>
lea    0xd4a(%rip),%rsi
mov    0x2d03(%rip),%rdx
mov    %r14,%rdi
xor    %eax,%eax
call   1100 <sprintf@plt>
mov    0x2cea(%rip),%rax
cmpl   $0x0,(%rax)
je     12e4 <inet_send+0xd4>
lea    0xd63(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x2cfd(%rip),%r15
cmpq   $0x0,(%r15)
jne    134e <inet_send+0x13e>
mov    0x2c88(%rip),%rbp
mov    0x0(%rbp),%rsi
lea    0xd54(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    0x2c8f(%rip),%rax
cmpl   $0x0,(%rax)
je     1339 <inet_send+0x129>
mov    0x2c5b(%rip),%rax
mov    (%rax),%rdi
call   10d0 <gethostbyname@plt>
mov    %rax,(%r15)
test   %rax,%rax
jne    134e <inet_send+0x13e>
lea    0xd3a(%rip),%rdi
jmp    144b <inet_send+0x23b>
mov    0x0(%rbp),%rdi
call   10d0 <gethostbyname@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     145a <inet_send+0x24a>
mov    0x2c83(%rip),%rbx
mov    (%rbx),%edi
mov    0x2c4a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
je     1444 <inet_send+0x234>
mov    %eax,%ebp
mov    (%rbx),%eax
mov    %eax,0x10(%rsp)
mov    0x2c21(%rip),%rax
cmpl   $0x0,(%rax)
mov    $0x50,%edi
je     1392 <inet_send+0x182>
mov    0x2c08(%rip),%rax
mov    (%rax),%edi
call   1080 <htons@plt>
mov    %rax,0x8(%rsp)
mov    (%r15),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x8,%esi
call   10f0 <bzero@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1120 <connect@plt>
cmp    $0xffffffff,%eax
je     1414 <inet_send+0x204>
mov    %r14,%rdi
call   1070 <strlen@plt>
xor    %ebx,%ebx
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
mov    0x2b9d(%rip),%rax
mov    (%rax),%ecx
mov    0x2bec(%rip),%rsi
mov    %ebp,%edi
mov    $0xfde8,%edx
call   1040 <recv@plt>
mov    %ebp,%edi
call   10b0 <close@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %ebp,%edi
call   10b0 <close@plt>
lea    0xc75(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%ebx
jmp    1407 <inet_send+0x1f7>
lea    0xc6a(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xc45(%rip),%rdi
call   10e0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    0x0(%rbp),%rsi
lea    0xc17(%rip),%rdi
xor    %eax,%eax
call   10a0 <printf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.hostent = type { i64 }
%struct.sockaddr_in = type { i32, %struct.in_addr, i8*, i32 }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [49 x i8] c"Error allocating memory for get_line. Aborting.\0A\00"
@cooked = external global i32
@out_query = external global [1024 x i8]
@dflag = external global i32
@pflag = external global i32
@.str.1 = [26 x i8] c"GET /search?%s HTTP/1.0\0A\0A\00"
@.str.2 = [35 x i8] c"GET http://%s/search?%s HTTP/1.0\0A\0A\00"
@google_server = external global i8*
@vflag = external global i32
@.str.3 = [26 x i8] c"(verbose) GET Line => %s\0A\00"
@he = external global %struct.hostent*
@.str.4 = [23 x i8] c"doing lookup of %s...\0A\00"
@proxyaddr = external global i8*
@.str.5 = [14 x i8] c"gethostbyname\00"
@.str.6 = [20 x i8] c"Host not found: %s\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.7 = [7 x i8] c"socket\00"
@proxyport = external global i32
@.str.8 = [8 x i8] c"connect\00"
@recvbuf = external global [65000 x i8]
@MSG_WAITALL = global i32 0
define i32 @inet_send(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.sockaddr_in
store i8* %0, i8** %3
%7 = call i8* @calloc(i32 1024, i32 1)
store i8* %7, i8** %4
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %1
%13 = load i32, i32* @cooked
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i8*, i8** %4
%17 = call i32 @strncpy(i8* %16, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @out_query, i64 0, i64 0), i32 1024)
br label %33
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = load i32, i32* @dflag
%21 = call i8* @inet_convert(i8* %19, i32 %20)
%22 = call i32 @strncpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @out_query, i64 0, i64 0), i8* %21, i32 1024)
%23 = load i32, i32* @pflag
%24 = icmp ne i32 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @out_query, i64 0, i64 0))
br label %32
28: ; preds = %18
%29 = load i8*, i8** %4
%30 = load i8*, i8** @google_server
%31 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %29, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %30, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @out_query, i64 0, i64 0))
br label %32
32: ; preds = %28, %25
br label %33
33: ; preds = %32, %15
%34 = load i32, i32* @vflag
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i8*, i8** %4
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %36, %33
%40 = load %struct.hostent*, %struct.hostent** @he
%41 = icmp eq %struct.hostent* %40, null
br i1 %41, label %42, label %65
42: ; preds = %39
%43 = load i8*, i8** @google_server
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %43)
%45 = load i32, i32* @pflag
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %55
47: ; preds = %42
%48 = load i8*, i8** @proxyaddr
%49 = call %struct.hostent* @gethostbyname(i8* %48)
store %struct.hostent* %49, %struct.hostent** @he
%50 = icmp eq %struct.hostent* %49, null
br i1 %50, label %51, label %54
51: ; preds = %47
%52 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %47
br label %64
55: ; preds = %42
%56 = load i8*, i8** @google_server
%57 = call %struct.hostent* @gethostbyname(i8* %56)
store %struct.hostent* %57, %struct.hostent** @he
%58 = icmp eq %struct.hostent* %57, null
br i1 %58, label %59, label %63
59: ; preds = %55
%60 = load i8*, i8** @google_server
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %60)
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %55
br label %64
64: ; preds = %63, %54
br label %65
65: ; preds = %64, %39
%66 = load i32, i32* @AF_INET
%67 = load i32, i32* @SOCK_STREAM
%68 = call i32 @socket(i32 %66, i32 %67, i32 0)
store i32 %68, i32* %5
%69 = icmp eq i32 %68, -1
br i1 %69, label %70, label %73
70: ; preds = %65
%71 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %65
%74 = load i32, i32* @AF_INET
%75 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 3
store i32 %74, i32* %75
%76 = load i32, i32* @pflag
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %82
78: ; preds = %73
%79 = load i32, i32* @proxyport
%80 = call i8* @htons(i32 %79)
%81 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i8* %80, i8** %81
br label %85
82: ; preds = %73
%83 = call i8* @htons(i32 80)
%84 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i8* %83, i8** %84
br label %85
85: ; preds = %82, %78
%86 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%87 = load %struct.hostent*, %struct.hostent** @he
%88 = getelementptr inbounds %struct.hostent, %struct.hostent* %87, i32 0, i32 0
%89 = load i64, i64* %88
%90 = inttoptr i64 %89 to %struct.in_addr*
%91 = bitcast %struct.in_addr* %86 to i8*
%92 = bitcast %struct.in_addr* %90 to i8*
%93 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%94 = call i32 @bzero(i32* %93, i32 8)
%95 = load i32, i32* %5
%96 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%97 = call i32 @connect(i32 %95, %struct.sockaddr* %96, i32 4)
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %103
99: ; preds = %85
%100 = load i32, i32* %5
%101 = call i32 @close(i32 %100)
%102 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
store i32 1, i32* %2
br label %114
103: ; preds = %85
%104 = load i32, i32* %5
%105 = load i8*, i8** %4
%106 = load i8*, i8** %4
%107 = call i32 @strlen(i8* %106)
%108 = call i32 @send(i32 %104, i8* %105, i32 %107, i32 0)
%109 = load i32, i32* %5
%110 = load i32, i32* @MSG_WAITALL
%111 = call i32 @recv(i32 %109, i8* getelementptr inbounds ([65000 x i8], [65000 x i8]* @recvbuf, i64 0, i64 0), i32 65000, i32 %110)
%112 = load i32, i32* %5
%113 = call i32 @close(i32 %112)
store i32 0, i32* %2
br label %114
114: ; preds = %103, %99
%115 = load i32, i32* %2
ret i32 %115
}

LLVM IR (-O2):
%struct.hostent = type { i64 }
%struct.sockaddr_in = type { i32, %struct.in_addr, i8*, i32 }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@cooked = external global i32
@out_query = external global [1024 x i8]
@dflag = external global i32
@pflag = external global i32
@.str.1 = [26 x i8] c"GET /search?%s HTTP/1.0\0A\0A\00"
@.str.2 = [35 x i8] c"GET http://%s/search?%s HTTP/1.0\0A\0A\00"
@google_server = external global i8*
@vflag = external global i32
@.str.3 = [26 x i8] c"(verbose) GET Line => %s\0A\00"
@he = external global %struct.hostent*
@.str.4 = [23 x i8] c"doing lookup of %s...\0A\00"
@proxyaddr = external global i8*
@.str.5 = [14 x i8] c"gethostbyname\00"
@.str.6 = [20 x i8] c"Host not found: %s\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.7 = [7 x i8] c"socket\00"
@proxyport = external global i32
@.str.8 = [8 x i8] c"connect\00"
@recvbuf = external global [65000 x i8]
@MSG_WAITALL = global i32 0
@str = [48 x i8] c"Error allocating memory for get_line. Aborting.\00"
define i32 @inet_send(i8* %0) {
%2 = alloca %struct.sockaddr_in
%3 = bitcast %struct.sockaddr_in* %2 to i8*
%4 = tail call dereferenceable_or_null(1024) i8* @calloc(i32 1024, i32 1)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %1
%10 = load i32, i32* @cooked
%11 = icmp eq i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call i32 @strncpy(i8* %4, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @out_query, i64 0, i64 0), i32 1024)
br label %25
14: ; preds = %9
%15 = load i32, i32* @dflag
%16 = tail call i8* @inet_convert(i8* %0, i32 %15)
%17 = tail call i32 @strncpy(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @out_query, i64 0, i64 0), i8* %16, i32 1024)
%18 = load i32, i32* @pflag
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %14
%21 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @out_query, i64 0, i64 0))
br label %25
22: ; preds = %14
%23 = load i8*, i8** @google_server
%24 = tail call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %23, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @out_query, i64 0, i64 0))
br label %25
25: ; preds = %20, %22, %12
%26 = load i32, i32* @vflag
%27 = icmp eq i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %25
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %30
30: ; preds = %28, %25
%31 = load %struct.hostent*, %struct.hostent** @he
%32 = icmp eq %struct.hostent* %31, null
br i1 %32, label %33, label %53
33: ; preds = %30
%34 = load i8*, i8** @google_server
%35 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @pflag
%37 = icmp eq i32 %36, 0
br i1 %37, label %45, label %38
38: ; preds = %33
%39 = load i8*, i8** @proxyaddr
%40 = tail call %struct.hostent* @gethostbyname(i8* %39)
store %struct.hostent* %40, %struct.hostent** @he
%41 = icmp eq %struct.hostent* %40, null
br i1 %41, label %42, label %53
42: ; preds = %38
%43 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
%44 = tail call i32 @exit(i32 1)
unreachable
45: ; preds = %33
%46 = load i8*, i8** @google_server
%47 = tail call %struct.hostent* @gethostbyname(i8* %46)
store %struct.hostent* %47, %struct.hostent** @he
%48 = icmp eq %struct.hostent* %47, null
br i1 %48, label %49, label %53
49: ; preds = %45
%50 = load i8*, i8** @google_server
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i8* %50)
%52 = tail call i32 @exit(i32 1)
unreachable
53: ; preds = %38, %45, %30
%54 = load i32, i32* @AF_INET
%55 = load i32, i32* @SOCK_STREAM
%56 = tail call i32 @socket(i32 %54, i32 %55, i32 0)
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %61
58: ; preds = %53
%59 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
%60 = tail call i32 @exit(i32 1)
unreachable
61: ; preds = %53
%62 = load i32, i32* @AF_INET
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 3
store i32 %62, i32* %63
%64 = load i32, i32* @pflag
%65 = icmp eq i32 %64, 0
%66 = load i32, i32* @proxyport
%67 = select i1 %65, i32 80, i32 %66
%68 = tail call i8* @htons(i32 %67)
%69 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 2
store i8* %68, i8** %69
%70 = load %struct.hostent*, %struct.hostent** @he
%71 = getelementptr inbounds %struct.hostent, %struct.hostent* %70, i64 0, i32 0
%72 = load i64, i64* %71
%73 = inttoptr i64 %72 to i32*
%74 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1, i32 0
%75 = load i32, i32* %73
store i32 %75, i32* %74
%76 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
%77 = call i32 @bzero(i32* %76, i32 8)
%78 = bitcast %struct.sockaddr_in* %2 to %struct.sockaddr*
%79 = call i32 @connect(i32 %56, %struct.sockaddr* %78, i32 4)
%80 = icmp eq i32 %79, -1
br i1 %80, label %81, label %84
81: ; preds = %61
%82 = call i32 @close(i32 %56)
%83 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %90
84: ; preds = %61
%85 = call i32 @strlen(i8* %4)
%86 = call i32 @send(i32 %56, i8* %4, i32 %85, i32 0)
%87 = load i32, i32* @MSG_WAITALL
%88 = call i32 @recv(i32 %56, i8* getelementptr inbounds ([65000 x i8], [65000 x i8]* @recvbuf, i64 0, i64 0), i32 65000, i32 %87)
%89 = call i32 @close(i32 %56)
br label %90
90: ; preds = %84, %81
%91 = phi i32 [ 1, %81 ], [ 0, %84 ]
ret i32 %91
}