#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 timeval {
  scalar_t__ tv_usec;
  scalar_t__ tv_sec;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ servaddr;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
scalar_t__ inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int read(int, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int server(int port, char *IP, char *API_URL, char *API_KEY, char *DEVICE_NUM,
           char *DEVICE_SENSOR, char *way, char *POST_char, int time,
           char *bu) {
  int sockfd, ret, i, h;
  struct sockaddr_in servaddr;
  char str1[4096], *buf;
  fd_set t_set1;
  buf = bu;
  struct timeval tv;
  if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    exit(0);
  }
  bzero(&servaddr, sizeof(servaddr));
  servaddr.sin_family = AF_INET;
  servaddr.sin_port = htons(port);
  if (inet_pton(AF_INET, IP, &servaddr.sin_addr) <= 0) {
    exit(0);
  };
  if (connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) < 0) {
    exit(0);
  }
  memset(str1, 0, 4096);
  strcat(str1, way);
  strcat(str1, " /v1.0/device/");
  strcat(str1, DEVICE_NUM);
  strcat(str1, "/sensor/");
  strcat(str1, DEVICE_SENSOR);
  strcat(str1, "/datapoints HTTP/1.1\r\n");
  strcat(str1, "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; "
               "rv:9.0.1) Gecko/20100101 Firefox/9.0.1\r\n");
  strcat(str1, "Host: ");
  strcat(str1, API_URL);
  strcat(str1, "\r\n");
  strcat(str1, "Accept: */*\r\n");
  strcat(str1, "U-ApiKey: ");
  strcat(str1, API_KEY);
  strcat(str1, "\r\n");
  strcat(str1, POST_char);
  strcat(str1, "\n\n");
  strcat(str1, "\r\n\r\n");
  strcat(str1, "\r\n\r\n");
  ret = write(sockfd, str1, strlen(str1));
  if (ret < 0) {
    exit(0);
  } else {
  }
  FD_ZERO(&t_set1);
  FD_SET(sockfd, &t_set1);
  FD_SET(sockfd, &t_set1);
  while (1) {
    sleep(time);
    tv.tv_sec = 0;
    tv.tv_usec = 0;
    h = 0;
    h = select(sockfd + 1, &t_set1, NULL, NULL, &tv);
    if (h == 0)
      continue;
    if (h < 0) {
      close(sockfd);
      exit(0);
    }
    if (h > 0) {
      memset(buf, 0, 4096);
      i = read(sockfd, buf, 4095);
      if (i == 0) {
        close(sockfd);
        exit(0);
      }
      return 0;
    }
  }
  close(sockfd);
  return 0;
}


x86 assembly (clang, -O0):
<server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1080,%rsp
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x28(%rbp),%rax
mov    %rax,-0x1058(%rbp)
mov    0x2da5(%rip),%rax
mov    (%rax),%edi
mov    0x2d8c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    1268 <server+0x68>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    -0x50(%rbp),%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    0x2d6b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x4(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x4c(%rbp)
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
lea    -0x50(%rbp),%rdx
call   1090 <inet_pton@plt>
cmp    $0x0,%rax
jg     12b4 <server+0xb4>
xor    %edi,%edi
call   10e0 <exit@plt>
mov    -0x34(%rbp),%edi
lea    -0x50(%rbp),%rsi
mov    $0xc,%edx
call   10f0 <connect@plt>
cmp    $0x0,%rax
jge    12d6 <server+0xd6>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    -0x1050(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
lea    -0x1050(%rbp),%rdi
mov    0x10(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xcf9(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xce5(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xccb(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xccf(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xd1e(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xd20(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xcef(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xcea(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xcd7(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
mov    0x18(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xcaf(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xc9f(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xc8c(%rip),%rsi
call   10d0 <strcat@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x107c(%rbp)
lea    -0x1050(%rbp),%rax
mov    %rax,-0x1078(%rbp)
lea    -0x1050(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x107c(%rbp),%edi
mov    -0x1078(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    1478 <server+0x278>
xor    %edi,%edi
call   10e0 <exit@plt>
jmp    147d <server+0x27d>
lea    -0x105c(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
mov    -0x34(%rbp),%edi
lea    -0x105c(%rbp),%rsi
call   1100 <FD_SET@plt>
mov    -0x34(%rbp),%edi
lea    -0x105c(%rbp),%rsi
call   1100 <FD_SET@plt>
mov    0x20(%rbp),%edi
call   1110 <sleep@plt>
movq   $0x0,-0x1068(%rbp)
movq   $0x0,-0x1070(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x34(%rbp),%edi
add    $0x1,%edi
lea    -0x105c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x1070(%rbp),%r8
mov    %rcx,%rdx
call   10b0 <select@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jne    14fe <server+0x2fe>
jmp    14a7 <server+0x2a7>
cmpl   $0x0,-0x40(%rbp)
jge    1517 <server+0x317>
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
cmpl   $0x0,-0x40(%rbp)
jle    156f <server+0x36f>
mov    -0x1058(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
mov    -0x34(%rbp),%edi
mov    -0x1058(%rbp),%rsi
mov    $0xfff,%edx
call   1080 <read@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1564 <server+0x364>
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10e0 <exit@plt>
xor    %eax,%eax
add    $0x1080,%rsp
pop    %rbp
ret
jmp    14a7 <server+0x2a7>

x86 assembly (clang, -O2):
<server>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1048,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,%r13
mov    %rcx,0x20(%rsp)
mov    %rdx,0x18(%rsp)
mov    %rsi,%rbx
mov    %edi,%r14d
mov    0x2db8(%rip),%r12
mov    (%r12),%edi
mov    0x2d9d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
test   %eax,%eax
js     147e <server+0x27e>
mov    %eax,%r15d
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    (%r12),%eax
mov    %eax,0x8(%rsp)
mov    %r14d,%edi
call   1050 <htons@plt>
mov    %eax,0x4(%rsp)
mov    (%r12),%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1090 <inet_pton@plt>
test   %rax,%rax
jle    147e <server+0x27e>
mov    %rsp,%rsi
mov    %r15d,%edi
mov    $0xc,%edx
call   10f0 <connect@plt>
test   %rax,%rax
js     147e <server+0x27e>
mov    0x1088(%rsp),%r14
mov    0x1080(%rsp),%rbp
lea    0x40(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10d0 <strcat@plt>
lea    0xd36(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <strcat@plt>
lea    0xd2b(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
call   10d0 <strcat@plt>
lea    0xd18(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xd20(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xd73(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
call   10d0 <strcat@plt>
lea    0xd7c(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10d0 <strcat@plt>
lea    0xd4c(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xd4b(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    0x20(%rsp),%rsi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10d0 <strcat@plt>
lea    0xd24(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xd18(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %eax,%eax
js     147e <server+0x27e>
mov    0x1098(%rsp),%r14
mov    0x1090(%rsp),%r12d
lea    0x2c(%rsp),%r13
mov    %r13,%rdi
call   10a0 <FD_ZERO@plt>
mov    %r15d,%edi
mov    %r13,%rsi
call   1100 <FD_SET@plt>
mov    %r15d,%edi
mov    %r13,%rsi
call   1100 <FD_SET@plt>
mov    %r15d,%ebx
add    $0x1,%ebx
lea    0x30(%rsp),%rbp
nopl   (%rax)
mov    %r12d,%edi
call   1110 <sleep@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
mov    %ebx,%edi
mov    %r13,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbp,%r8
call   10b0 <select@plt>
test   %eax,%eax
je     1420 <server+0x220>
js     1485 <server+0x285>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0xfff,%edx
call   1080 <read@plt>
test   %eax,%eax
je     1485 <server+0x285>
xor    %eax,%eax
add    $0x1048,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   10e0 <exit@plt>
mov    %r15d,%edi
call   1070 <close@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.timeval = type { i64, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [15 x i8] c" /v1.0/device/\00"
@.str.1 = [9 x i8] c"/sensor/\00"
@.str.2 = [23 x i8] c"/datapoints HTTP/1.1\0D\0A\00"
@.str.3 = [98 x i8] c"User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:9.0.1) Gecko/20100101 Firefox/9.0.1\0D\0A\00"
@.str.4 = [7 x i8] c"Host: \00"
@.str.5 = [3 x i8] c"\0D\0A\00"
@.str.6 = [14 x i8] c"Accept: */*\0D\0A\00"
@.str.7 = [11 x i8] c"U-ApiKey: \00"
@.str.8 = [3 x i8] c"\0A\0A\00"
@.str.9 = [5 x i8] c"\0D\0A\0D\0A\00"
define i32 @server(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7, i32 %8, i8* %9) {
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i8*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca %struct.sockaddr_in
%26 = alloca [4096 x i8]
%27 = alloca i8*
%28 = alloca i32
%29 = alloca %struct.timeval
store i32 %0, i32* %11
store i8* %1, i8** %12
store i8* %2, i8** %13
store i8* %3, i8** %14
store i8* %4, i8** %15
store i8* %5, i8** %16
store i8* %6, i8** %17
store i8* %7, i8** %18
store i32 %8, i32* %19
store i8* %9, i8** %20
%30 = load i8*, i8** %20
store i8* %30, i8** %27
%31 = load i32, i32* @AF_INET
%32 = load i32, i32* @SOCK_STREAM
%33 = call i32 @socket(i32 %31, i32 %32, i32 0)
store i32 %33, i32* %21
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %10
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %10
%38 = call i32 @bzero(%struct.sockaddr_in* %25, i32 12)
%39 = load i32, i32* @AF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %25, i32 0, i32 2
store i32 %39, i32* %40
%41 = load i32, i32* %11
%42 = call i32 @htons(i32 %41)
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %25, i32 0, i32 1
store i32 %42, i32* %43
%44 = load i32, i32* @AF_INET
%45 = load i8*, i8** %12
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %25, i32 0, i32 0
%47 = call i64 @inet_pton(i32 %44, i8* %45, i32* %46)
%48 = icmp sle i64 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %37
%50 = call i32 @exit(i32 0)
unreachable
51: ; preds = %37
%52 = load i32, i32* %21
%53 = bitcast %struct.sockaddr_in* %25 to %struct.sockaddr*
%54 = call i64 @connect(i32 %52, %struct.sockaddr* %53, i32 12)
%55 = icmp slt i64 %54, 0
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = call i32 @exit(i32 0)
unreachable
58: ; preds = %51
%59 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%60 = call i32 @memset(i8* %59, i32 0, i32 4096)
%61 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%62 = load i8*, i8** %17
%63 = call i32 @strcat(i8* %61, i8* %62)
%64 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%65 = call i32 @strcat(i8* %64, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%66 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%67 = load i8*, i8** %15
%68 = call i32 @strcat(i8* %66, i8* %67)
%69 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%70 = call i32 @strcat(i8* %69, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%71 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%72 = load i8*, i8** %16
%73 = call i32 @strcat(i8* %71, i8* %72)
%74 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%75 = call i32 @strcat(i8* %74, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%76 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%77 = call i32 @strcat(i8* %76, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.3, i64 0, i64 0))
%78 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%79 = call i32 @strcat(i8* %78, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%80 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%81 = load i8*, i8** %13
%82 = call i32 @strcat(i8* %80, i8* %81)
%83 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%84 = call i32 @strcat(i8* %83, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%85 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%86 = call i32 @strcat(i8* %85, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%88 = call i32 @strcat(i8* %87, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%89 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%90 = load i8*, i8** %14
%91 = call i32 @strcat(i8* %89, i8* %90)
%92 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%93 = call i32 @strcat(i8* %92, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%94 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%95 = load i8*, i8** %18
%96 = call i32 @strcat(i8* %94, i8* %95)
%97 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%98 = call i32 @strcat(i8* %97, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%99 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%100 = call i32 @strcat(i8* %99, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%101 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%102 = call i32 @strcat(i8* %101, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%103 = load i32, i32* %21
%104 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%105 = getelementptr inbounds [4096 x i8], [4096 x i8]* %26, i64 0, i64 0
%106 = call i32 @strlen(i8* %105)
%107 = call i32 @write(i32 %103, i8* %104, i32 %106)
store i32 %107, i32* %22
%108 = load i32, i32* %22
%109 = icmp slt i32 %108, 0
br i1 %109, label %110, label %112
110: ; preds = %58
%111 = call i32 @exit(i32 0)
unreachable
112: ; preds = %58
br label %113
113: ; preds = %112
%114 = call i32 @FD_ZERO(i32* %28)
%115 = load i32, i32* %21
%116 = call i32 @FD_SET(i32 %115, i32* %28)
%117 = load i32, i32* %21
%118 = call i32 @FD_SET(i32 %117, i32* %28)
br label %119
119: ; preds = %113, %129, %153
%120 = load i32, i32* %19
%121 = call i32 @sleep(i32 %120)
%122 = getelementptr inbounds %struct.timeval, %struct.timeval* %29, i32 0, i32 1
store i64 0, i64* %122
%123 = getelementptr inbounds %struct.timeval, %struct.timeval* %29, i32 0, i32 0
store i64 0, i64* %123
store i32 0, i32* %24
%124 = load i32, i32* %21
%125 = add nsw i32 %124, 1
%126 = call i32 @select(i32 %125, i32* %28, i32* null, i32* null, %struct.timeval* %29)
store i32 %126, i32* %24
%127 = load i32, i32* %24
%128 = icmp eq i32 %127, 0
br i1 %128, label %129, label %130
129: ; preds = %119
br label %119
130: ; preds = %119
%131 = load i32, i32* %24
%132 = icmp slt i32 %131, 0
br i1 %132, label %133, label %137
133: ; preds = %130
%134 = load i32, i32* %21
%135 = call i32 @close(i32 %134)
%136 = call i32 @exit(i32 0)
unreachable
137: ; preds = %130
%138 = load i32, i32* %24
%139 = icmp sgt i32 %138, 0
br i1 %139, label %140, label %153
140: ; preds = %137
%141 = load i8*, i8** %27
%142 = call i32 @memset(i8* %141, i32 0, i32 4096)
%143 = load i32, i32* %21
%144 = load i8*, i8** %27
%145 = call i32 @read(i32 %143, i8* %144, i32 4095)
store i32 %145, i32* %23
%146 = load i32, i32* %23
%147 = icmp eq i32 %146, 0
br i1 %147, label %148, label %152
148: ; preds = %140
%149 = load i32, i32* %21
%150 = call i32 @close(i32 %149)
%151 = call i32 @exit(i32 0)
unreachable
152: ; preds = %140
ret i32 0
153: ; preds = %137
br label %119
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.timeval = type { i64, i64 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [15 x i8] c" /v1.0/device/\00"
@.str.1 = [9 x i8] c"/sensor/\00"
@.str.2 = [23 x i8] c"/datapoints HTTP/1.1\0D\0A\00"
@.str.3 = [98 x i8] c"User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:9.0.1) Gecko/20100101 Firefox/9.0.1\0D\0A\00"
@.str.4 = [7 x i8] c"Host: \00"
@.str.5 = [3 x i8] c"\0D\0A\00"
@.str.6 = [14 x i8] c"Accept: */*\0D\0A\00"
@.str.7 = [11 x i8] c"U-ApiKey: \00"
@.str.8 = [3 x i8] c"\0A\0A\00"
@.str.9 = [5 x i8] c"\0D\0A\0D\0A\00"
define i32 @server(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7, i32 %8, i8* %9) {
%11 = alloca %struct.sockaddr_in
%12 = alloca [4096 x i8]
%13 = alloca i32
%14 = alloca %struct.timeval
%15 = bitcast %struct.sockaddr_in* %11 to i8*
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%17 = bitcast i32* %13 to i8*
%18 = bitcast %struct.timeval* %14 to i8*
%19 = load i32, i32* @AF_INET
%20 = load i32, i32* @SOCK_STREAM
%21 = tail call i32 @socket(i32 %19, i32 %20, i32 0)
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %10
%24 = tail call i32 @exit(i32 0)
unreachable
25: ; preds = %10
%26 = call i32 @bzero(%struct.sockaddr_in* %11, i32 12)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i64 0, i32 2
store i32 %27, i32* %28
%29 = tail call i32 @htons(i32 %0)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i64 0, i32 1
store i32 %29, i32* %30
%31 = load i32, i32* @AF_INET
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i64 0, i32 0
%33 = call i64 @inet_pton(i32 %31, i8* %1, i32* %32)
%34 = icmp slt i64 %33, 1
br i1 %34, label %35, label %37
35: ; preds = %25
%36 = call i32 @exit(i32 0)
unreachable
37: ; preds = %25
%38 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%39 = call i64 @connect(i32 %21, %struct.sockaddr* %38, i32 12)
%40 = icmp slt i64 %39, 0
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 @exit(i32 0)
unreachable
43: ; preds = %37
%44 = call i32 @memset(i8* %16, i32 0, i32 4096)
%45 = call i32 @strcat(i8* %16, i8* %6)
%46 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @strcat(i8* %16, i8* %4)
%48 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%49 = call i32 @strcat(i8* %16, i8* %5)
%50 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.3, i64 0, i64 0))
%52 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%53 = call i32 @strcat(i8* %16, i8* %2)
%54 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%55 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%56 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%57 = call i32 @strcat(i8* %16, i8* %3)
%58 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%59 = call i32 @strcat(i8* %16, i8* %7)
%60 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%61 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%62 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%63 = call i32 @strlen(i8* %16)
%64 = call i32 @write(i32 %21, i8* %16, i32 %63)
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %68
66: ; preds = %43
%67 = call i32 @exit(i32 0)
unreachable
68: ; preds = %43
%69 = call i32 @FD_ZERO(i32* %13)
%70 = call i32 @FD_SET(i32 %21, i32* %13)
%71 = call i32 @FD_SET(i32 %21, i32* %13)
%72 = add nuw nsw i32 %21, 1
%73 = bitcast %struct.timeval* %14 to i8*
br label %74
74: ; preds = %74, %68
%75 = call i32 @sleep(i32 %8)
%76 = call i32 @select(i32 %72, i32* %13, i32* null, i32* null, %struct.timeval* %14)
%77 = icmp eq i32 %76, 0
br i1 %77, label %74, label %78
78: ; preds = %74
%79 = icmp slt i32 %76, 0
br i1 %79, label %80, label %83
80: ; preds = %78
%81 = call i32 @close(i32 %21)
%82 = call i32 @exit(i32 0)
unreachable
83: ; preds = %78
%84 = call i32 @memset(i8* %9, i32 0, i32 4096)
%85 = call i32 @read(i32 %21, i8* %9, i32 4095)
%86 = icmp eq i32 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %83
%88 = call i32 @close(i32 %21)
%89 = call i32 @exit(i32 0)
unreachable
90: ; preds = %83
ret i32 0
}