#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_family;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  int /*<<< orphan*/ h_addr;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SHUT_RDWR;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ TCP_NODELAY;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ debugMsg(char *);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
char *malloc(int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int recv(int, char *, int, int /*<<< orphan*/);
scalar_t__ send(int, char *, int, int /*<<< orphan*/);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char const *, int);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int strlen(char *);
char *httpGetPost(char *host, char *path, int port, char *method) {
  debugMsg("httpGetPost() ...");
  struct hostent *hp;
  if ((hp = gethostbyname(host)) == NULL) {
    debugMsg("httpGetPost() ... gethostbyname() ... connection failed ....");
    return NULL;
  }
  debugMsg("httpGetPost() ... gethostbyname() ... ok ....");
  struct sockaddr_in addr;
  memcpy(&addr.sin_addr, hp->h_addr, hp->h_length);
  addr.sin_port = htons(port);
  addr.sin_family = AF_INET;
  int sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  int on = 1;
  if (setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&on,
                 sizeof(int)) == -1) {
    debugMsg("httpGetPost() ... setsockopt() ... fail ...");
    return NULL;
  }
  debugMsg("httpGetPost() ... setsockopt() ... ok ...");
  if (sock == -1) {
    debugMsg("httpGetPost() ... socket() ... fail ....");
    return NULL;
  }
  debugMsg("httpGetPost() ... socket() ... ok ....");
  if (connect(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) ==
      -1) {
    debugMsg("httpGetPost() ... connect() ... fail ....");
    return NULL;
  }
  debugMsg("httpGetPost() ... connect() ... ok ....");
  char http_header_val[512];
  sprintf(http_header_val,
          "%s %s HTTP/1.1\r\nHost: %s\r\nUserAgent: Linux Br/1.0.0\r\n\r\n",
          method, path, host);
  if (send(sock, http_header_val, strlen(http_header_val), 0) < 0) {
    debugMsg("httpGetPost() ... send() ... fail ....");
    return NULL;
  }
  debugMsg("httpGetPost() ... send() ... ok ....");
  char server_reply[102400];
  int recv_size;
  if ((recv_size = recv(sock, server_reply, 102400, 0)) == -1) {
    debugMsg("httpGetPost() ... recv() ... fail ....");
    return NULL;
  }
  debugMsg("httpGetPost() ... recv() ... ok ....");
  server_reply[recv_size] = '\0';
  debugMsg("httpGetPost() ... malloc() ....");
  char *ret_val = malloc(sizeof(*ret_val) * strlen(server_reply));
  debugMsg("httpGetPost() ... malloc() .... ok ...");
  sprintf(ret_val, "%s", (char *)server_reply);
  debugMsg("httpGetPost() ... ok ...");
  shutdown(sock, SHUT_RDWR);
  close(sock);
  return ret_val;
}


x86 assembly (clang, -O0):
<httpGetPost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x19270,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
lea    0xdff(%rip),%rdi
call   10a0 <debugMsg@plt>
mov    -0x10(%rbp),%rdi
call   10b0 <gethostbyname@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    1236 <httpGetPost+0x56>
lea    0xdee(%rip),%rdi
call   10a0 <debugMsg@plt>
movq   $0x0,-0x8(%rbp)
jmp    14c3 <httpGetPost+0x2e3>
lea    0xe12(%rip),%rdi
call   10a0 <debugMsg@plt>
lea    -0x40(%rbp),%rdi
add    $0x8,%rdi
mov    -0x30(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x30(%rbp),%rax
mov    (%rax),%edx
call   10c0 <memcpy@plt>
mov    -0x1c(%rbp),%edi
call   1070 <htons@plt>
mov    %eax,-0x3c(%rbp)
mov    0x2d6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    0x2d3e(%rip),%rax
mov    (%rax),%edi
mov    0x2d3d(%rip),%rax
mov    (%rax),%esi
mov    0x2d44(%rip),%rax
mov    (%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0x44(%rbp)
movl   $0x1,-0x48(%rbp)
mov    -0x44(%rbp),%edi
mov    0x2d29(%rip),%rax
mov    (%rax),%esi
mov    0x2d30(%rip),%rax
mov    (%rax),%edx
lea    -0x48(%rbp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    12e3 <httpGetPost+0x103>
lea    0xdac(%rip),%rdi
call   10a0 <debugMsg@plt>
movq   $0x0,-0x8(%rbp)
jmp    14c3 <httpGetPost+0x2e3>
lea    0xdbf(%rip),%rdi
call   10a0 <debugMsg@plt>
cmpl   $0xffffffff,-0x44(%rbp)
jne    1312 <httpGetPost+0x132>
lea    0xdd3(%rip),%rdi
call   10a0 <debugMsg@plt>
movq   $0x0,-0x8(%rbp)
jmp    14c3 <httpGetPost+0x2e3>
lea    0xde3(%rip),%rdi
call   10a0 <debugMsg@plt>
mov    -0x44(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1351 <httpGetPost+0x171>
lea    0xde4(%rip),%rdi
call   10a0 <debugMsg@plt>
movq   $0x0,-0x8(%rbp)
jmp    14c3 <httpGetPost+0x2e3>
lea    0xdf5(%rip),%rdi
call   10a0 <debugMsg@plt>
lea    -0x250(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x1926c(%rbp)
lea    -0x250(%rbp),%rax
mov    %rax,-0x19268(%rbp)
lea    -0x250(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x1926c(%rbp),%edi
mov    -0x19268(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0x0,%rax
jge    13da <httpGetPost+0x1fa>
lea    0xde5(%rip),%rdi
call   10a0 <debugMsg@plt>
movq   $0x0,-0x8(%rbp)
jmp    14c3 <httpGetPost+0x2e3>
lea    0xdf3(%rip),%rdi
call   10a0 <debugMsg@plt>
mov    -0x44(%rbp),%edi
lea    -0x19250(%rbp),%rsi
mov    $0x19000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x19254(%rbp)
cmp    $0xffffffff,%eax
jne    1424 <httpGetPost+0x244>
lea    0xde7(%rip),%rdi
call   10a0 <debugMsg@plt>
movq   $0x0,-0x8(%rbp)
jmp    14c3 <httpGetPost+0x2e3>
lea    0xdf5(%rip),%rdi
call   10a0 <debugMsg@plt>
movslq -0x19254(%rbp),%rax
movb   $0x0,-0x19250(%rbp,%rax,1)
lea    0xdff(%rip),%rdi
call   10a0 <debugMsg@plt>
lea    -0x19250(%rbp),%rdi
call   1060 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x19260(%rbp)
lea    0xdf3(%rip),%rdi
call   10a0 <debugMsg@plt>
mov    -0x19260(%rbp),%rdi
lea    -0x19250(%rbp),%rdx
lea    0xe00(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
lea    0xdf5(%rip),%rdi
call   10a0 <debugMsg@plt>
mov    -0x44(%rbp),%edi
mov    0x2b47(%rip),%rax
mov    (%rax),%esi
call   1050 <shutdown@plt>
mov    -0x44(%rbp),%edi
call   1090 <close@plt>
mov    -0x19260(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x19270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpGetPost>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x19220,%rsp
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r12
lea    0xdef(%rip),%rdi
call   10b0 <debugMsg@plt>
mov    %r12,%rdi
call   10c0 <gethostbyname@plt>
test   %rax,%rax
je     13d8 <httpGetPost+0x1e8>
mov    %rax,%rbx
lea    0xe1e(%rip),%rdi
call   10b0 <debugMsg@plt>
lea    0x18(%rsp),%rdi
mov    (%rbx),%edx
mov    0x4(%rbx),%esi
call   10d0 <memcpy@plt>
mov    %ebp,%edi
call   1080 <htons@plt>
mov    %eax,0x14(%rsp)
mov    0x2d81(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
mov    0x2d53(%rip),%rax
mov    (%rax),%esi
mov    0x2d5a(%rip),%rbx
mov    (%rbx),%edx
call   1110 <socket@plt>
mov    %eax,%ebp
movl   $0x1,0xc(%rsp)
mov    (%rbx),%esi
mov    0x2d50(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1050 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     13e1 <httpGetPost+0x1f1>
lea    0xdf5(%rip),%rdi
call   10b0 <debugMsg@plt>
cmp    $0xffffffff,%ebp
je     13ea <httpGetPost+0x1fa>
lea    0xe33(%rip),%rdi
call   10b0 <debugMsg@plt>
lea    0x10(%rsp),%rsi
mov    %ebp,%edi
mov    $0xc,%edx
call   1100 <connect@plt>
cmp    $0xffffffff,%eax
je     13f3 <httpGetPost+0x203>
lea    0xe5e(%rip),%rdi
call   10b0 <debugMsg@plt>
lea    0xe7a(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r12,%r8
xor    %eax,%eax
call   10f0 <sprintf@plt>
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1090 <send@plt>
test   %rax,%rax
js     13fc <httpGetPost+0x20c>
lea    0xe9b(%rip),%rdi
call   10b0 <debugMsg@plt>
lea    0x220(%rsp),%rsi
mov    %ebp,%edi
mov    $0x19000,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     1405 <httpGetPost+0x215>
mov    %eax,%ebx
lea    0xeba(%rip),%rdi
call   10b0 <debugMsg@plt>
movslq %ebx,%rax
movb   $0x0,0x220(%rsp,%rax,1)
lea    0xec8(%rip),%rdi
call   10b0 <debugMsg@plt>
lea    0x220(%rsp),%r14
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %eax,%edi
call   10e0 <malloc@plt>
mov    %rax,%rbx
lea    0xec2(%rip),%rdi
call   10b0 <debugMsg@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
lea    0xed2(%rip),%rdi
call   10b0 <debugMsg@plt>
mov    0x2c2a(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   1060 <shutdown@plt>
mov    %ebp,%edi
call   10a0 <close@plt>
jmp    1413 <httpGetPost+0x223>
lea    0xc33(%rip),%rdi
jmp    140c <httpGetPost+0x21c>
lea    0xc95(%rip),%rdi
jmp    140c <httpGetPost+0x21c>
lea    0xce2(%rip),%rdi
jmp    140c <httpGetPost+0x21c>
lea    0xd29(%rip),%rdi
jmp    140c <httpGetPost+0x21c>
lea    0xdaa(%rip),%rdi
jmp    140c <httpGetPost+0x21c>
lea    0xded(%rip),%rdi
call   10b0 <debugMsg@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x19220,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.hostent = type { i32, i32 }
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [18 x i8] c"httpGetPost() ...\00"
@.str.1 = [61 x i8] c"httpGetPost() ... gethostbyname() ... connection failed ....\00"
@.str.2 = [46 x i8] c"httpGetPost() ... gethostbyname() ... ok ....\00"
@AF_INET = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@.str.3 = [44 x i8] c"httpGetPost() ... setsockopt() ... fail ...\00"
@.str.4 = [42 x i8] c"httpGetPost() ... setsockopt() ... ok ...\00"
@.str.5 = [41 x i8] c"httpGetPost() ... socket() ... fail ....\00"
@.str.6 = [39 x i8] c"httpGetPost() ... socket() ... ok ....\00"
@.str.7 = [42 x i8] c"httpGetPost() ... connect() ... fail ....\00"
@.str.8 = [40 x i8] c"httpGetPost() ... connect() ... ok ....\00"
@.str.9 = [56 x i8] c"%s %s HTTP/1.1\0D\0AHost: %s\0D\0AUserAgent: Linux Br/1.0.0\0D\0A\0D\0A\00"
@.str.10 = [39 x i8] c"httpGetPost() ... send() ... fail ....\00"
@.str.11 = [37 x i8] c"httpGetPost() ... send() ... ok ....\00"
@.str.12 = [39 x i8] c"httpGetPost() ... recv() ... fail ....\00"
@.str.13 = [37 x i8] c"httpGetPost() ... recv() ... ok ....\00"
@.str.14 = [32 x i8] c"httpGetPost() ... malloc() ....\00"
@.str.15 = [39 x i8] c"httpGetPost() ... malloc() .... ok ...\00"
@.str.16 = [3 x i8] c"%s\00"
@.str.17 = [25 x i8] c"httpGetPost() ... ok ...\00"
@SHUT_RDWR = global i32 0
define i8* @httpGetPost(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca %struct.hostent*
%11 = alloca %struct.sockaddr_in
%12 = alloca i32
%13 = alloca i32
%14 = alloca [512 x i8]
%15 = alloca [102400 x i8]
%16 = alloca i32
%17 = alloca i8*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i8* %3, i8** %9
%18 = call i32 @debugMsg(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%19 = load i8*, i8** %6
%20 = call %struct.hostent* @gethostbyname(i8* %19)
store %struct.hostent* %20, %struct.hostent** %10
%21 = icmp eq %struct.hostent* %20, null
br i1 %21, label %22, label %24
22: ; preds = %4
%23 = call i32 @debugMsg(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
store i8* null, i8** %5
br label %111
24: ; preds = %4
%25 = call i32 @debugMsg(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
%27 = load %struct.hostent*, %struct.hostent** %10
%28 = getelementptr inbounds %struct.hostent, %struct.hostent* %27, i32 0, i32 1
%29 = load i32, i32* %28
%30 = load %struct.hostent*, %struct.hostent** %10
%31 = getelementptr inbounds %struct.hostent, %struct.hostent* %30, i32 0, i32 0
%32 = load i32, i32* %31
%33 = call i32 @memcpy(i32* %26, i32 %29, i32 %32)
%34 = load i32, i32* %8
%35 = call i32 @htons(i32 %34)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
store i32 %35, i32* %36
%37 = load i32, i32* @AF_INET
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
store i32 %37, i32* %38
%39 = load i32, i32* @PF_INET
%40 = load i32, i32* @SOCK_STREAM
%41 = load i32, i32* @IPPROTO_TCP
%42 = call i32 @socket(i32 %39, i32 %40, i32 %41)
store i32 %42, i32* %12
store i32 1, i32* %13
%43 = load i32, i32* %12
%44 = load i32, i32* @IPPROTO_TCP
%45 = load i32, i32* @TCP_NODELAY
%46 = bitcast i32* %13 to i8*
%47 = call i32 @setsockopt(i32 %43, i32 %44, i32 %45, i8* %46, i32 4)
%48 = icmp eq i32 %47, -1
br i1 %48, label %49, label %51
49: ; preds = %24
%50 = call i32 @debugMsg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
store i8* null, i8** %5
br label %111
51: ; preds = %24
%52 = call i32 @debugMsg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%53 = load i32, i32* %12
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call i32 @debugMsg(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
store i8* null, i8** %5
br label %111
57: ; preds = %51
%58 = call i32 @debugMsg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
%59 = load i32, i32* %12
%60 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%61 = call i32 @connect(i32 %59, %struct.sockaddr* %60, i32 12)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %65
63: ; preds = %57
%64 = call i32 @debugMsg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
store i8* null, i8** %5
br label %111
65: ; preds = %57
%66 = call i32 @debugMsg(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
%67 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%68 = load i8*, i8** %9
%69 = load i8*, i8** %7
%70 = load i8*, i8** %6
%71 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %67, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0), i8* %68, i8* %69, i8* %70)
%72 = load i32, i32* %12
%73 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%74 = getelementptr inbounds [512 x i8], [512 x i8]* %14, i64 0, i64 0
%75 = call i32 @strlen(i8* %74)
%76 = call i64 @send(i32 %72, i8* %73, i32 %75, i32 0)
%77 = icmp slt i64 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %65
%79 = call i32 @debugMsg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
store i8* null, i8** %5
br label %111
80: ; preds = %65
%81 = call i32 @debugMsg(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
%82 = load i32, i32* %12
%83 = getelementptr inbounds [102400 x i8], [102400 x i8]* %15, i64 0, i64 0
%84 = call i32 @recv(i32 %82, i8* %83, i32 102400, i32 0)
store i32 %84, i32* %16
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %88
86: ; preds = %80
%87 = call i32 @debugMsg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0))
store i8* null, i8** %5
br label %111
88: ; preds = %80
%89 = call i32 @debugMsg(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0))
%90 = load i32, i32* %16
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds [102400 x i8], [102400 x i8]* %15, i64 0, i64 %91
store i8 0, i8* %92
%93 = call i32 @debugMsg(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0))
%94 = getelementptr inbounds [102400 x i8], [102400 x i8]* %15, i64 0, i64 0
%95 = call i32 @strlen(i8* %94)
%96 = sext i32 %95 to i64
%97 = mul i64 1, %96
%98 = trunc i64 %97 to i32
%99 = call i8* @malloc(i32 %98)
store i8* %99, i8** %17
%100 = call i32 @debugMsg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.15, i64 0, i64 0))
%101 = load i8*, i8** %17
%102 = getelementptr inbounds [102400 x i8], [102400 x i8]* %15, i64 0, i64 0
%103 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %101, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.16, i64 0, i64 0), i8* %102)
%104 = call i32 @debugMsg(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0))
%105 = load i32, i32* %12
%106 = load i32, i32* @SHUT_RDWR
%107 = call i32 @shutdown(i32 %105, i32 %106)
%108 = load i32, i32* %12
%109 = call i32 @close(i32 %108)
%110 = load i8*, i8** %17
store i8* %110, i8** %5
br label %111
111: ; preds = %88, %86, %78, %63, %55, %49, %22
%112 = load i8*, i8** %5
ret i8* %112
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.hostent = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [18 x i8] c"httpGetPost() ...\00"
@.str.1 = [61 x i8] c"httpGetPost() ... gethostbyname() ... connection failed ....\00"
@.str.2 = [46 x i8] c"httpGetPost() ... gethostbyname() ... ok ....\00"
@AF_INET = global i32 0
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@TCP_NODELAY = global i32 0
@.str.3 = [44 x i8] c"httpGetPost() ... setsockopt() ... fail ...\00"
@.str.4 = [42 x i8] c"httpGetPost() ... setsockopt() ... ok ...\00"
@.str.5 = [41 x i8] c"httpGetPost() ... socket() ... fail ....\00"
@.str.6 = [39 x i8] c"httpGetPost() ... socket() ... ok ....\00"
@.str.7 = [42 x i8] c"httpGetPost() ... connect() ... fail ....\00"
@.str.8 = [40 x i8] c"httpGetPost() ... connect() ... ok ....\00"
@.str.9 = [56 x i8] c"%s %s HTTP/1.1\0D\0AHost: %s\0D\0AUserAgent: Linux Br/1.0.0\0D\0A\0D\0A\00"
@.str.10 = [39 x i8] c"httpGetPost() ... send() ... fail ....\00"
@.str.11 = [37 x i8] c"httpGetPost() ... send() ... ok ....\00"
@.str.12 = [39 x i8] c"httpGetPost() ... recv() ... fail ....\00"
@.str.13 = [37 x i8] c"httpGetPost() ... recv() ... ok ....\00"
@.str.14 = [32 x i8] c"httpGetPost() ... malloc() ....\00"
@.str.15 = [39 x i8] c"httpGetPost() ... malloc() .... ok ...\00"
@.str.17 = [25 x i8] c"httpGetPost() ... ok ...\00"
@SHUT_RDWR = global i32 0
define i8* @httpGetPost(i8* %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca %struct.sockaddr_in
%6 = alloca i32
%7 = alloca [512 x i8]
%8 = alloca [102400 x i8]
%9 = tail call i32 @debugMsg(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%10 = tail call %struct.hostent* @gethostbyname(i8* %0)
%11 = icmp eq %struct.hostent* %10, null
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = tail call i32 @debugMsg(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
br label %85
14: ; preds = %4
%15 = tail call i32 @debugMsg(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0))
%16 = bitcast %struct.sockaddr_in* %5 to i8*
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
%18 = getelementptr inbounds %struct.hostent, %struct.hostent* %10, i64 0, i32 1
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.hostent, %struct.hostent* %10, i64 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @memcpy(i32* %17, i32 %19, i32 %21)
%23 = call i32 @htons(i32 %2)
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i32 %23, i32* %24
%25 = load i32, i32* @AF_INET
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0
store i32 %25, i32* %26
%27 = load i32, i32* @PF_INET
%28 = load i32, i32* @SOCK_STREAM
%29 = load i32, i32* @IPPROTO_TCP
%30 = call i32 @socket(i32 %27, i32 %28, i32 %29)
%31 = bitcast i32* %6 to i8*
store i32 1, i32* %6
%32 = load i32, i32* @IPPROTO_TCP
%33 = load i32, i32* @TCP_NODELAY
%34 = call i32 @setsockopt(i32 %30, i32 %32, i32 %33, i8* %31, i32 4)
%35 = icmp eq i32 %34, -1
br i1 %35, label %36, label %38
36: ; preds = %14
%37 = call i32 @debugMsg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0))
br label %83
38: ; preds = %14
%39 = call i32 @debugMsg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%40 = icmp eq i32 %30, -1
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @debugMsg(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0))
br label %83
43: ; preds = %38
%44 = call i32 @debugMsg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
%45 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%46 = call i32 @connect(i32 %30, %struct.sockaddr* %45, i32 12)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %43
%49 = call i32 @debugMsg(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
br label %83
50: ; preds = %43
%51 = call i32 @debugMsg(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%53 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %52, i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str.9, i64 0, i64 0), i8* %3, i8* %1, i8* %0)
%54 = call i32 @strlen(i8* %52)
%55 = call i64 @send(i32 %30, i8* %52, i32 %54, i32 0)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %50
%58 = call i32 @debugMsg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0))
br label %81
59: ; preds = %50
%60 = call i32 @debugMsg(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
%61 = getelementptr inbounds [102400 x i8], [102400 x i8]* %8, i64 0, i64 0
%62 = call i32 @recv(i32 %30, i8* %61, i32 102400, i32 0)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %66
64: ; preds = %59
%65 = call i32 @debugMsg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0))
br label %79
66: ; preds = %59
%67 = call i32 @debugMsg(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.13, i64 0, i64 0))
%68 = sext i32 %62 to i64
%69 = getelementptr inbounds [102400 x i8], [102400 x i8]* %8, i64 0, i64 %68
store i8 0, i8* %69
%70 = call i32 @debugMsg(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.14, i64 0, i64 0))
%71 = call i32 @strlen(i8* %61)
%72 = call i8* @malloc(i32 %71)
%73 = call i32 @debugMsg(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.15, i64 0, i64 0))
%74 = call i8* @strcpy(i8* dereferenceable(1) %72, i8* %61)
%75 = call i32 @debugMsg(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0))
%76 = load i32, i32* @SHUT_RDWR
%77 = call i32 @shutdown(i32 %30, i32 %76)
%78 = call i32 @close(i32 %30)
br label %79
79: ; preds = %66, %64
%80 = phi i8* [ null, %64 ], [ %72, %66 ]
br label %81
81: ; preds = %79, %57
%82 = phi i8* [ null, %57 ], [ %80, %79 ]
br label %83
83: ; preds = %81, %48, %41, %36
%84 = phi i8* [ null, %36 ], [ null, %41 ], [ null, %48 ], [ %82, %81 ]
br label %85
85: ; preds = %83, %12
%86 = phi i8* [ null, %12 ], [ %84, %83 ]
ret i8* %86
}