#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;
  scalar_t__ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  char *h_name;
  scalar_t__ h_addrtype;
  char **h_addr_list;
};
typedef int /*<<< orphan*/ str;
typedef int /*<<< orphan*/ servaddr;

/* Variables and functions */
scalar_t__ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ h_errno;
char *hstrerror(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
char *inet_ntop(scalar_t__, char *, char *, int);
int /*<<< orphan*/ inet_pton(scalar_t__, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ process_http(int, char *, char *, char *);
int socket(scalar_t__, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(void) {
  int sockfd;
  struct sockaddr_in servaddr;
  char **pptr;
  char *hname = "telit.jspblm.com";
  char *page = "/telit-post-request/";
  char *poststr = "a=10990&b=150408&c=115549&d=115554&e=59703751&f=0&g=0&h=3&i="
                  "0&j=>&k=8950203015001199331";
  char str[50];
  struct hostent *hptr;
  if ((hptr = gethostbyname(hname)) == NULL) {
    fprintf(stderr, " Server down error for host: %s: %s", hname,
            hstrerror(h_errno));
    exit(1);
  }
  printf("hostname: %s \n", hptr->h_name);
  if (hptr->h_addrtype == AF_INET && (pptr = hptr->h_addr_list) != NULL) {
    printf("address: %s\n",
           inet_ntop(hptr->h_addrtype, *pptr, str, sizeof(str)));
  } else {
    fprintf(stderr, "Error call inet_ntop \n");
  }
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_port = htons(80);
  inet_pton(AF_INET, str, &servaddr.sin_addr);
  connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr));
  process_http(sockfd, hname, page, poststr);
  close(sockfd);
  printf("END\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe17(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe1d(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe27(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <gethostbyname@plt>
mov    %rax,-0x78(%rbp)
cmp    $0x0,%rax
jne    1264 <main+0x94>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x84(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
call   10c0 <hstrerror@plt>
mov    -0x84(%rbp),%edi
mov    -0x80(%rbp),%rdx
mov    %rax,%rcx
lea    0xe2b(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x78(%rbp),%rax
mov    (%rax),%rsi
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x78(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2d60(%rip),%rcx
cmp    (%rcx),%rax
jne    12da <main+0x10a>
mov    -0x78(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     12da <main+0x10a>
mov    -0x78(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
lea    -0x70(%rbp),%rdx
mov    $0x32,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rsi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    12f1 <main+0x121>
mov    0x2cef(%rip),%rax
mov    (%rax),%edi
lea    0xdd4(%rip),%rsi
mov    $0x0,%al
call   1090 <fprintf@plt>
mov    0x2cf0(%rip),%rax
mov    (%rax),%rdi
mov    0x2cc6(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
mov    $0x10,%esi
call   10b0 <bzero@plt>
mov    0x2cc5(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    $0x50,%edi
call   1050 <htons@plt>
mov    %eax,-0x14(%rbp)
mov    0x2caa(%rip),%rax
mov    (%rax),%rdi
lea    -0x70(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   10a0 <inet_pton@plt>
mov    -0x8(%rbp),%edi
lea    -0x18(%rbp),%rsi
mov    $0x10,%edx
call   10e0 <connect@plt>
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
call   1040 <process_http@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
lea    0xd53(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   10d0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
lea    0xe10(%rip),%rdi
call   1090 <gethostbyname@plt>
test   %rax,%rax
jne    1235 <main+0x55>
mov    0x2dcf(%rip),%rax
mov    (%rax),%ebx
mov    0x2dd6(%rip),%rax
mov    (%rax),%edi
call   10d0 <hstrerror@plt>
lea    0xe66(%rip),%rsi
lea    0xde1(%rip),%rdx
mov    %ebx,%edi
mov    %rax,%rcx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    %rax,%rbx
mov    (%rax),%rsi
lea    0xe60(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x8(%rbx),%rdi
mov    0x2d94(%rip),%r15
cmp    (%r15),%rdi
jne    1262 <main+0x82>
mov    0x10(%rbx),%rax
test   %rax,%rax
jne    127b <main+0x9b>
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
lea    0xe4c(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    129e <main+0xbe>
mov    (%rax),%rsi
lea    0x10(%rsp),%rdx
mov    $0x32,%ecx
call   1030 <inet_ntop@plt>
lea    0xe1d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    (%r15),%rdi
mov    0x2d20(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x10,%esi
call   10c0 <bzero@plt>
mov    (%r15),%rax
mov    %rax,0x8(%rsp)
mov    $0x50,%edi
call   1060 <htons@plt>
mov    %eax,0x4(%rsp)
mov    (%r15),%rdi
lea    0x10(%rsp),%rsi
mov    %r14,%rdx
call   10b0 <inet_pton@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x10,%edx
call   10f0 <connect@plt>
lea    0xd01(%rip),%rsi
lea    0xd0b(%rip),%rdx
lea    0xd19(%rip),%rcx
mov    %ebx,%edi
call   1050 <process_http@plt>
mov    %ebx,%edi
call   1080 <close@plt>
lea    0xdb3(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i64 }
%struct.hostent = type { i8*, i64, i8** }
%struct.sockaddr = type { i32 }
@.str = [17 x i8] c"telit.jspblm.com\00"
@.str.1 = [21 x i8] c"/telit-post-request/\00"
@.str.2 = [88 x i8] c"a=10990&b=150408&c=115549&d=115554&e=59703751&f=0&g=0&h=3&i=0&j=>&k=8950203015001199331\00"
@stderr = global i32 0
@.str.3 = [36 x i8] c" Server down error for host: %s: %s\00"
@h_errno = global i32 0
@.str.4 = [15 x i8] c"hostname: %s \0A\00"
@AF_INET = global i64 0
@.str.5 = [13 x i8] c"address: %s\0A\00"
@.str.6 = [23 x i8] c"Error call inet_ntop \0A\00"
@SOCK_STREAM = global i32 0
@.str.7 = [5 x i8] c"END\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.sockaddr_in
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [50 x i8]
%9 = alloca %struct.hostent*
store i32 0, i32* %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0), i8** %7
%10 = load i8*, i8** %5
%11 = call %struct.hostent* @gethostbyname(i8* %10)
store %struct.hostent* %11, %struct.hostent** %9
%12 = icmp eq %struct.hostent* %11, null
br i1 %12, label %13, label %20
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %5
%16 = load i32, i32* @h_errno
%17 = call i8* @hstrerror(i32 %16)
%18 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %15, i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %0
%21 = load %struct.hostent*, %struct.hostent** %9
%22 = getelementptr inbounds %struct.hostent, %struct.hostent* %21, i32 0, i32 0
%23 = load i8*, i8** %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = load %struct.hostent*, %struct.hostent** %9
%26 = getelementptr inbounds %struct.hostent, %struct.hostent* %25, i32 0, i32 1
%27 = load i64, i64* %26
%28 = load i64, i64* @AF_INET
%29 = icmp eq i64 %27, %28
br i1 %29, label %30, label %44
30: ; preds = %20
%31 = load %struct.hostent*, %struct.hostent** %9
%32 = getelementptr inbounds %struct.hostent, %struct.hostent* %31, i32 0, i32 2
%33 = load i8**, i8*** %32
store i8** %33, i8*** %4
%34 = icmp ne i8** %33, null
br i1 %34, label %35, label %44
35: ; preds = %30
%36 = load %struct.hostent*, %struct.hostent** %9
%37 = getelementptr inbounds %struct.hostent, %struct.hostent* %36, i32 0, i32 1
%38 = load i64, i64* %37
%39 = load i8**, i8*** %4
%40 = load i8*, i8** %39
%41 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%42 = call i8* @inet_ntop(i64 %38, i8* %40, i8* %41, i32 50)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %42)
br label %47
44: ; preds = %30, %20
%45 = load i32, i32* @stderr
%46 = call i32 (i32, i8*, ...) @fprintf(i32 %45, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %47
47: ; preds = %44, %35
%48 = load i64, i64* @AF_INET
%49 = load i32, i32* @SOCK_STREAM
%50 = call i32 @socket(i64 %48, i32 %49, i32 0)
store i32 %50, i32* %2
%51 = call i32 @bzero(%struct.sockaddr_in* %3, i32 16)
%52 = load i64, i64* @AF_INET
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 2
store i64 %52, i64* %53
%54 = call i32 @htons(i32 80)
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
store i32 %54, i32* %55
%56 = load i64, i64* @AF_INET
%57 = getelementptr inbounds [50 x i8], [50 x i8]* %8, i64 0, i64 0
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%59 = call i32 @inet_pton(i64 %56, i8* %57, i32* %58)
%60 = load i32, i32* %2
%61 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%62 = call i32 @connect(i32 %60, %struct.sockaddr* %61, i32 16)
%63 = load i32, i32* %2
%64 = load i8*, i8** %5
%65 = load i8*, i8** %6
%66 = load i8*, i8** %7
%67 = call i32 @process_http(i32 %63, i8* %64, i8* %65, i8* %66)
%68 = load i32, i32* %2
%69 = call i32 @close(i32 %68)
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
%71 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i64 }
%struct.hostent = type { i8*, i64, i8** }
%struct.sockaddr = type { i32 }
@.str = [17 x i8] c"telit.jspblm.com\00"
@.str.1 = [21 x i8] c"/telit-post-request/\00"
@.str.2 = [88 x i8] c"a=10990&b=150408&c=115549&d=115554&e=59703751&f=0&g=0&h=3&i=0&j=>&k=8950203015001199331\00"
@stderr = global i32 0
@.str.3 = [36 x i8] c" Server down error for host: %s: %s\00"
@h_errno = global i32 0
@.str.4 = [15 x i8] c"hostname: %s \0A\00"
@AF_INET = global i64 0
@.str.5 = [13 x i8] c"address: %s\0A\00"
@.str.6 = [23 x i8] c"Error call inet_ntop \0A\00"
@SOCK_STREAM = global i32 0
@str = [4 x i8] c"END\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca [50 x i8]
%3 = bitcast %struct.sockaddr_in* %1 to i8*
%4 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%5 = tail call %struct.hostent* @gethostbyname(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq %struct.hostent* %5, null
br i1 %6, label %7, label %13
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @h_errno
%10 = tail call i8* @hstrerror(i32 %9)
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %0
%14 = getelementptr inbounds %struct.hostent, %struct.hostent* %5, i64 0, i32 0
%15 = load i8*, i8** %14
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds %struct.hostent, %struct.hostent* %5, i64 0, i32 1
%18 = load i64, i64* %17
%19 = load i64, i64* @AF_INET
%20 = icmp eq i64 %18, %19
br i1 %20, label %21, label %29
21: ; preds = %13
%22 = getelementptr inbounds %struct.hostent, %struct.hostent* %5, i64 0, i32 2
%23 = load i8**, i8*** %22
%24 = icmp eq i8** %23, null
br i1 %24, label %29, label %25
25: ; preds = %21
%26 = load i8*, i8** %23
%27 = call i8* @inet_ntop(i64 %18, i8* %26, i8* %4, i32 50)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %27)
br label %32
29: ; preds = %21, %13
%30 = load i32, i32* @stderr
%31 = tail call i32 (i32, i8*, ...) @fprintf(i32 %30, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
br label %32
32: ; preds = %29, %25
%33 = load i64, i64* @AF_INET
%34 = load i32, i32* @SOCK_STREAM
%35 = call i32 @socket(i64 %33, i32 %34, i32 0)
%36 = call i32 @bzero(%struct.sockaddr_in* %1, i32 16)
%37 = load i64, i64* @AF_INET
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i64 %37, i64* %38
%39 = call i32 @htons(i32 80)
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %39, i32* %40
%41 = load i64, i64* @AF_INET
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%43 = call i32 @inet_pton(i64 %41, i8* %4, i32* %42)
%44 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%45 = call i32 @connect(i32 %35, %struct.sockaddr* %44, i32 16)
%46 = call i32 @process_http(i32 %35, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 @close(i32 %35)
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%49 = call i32 @exit(i32 0)
unreachable
}