#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*/, int, 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*/);
char *server(int port, int IP, char *API_URL, char *API_KEY, char *DEVICE_NUM,
             char *DEVICE_SENSOR, char *way, char *POST_char, int time) {
  int sockfd, ret, i, h;
  struct sockaddr_in servaddr;
  char str1[4096], buf[1024];
  fd_set t_set1;
  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) {
      close(sockfd);
      return "-1";
    }
    if (h > 0) {
      memset(buf, 0, 4096);
      i = read(sockfd, buf, 4095);
      if (i == 0) {
        close(sockfd);
        return buf;
      }
      return buf;
    }
  }
  close(sockfd);
  return buf;
}


x86 assembly (clang, -O0):
<server>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1480,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    0x2db5(%rip),%rax
mov    (%rax),%edi
mov    0x2d9c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x34(%rbp)
cmp    $0x0,%eax
jge    1258 <server+0x58>
xor    %edi,%edi
call   10e0 <exit@plt>
lea    -0x50(%rbp),%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x4c(%rbp)
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%esi
lea    -0x50(%rbp),%rdx
call   1090 <inet_pton@plt>
cmp    $0x0,%rax
jg     12a3 <server+0xa3>
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    12c5 <server+0xc5>
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    0xd0a(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xcf6(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xcdc(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xce0(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xd2f(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xd31(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xd00(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xcfb(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xce8(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
mov    0x18(%rbp),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xcc0(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xcb0(%rip),%rsi
call   10d0 <strcat@plt>
lea    -0x1050(%rbp),%rdi
lea    0xc9d(%rip),%rsi
call   10d0 <strcat@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x1474(%rbp)
lea    -0x1050(%rbp),%rax
mov    %rax,-0x1470(%rbp)
lea    -0x1050(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1474(%rbp),%edi
mov    -0x1470(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jge    1467 <server+0x267>
xor    %edi,%edi
call   10e0 <exit@plt>
jmp    146c <server+0x26c>
lea    -0x1454(%rbp),%rdi
call   10a0 <FD_ZERO@plt>
mov    -0x34(%rbp),%edi
lea    -0x1454(%rbp),%rsi
call   1100 <FD_SET@plt>
mov    -0x34(%rbp),%edi
lea    -0x1454(%rbp),%rsi
call   1100 <FD_SET@plt>
mov    0x20(%rbp),%edi
call   1110 <sleep@plt>
movq   $0x0,-0x1460(%rbp)
movq   $0x0,-0x1468(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x34(%rbp),%edi
add    $0x1,%edi
lea    -0x1454(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x1468(%rbp),%r8
mov    %rcx,%rdx
call   10b0 <select@plt>
mov    %eax,-0x40(%rbp)
cmpl   $0x0,-0x40(%rbp)
jge    1500 <server+0x300>
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
lea    0xbc2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    156b <server+0x36b>
cmpl   $0x0,-0x40(%rbp)
jle    1566 <server+0x366>
lea    -0x1450(%rbp),%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
mov    -0x34(%rbp),%edi
lea    -0x1450(%rbp),%rsi
mov    $0xfff,%edx
call   1080 <read@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1556 <server+0x356>
mov    -0x34(%rbp),%edi
call   1070 <close@plt>
lea    -0x1450(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    156b <server+0x36b>
lea    -0x1450(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    156b <server+0x36b>
jmp    1496 <server+0x296>
mov    -0x8(%rbp),%rax
add    $0x1480,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<server>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1448,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,%r13
mov    %rcx,0x20(%rsp)
mov    %rdx,0x18(%rsp)
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2dba(%rip),%r12
mov    (%r12),%edi
mov    0x2d9f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
test   %eax,%eax
js     148c <server+0x28c>
mov    %eax,%r14d
mov    %rsp,%r15
mov    %r15,%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    (%r12),%eax
mov    %eax,0x8(%rsp)
mov    %ebp,%edi
call   1050 <htons@plt>
mov    %eax,0x4(%rsp)
mov    (%r12),%edi
mov    %ebx,%esi
mov    %r15,%rdx
call   1090 <inet_pton@plt>
test   %rax,%rax
jle    148c <server+0x28c>
mov    %rsp,%rsi
mov    %r14d,%edi
mov    $0xc,%edx
call   10f0 <connect@plt>
test   %rax,%rax
js     148c <server+0x28c>
mov    0x1488(%rsp),%r15
mov    0x1480(%rsp),%rbp
lea    0x440(%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    0xd37(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10d0 <strcat@plt>
lea    0xd2c(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
call   10d0 <strcat@plt>
lea    0xd19(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xd21(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xd74(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
call   10d0 <strcat@plt>
lea    0xd7d(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
call   10d0 <strcat@plt>
lea    0xd4d(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xd4c(%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    %r15,%rsi
call   10d0 <strcat@plt>
lea    0xd25(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <strcat@plt>
lea    0xd19(%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    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %eax,%eax
js     148c <server+0x28c>
mov    0x1490(%rsp),%r12d
lea    0x2c(%rsp),%r13
mov    %r13,%rdi
call   10a0 <FD_ZERO@plt>
mov    %r14d,%edi
mov    %r13,%rsi
call   1100 <FD_SET@plt>
mov    %r14d,%edi
mov    %r13,%rsi
call   1100 <FD_SET@plt>
mov    %r14d,%ebp
add    $0x1,%ebp
lea    0x30(%rsp),%rbx
lea    0xcae(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
call   1110 <sleep@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
mov    %ebp,%edi
mov    %r13,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
call   10b0 <select@plt>
test   %eax,%eax
js     146f <server+0x26f>
je     1420 <server+0x220>
lea    0x40(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1000,%edx
call   1060 <memset@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    $0xfff,%edx
call   1080 <read@plt>
test   %eax,%eax
jne    1477 <server+0x277>
mov    %r14d,%edi
call   1070 <close@plt>
mov    %r15,%rax
add    $0x1448,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
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"
@.str.10 = [3 x i8] c"-1\00"
define i8* @server(i32 %0, i32 %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7, i32 %8) {
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca %struct.sockaddr_in
%25 = alloca [4096 x i8]
%26 = alloca [1024 x i8]
%27 = alloca i32
%28 = alloca %struct.timeval
store i32 %0, i32* %11
store i32 %1, i32* %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
%29 = load i32, i32* @AF_INET
%30 = load i32, i32* @SOCK_STREAM
%31 = call i32 @socket(i32 %29, i32 %30, i32 0)
store i32 %31, i32* %20
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %9
%34 = call i32 @exit(i32 0)
unreachable
35: ; preds = %9
%36 = call i32 @bzero(%struct.sockaddr_in* %24, i32 12)
%37 = load i32, i32* @AF_INET
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %24, i32 0, i32 2
store i32 %37, i32* %38
%39 = load i32, i32* %11
%40 = call i32 @htons(i32 %39)
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %24, i32 0, i32 1
store i32 %40, i32* %41
%42 = load i32, i32* @AF_INET
%43 = load i32, i32* %12
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %24, i32 0, i32 0
%45 = call i64 @inet_pton(i32 %42, i32 %43, i32* %44)
%46 = icmp sle i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %35
%48 = call i32 @exit(i32 0)
unreachable
49: ; preds = %35
%50 = load i32, i32* %20
%51 = bitcast %struct.sockaddr_in* %24 to %struct.sockaddr*
%52 = call i64 @connect(i32 %50, %struct.sockaddr* %51, i32 12)
%53 = icmp slt i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %49
%55 = call i32 @exit(i32 0)
unreachable
56: ; preds = %49
%57 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%58 = call i32 @memset(i8* %57, i32 0, i32 4096)
%59 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%60 = load i8*, i8** %17
%61 = call i32 @strcat(i8* %59, i8* %60)
%62 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%63 = call i32 @strcat(i8* %62, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%64 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%65 = load i8*, i8** %15
%66 = call i32 @strcat(i8* %64, i8* %65)
%67 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%68 = call i32 @strcat(i8* %67, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%69 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%70 = load i8*, i8** %16
%71 = call i32 @strcat(i8* %69, i8* %70)
%72 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%73 = call i32 @strcat(i8* %72, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%74 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%75 = call i32 @strcat(i8* %74, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.3, i64 0, i64 0))
%76 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%77 = call i32 @strcat(i8* %76, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%78 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%79 = load i8*, i8** %13
%80 = call i32 @strcat(i8* %78, i8* %79)
%81 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%82 = call i32 @strcat(i8* %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%83 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%84 = call i32 @strcat(i8* %83, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%85 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%86 = call i32 @strcat(i8* %85, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%87 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%88 = load i8*, i8** %14
%89 = call i32 @strcat(i8* %87, i8* %88)
%90 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%91 = call i32 @strcat(i8* %90, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%92 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%93 = load i8*, i8** %18
%94 = call i32 @strcat(i8* %92, i8* %93)
%95 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%96 = call i32 @strcat(i8* %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0))
%97 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%98 = call i32 @strcat(i8* %97, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%99 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, 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 = load i32, i32* %20
%102 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%103 = getelementptr inbounds [4096 x i8], [4096 x i8]* %25, i64 0, i64 0
%104 = call i32 @strlen(i8* %103)
%105 = call i32 @write(i32 %101, i8* %102, i32 %104)
store i32 %105, i32* %21
%106 = load i32, i32* %21
%107 = icmp slt i32 %106, 0
br i1 %107, label %108, label %110
108: ; preds = %56
%109 = call i32 @exit(i32 0)
unreachable
110: ; preds = %56
br label %111
111: ; preds = %110
%112 = call i32 @FD_ZERO(i32* %27)
%113 = load i32, i32* %20
%114 = call i32 @FD_SET(i32 %113, i32* %27)
%115 = load i32, i32* %20
%116 = call i32 @FD_SET(i32 %115, i32* %27)
br label %117
117: ; preds = %111, %147
%118 = load i32, i32* %19
%119 = call i32 @sleep(i32 %118)
%120 = getelementptr inbounds %struct.timeval, %struct.timeval* %28, i32 0, i32 1
store i64 0, i64* %120
%121 = getelementptr inbounds %struct.timeval, %struct.timeval* %28, i32 0, i32 0
store i64 0, i64* %121
store i32 0, i32* %23
%122 = load i32, i32* %20
%123 = add nsw i32 %122, 1
%124 = call i32 @select(i32 %123, i32* %27, i32* null, i32* null, %struct.timeval* %28)
store i32 %124, i32* %23
%125 = load i32, i32* %23
%126 = icmp slt i32 %125, 0
br i1 %126, label %127, label %130
127: ; preds = %117
%128 = load i32, i32* %20
%129 = call i32 @close(i32 %128)
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), i8** %10
br label %148
130: ; preds = %117
%131 = load i32, i32* %23
%132 = icmp sgt i32 %131, 0
br i1 %132, label %133, label %147
133: ; preds = %130
%134 = getelementptr inbounds [1024 x i8], [1024 x i8]* %26, i64 0, i64 0
%135 = call i32 @memset(i8* %134, i32 0, i32 4096)
%136 = load i32, i32* %20
%137 = getelementptr inbounds [1024 x i8], [1024 x i8]* %26, i64 0, i64 0
%138 = call i32 @read(i32 %136, i8* %137, i32 4095)
store i32 %138, i32* %22
%139 = load i32, i32* %22
%140 = icmp eq i32 %139, 0
br i1 %140, label %141, label %145
141: ; preds = %133
%142 = load i32, i32* %20
%143 = call i32 @close(i32 %142)
%144 = getelementptr inbounds [1024 x i8], [1024 x i8]* %26, i64 0, i64 0
store i8* %144, i8** %10
br label %148
145: ; preds = %133
%146 = getelementptr inbounds [1024 x i8], [1024 x i8]* %26, i64 0, i64 0
store i8* %146, i8** %10
br label %148
147: ; preds = %130
br label %117
148: ; preds = %145, %141, %127
%149 = load i8*, i8** %10
ret i8* %149
}

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"
@.str.10 = [3 x i8] c"-1\00"
define i8* @server(i32 %0, i32 %1, i8* %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7, i32 %8) {
%10 = alloca %struct.sockaddr_in
%11 = alloca [4096 x i8]
%12 = alloca [1024 x i8]
%13 = alloca i32
%14 = alloca %struct.timeval
%15 = bitcast %struct.sockaddr_in* %10 to i8*
%16 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%18 = bitcast i32* %13 to i8*
%19 = bitcast %struct.timeval* %14 to i8*
%20 = load i32, i32* @AF_INET
%21 = load i32, i32* @SOCK_STREAM
%22 = tail call i32 @socket(i32 %20, i32 %21, i32 0)
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %9
%25 = tail call i32 @exit(i32 0)
unreachable
26: ; preds = %9
%27 = call i32 @bzero(%struct.sockaddr_in* %10, i32 12)
%28 = load i32, i32* @AF_INET
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i64 0, i32 2
store i32 %28, i32* %29
%30 = tail call i32 @htons(i32 %0)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i64 0, i32 1
store i32 %30, i32* %31
%32 = load i32, i32* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i64 0, i32 0
%34 = call i64 @inet_pton(i32 %32, i32 %1, i32* %33)
%35 = icmp slt i64 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %26
%37 = call i32 @exit(i32 0)
unreachable
38: ; preds = %26
%39 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%40 = call i64 @connect(i32 %22, %struct.sockaddr* %39, i32 12)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 @exit(i32 0)
unreachable
44: ; preds = %38
%45 = call i32 @memset(i8* %16, i32 0, i32 4096)
%46 = call i32 @strcat(i8* %16, i8* %6)
%47 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%48 = call i32 @strcat(i8* %16, i8* %4)
%49 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%50 = call i32 @strcat(i8* %16, i8* %5)
%51 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%52 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([98 x i8], [98 x i8]* @.str.3, i64 0, i64 0))
%53 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
%54 = call i32 @strcat(i8* %16, i8* %2)
%55 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%56 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%57 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%58 = call i32 @strcat(i8* %16, i8* %3)
%59 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%60 = call i32 @strcat(i8* %16, i8* %7)
%61 = call i32 @strcat(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, 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 @strcat(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%64 = call i32 @strlen(i8* %16)
%65 = call i32 @write(i32 %22, i8* %16, i32 %64)
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %44
%68 = call i32 @exit(i32 0)
unreachable
69: ; preds = %44
%70 = call i32 @FD_ZERO(i32* %13)
%71 = call i32 @FD_SET(i32 %22, i32* %13)
%72 = call i32 @FD_SET(i32 %22, i32* %13)
%73 = add nuw nsw i32 %22, 1
%74 = bitcast %struct.timeval* %14 to i8*
br label %75
75: ; preds = %79, %69
%76 = call i32 @sleep(i32 %8)
%77 = call i32 @select(i32 %73, i32* %13, i32* null, i32* null, %struct.timeval* %14)
%78 = icmp slt i32 %77, 0
br i1 %78, label %85, label %79
79: ; preds = %75
%80 = icmp eq i32 %77, 0
br i1 %80, label %75, label %81
81: ; preds = %79
%82 = call i32 @memset(i8* %17, i32 0, i32 4096)
%83 = call i32 @read(i32 %22, i8* %17, i32 4095)
%84 = icmp eq i32 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %75, %81
%86 = phi i8* [ %17, %81 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0), %75 ]
%87 = call i32 @close(i32 %22)
br label %88
88: ; preds = %85, %81
%89 = phi i8* [ %17, %81 ], [ %86, %85 ]
ret i8* %89
}