#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 */
typedef int uint64_t;
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ sin4;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ EINPROGRESS;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int /*<<< orphan*/ IPPROTO_TCP;
int O_NONBLOCK;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
scalar_t__ errno;
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_pton(int /*<<< orphan*/, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, ...);
int realtime_now();
int /*<<< orphan*/ sched_yield();
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
double sqrt(double);
int main() {
  int port = 1024 + 1;
  struct sockaddr_in sin4;
  memset(&sin4, 0, sizeof(sin4));
  sin4.sin_family = AF_INET;
  sin4.sin_port = htons(port);
  inet_pton(AF_INET, "127.0.0.1", &(sin4.sin_addr));
  struct sockaddr *sockaddr = (struct sockaddr *)&sin4;
  int sockaddr_len = sizeof(sin4);
  uint64_t ta = realtime_now();
  uint64_t best_td = (uint64_t)-1LL;
  uint64_t sum = 0;
  uint64_t sum_sq = 0;
  int MAX = 16;
  int i;
  for (i = 0; i < MAX; i++) {
    int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
    int flags = fcntl(sd, F_GETFL, 0);
    fcntl(sd, F_SETFL, flags | O_NONBLOCK);
    uint64_t t0 = realtime_now();
    int r = connect(sd, sockaddr, sockaddr_len);
    uint64_t t1 = realtime_now();
    if (r < 0 && errno != EINPROGRESS) {
      perror("connect()");
    }
    close(sd);
    int k;
    for (k = 0; k < 1000; k++) {
      sched_yield();
    }
    sleep(1);
    uint64_t td = t1 - t0;
    if (best_td > td)
      best_td = td;
    printf("took %.3fms\n", td / 1000000.);
    sum += td;
    sum_sq += td * td;
  }
  uint64_t tdd = realtime_now() - ta;
  printf("min=%.3fms tot=%.3fms\n", best_td / 1000000., tdd / 1000000.);
  double avg, dev, var;
  avg = (double)sum / (double)MAX;
  var = ((double)sum_sq / (double)MAX) - (avg * avg);
  dev = sqrt(var);
  printf("min %.3f avg %.3f var %.3f\n", best_td / 1000000., avg / 1000000.,
         dev / 1000000.);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x401,-0x8(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2de8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <htons@plt>
mov    %eax,-0x14(%rbp)
mov    0x2dd1(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rdx
lea    0xde4(%rip),%rsi
call   1090 <inet_pton@plt>
lea    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0xc,-0x24(%rbp)
mov    $0x0,%al
call   10a0 <realtime_now@plt>
mov    %eax,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x10,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    13ba <main+0x1ea>
mov    0x2d28(%rip),%rax
mov    (%rax),%edi
mov    0x2d37(%rip),%rax
mov    (%rax),%esi
mov    0x2d46(%rip),%rax
mov    (%rax),%edx
call   10f0 <socket@plt>
mov    %eax,-0x40(%rbp)
mov    -0x40(%rbp),%edi
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,-0x44(%rbp)
mov    -0x40(%rbp),%edi
mov    0x2d0c(%rip),%rax
mov    (%rax),%esi
mov    -0x44(%rbp),%edx
mov    0x2d20(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
mov    $0x0,%al
call   10a0 <realtime_now@plt>
mov    %eax,-0x48(%rbp)
mov    -0x40(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   10d0 <connect@plt>
mov    %eax,-0x4c(%rbp)
mov    $0x0,%al
call   10a0 <realtime_now@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jge    131d <main+0x14d>
mov    0x2cb2(%rip),%rax
mov    (%rax),%rax
mov    0x2cd0(%rip),%rcx
cmp    (%rcx),%rax
je     131d <main+0x14d>
lea    0xcfa(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x40(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x54(%rbp)
cmpl   $0x3e8,-0x54(%rbp)
jge    134e <main+0x17e>
mov    $0x0,%al
call   1080 <sched_yield@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    132c <main+0x15c>
mov    $0x1,%edi
call   10e0 <sleep@plt>
mov    -0x50(%rbp),%eax
sub    -0x48(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x58(%rbp),%eax
jle    1373 <main+0x1a3>
mov    -0x58(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cvtsi2sdl -0x58(%rbp),%xmm0
movsd  0xc80(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xc8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x58(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x58(%rbp),%eax
imul   -0x58(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1265 <main+0x95>
mov    $0x0,%al
call   10a0 <realtime_now@plt>
sub    -0x28(%rbp),%eax
mov    %eax,-0x5c(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  0xc2c(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
cvtsi2sdl -0x5c(%rbp),%xmm0
movsd  0xc17(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xc35(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
cvtsi2sdl -0x30(%rbp),%xmm0
cvtsi2sdl -0x38(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
cvtsi2sdl -0x34(%rbp),%xmm1
cvtsi2sdl -0x38(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x78(%rbp),%xmm0
call   10c0 <sqrt@plt>
movsd  %xmm0,-0x70(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
movsd  0xb9a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
movsd  -0x68(%rbp),%xmm0
movsd  0xb85(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x70(%rbp),%xmm1
movsd  0xb74(%rip),%xmm2
divsd  %xmm2,%xmm1
lea    0xba9(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0x18(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2def(%rip),%rbx
mov    (%rbx),%eax
mov    %eax,0x20(%rsp)
mov    $0x401,%edi
call   1040 <htons@plt>
mov    %eax,0x1c(%rsp)
mov    (%rbx),%edi
lea    0xdfa(%rip),%rsi
mov    %rbp,%rdx
call   1090 <inet_pton@plt>
xor    %eax,%eax
call   10a0 <realtime_now@plt>
mov    %eax,0x10(%rsp)
mov    $0xffffffff,%r14d
xor    %r13d,%r13d
xor    %ebp,%ebp
xor    %r12d,%r12d
nopw   0x0(%rax,%rax,1)
mov    %ebp,0x8(%rsp)
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
mov    0x2d73(%rip),%rax
mov    (%rax),%edx
call   10f0 <socket@plt>
mov    %eax,%ebp
mov    0x2d3b(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    0x2d41(%rip),%rcx
mov    (%rcx),%esi
mov    0x2d58(%rip),%rcx
or     (%rcx),%eax
mov    %ebp,%edi
mov    %eax,%edx
call   1030 <fcntl@plt>
xor    %eax,%eax
call   10a0 <realtime_now@plt>
mov    %eax,0x14(%rsp)
mov    %ebp,%edi
lea    0x18(%rsp),%rsi
mov    $0xc,%edx
call   10d0 <connect@plt>
mov    %eax,%r15d
xor    %eax,%eax
call   10a0 <realtime_now@plt>
mov    %eax,%ebx
test   %r15d,%r15d
jns    12d6 <main+0x106>
mov    0x2ce9(%rip),%rax
mov    (%rax),%rax
mov    0x2d07(%rip),%rcx
cmp    (%rcx),%rax
jne    134e <main+0x17e>
mov    %ebp,%edi
call   1070 <close@plt>
mov    $0x3e8,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1080 <sched_yield@plt>
add    $0xffffffff,%ebp
jne    12f0 <main+0x120>
mov    $0x1,%edi
call   10e0 <sleep@plt>
sub    0x14(%rsp),%ebx
cmp    %ebx,%r14d
cmovg  %ebx,%r14d
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
divsd  0xce0(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0xcf9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    %ebx,%r13d
imul   %ebx,%ebx
mov    0x8(%rsp),%ebp
add    %ebx,%ebp
add    $0x1,%r12d
cmp    $0x10,%r12d
jne    1240 <main+0x70>
jmp    135f <main+0x18f>
lea    0xcc5(%rip),%rdi
call   10b0 <perror@plt>
jmp    12d6 <main+0x106>
xor    %eax,%eax
call   10a0 <realtime_now@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  0xc8a(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebx
sub    0x10(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  %xmm1,%xmm0
lea    0xc9d(%rip),%rdi
mov    %ebx,%esi
mov    $0x1,%al
call   1050 <printf@plt>
cvtsi2sd %r13d,%xmm2
movsd  0xc5e(%rip),%xmm1
mulsd  %xmm1,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm2,%xmm1
mulsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     13d8 <main+0x208>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
jmp    13ed <main+0x21d>
movsd  %xmm2,0x8(%rsp)
call   10c0 <sqrt@plt>
movsd  0x8(%rsp),%xmm2
movapd %xmm0,%xmm1
movsd  0xc0b(%rip),%xmm0
divsd  %xmm0,%xmm2
divsd  %xmm0,%xmm1
lea    0xc44(%rip),%rdi
mov    %ebx,%esi
movapd %xmm2,%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@errno = global i64 0
@EINPROGRESS = global i64 0
@.str.1 = [10 x i8] c"connect()\00"
@.str.2 = [13 x i8] c"took %.3fms\0A\00"
@.str.3 = [23 x i8] c"min=%.3fms tot=%.3fms\0A\00"
@.str.4 = [28 x i8] c"min %.3f avg %.3f var %.3f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca double
%21 = alloca double
%22 = alloca double
store i32 0, i32* %1
store i32 1025, i32* %2
%23 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 12)
%24 = load i32, i32* @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 2
store i32 %24, i32* %25
%26 = load i32, i32* %2
%27 = call i32 @htons(i32 %26)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
store i32 %27, i32* %28
%29 = load i32, i32* @AF_INET
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%31 = call i32 @inet_pton(i32 %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %30)
%32 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
store %struct.sockaddr* %32, %struct.sockaddr** %4
store i32 12, i32* %5
%33 = call i32 (...) @realtime_now()
store i32 %33, i32* %6
store i32 -1, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 16, i32* %10
store i32 0, i32* %11
br label %34
34: ; preds = %101, %0
%35 = load i32, i32* %11
%36 = load i32, i32* %10
%37 = icmp slt i32 %35, %36
br i1 %37, label %38, label %104
38: ; preds = %34
%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
%43 = load i32, i32* %12
%44 = load i32, i32* @F_GETFL
%45 = call i32 @fcntl(i32 %43, i32 %44, i32 0)
store i32 %45, i32* %13
%46 = load i32, i32* %12
%47 = load i32, i32* @F_SETFL
%48 = load i32, i32* %13
%49 = load i32, i32* @O_NONBLOCK
%50 = or i32 %48, %49
%51 = call i32 @fcntl(i32 %46, i32 %47, i32 %50)
%52 = call i32 (...) @realtime_now()
store i32 %52, i32* %14
%53 = load i32, i32* %12
%54 = load %struct.sockaddr*, %struct.sockaddr** %4
%55 = load i32, i32* %5
%56 = call i32 @connect(i32 %53, %struct.sockaddr* %54, i32 %55)
store i32 %56, i32* %15
%57 = call i32 (...) @realtime_now()
store i32 %57, i32* %16
%58 = load i32, i32* %15
%59 = icmp slt i32 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %38
%61 = load i64, i64* @errno
%62 = load i64, i64* @EINPROGRESS
%63 = icmp ne i64 %61, %62
br i1 %63, label %64, label %66
64: ; preds = %60
%65 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %66
66: ; preds = %64, %60, %38
%67 = load i32, i32* %12
%68 = call i32 @close(i32 %67)
store i32 0, i32* %17
br label %69
69: ; preds = %74, %66
%70 = load i32, i32* %17
%71 = icmp slt i32 %70, 1000
br i1 %71, label %72, label %77
72: ; preds = %69
%73 = call i32 (...) @sched_yield()
br label %74
74: ; preds = %72
%75 = load i32, i32* %17
%76 = add nsw i32 %75, 1
store i32 %76, i32* %17
br label %69
77: ; preds = %69
%78 = call i32 @sleep(i32 1)
%79 = load i32, i32* %16
%80 = load i32, i32* %14
%81 = sub nsw i32 %79, %80
store i32 %81, i32* %18
%82 = load i32, i32* %7
%83 = load i32, i32* %18
%84 = icmp sgt i32 %82, %83
br i1 %84, label %85, label %87
85: ; preds = %77
%86 = load i32, i32* %18
store i32 %86, i32* %7
br label %87
87: ; preds = %85, %77
%88 = load i32, i32* %18
%89 = sitofp i32 %88 to double
%90 = fdiv double %89, 1.000000e+06
%91 = fptosi double %90 to i32
%92 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %91)
%93 = load i32, i32* %18
%94 = load i32, i32* %8
%95 = add nsw i32 %94, %93
store i32 %95, i32* %8
%96 = load i32, i32* %18
%97 = load i32, i32* %18
%98 = mul nsw i32 %96, %97
%99 = load i32, i32* %9
%100 = add nsw i32 %99, %98
store i32 %100, i32* %9
br label %101
101: ; preds = %87
%102 = load i32, i32* %11
%103 = add nsw i32 %102, 1
store i32 %103, i32* %11
br label %34
104: ; preds = %34
%105 = call i32 (...) @realtime_now()
%106 = load i32, i32* %6
%107 = sub nsw i32 %105, %106
store i32 %107, i32* %19
%108 = load i32, i32* %7
%109 = sitofp i32 %108 to double
%110 = fdiv double %109, 1.000000e+06
%111 = fptosi double %110 to i32
%112 = load i32, i32* %19
%113 = sitofp i32 %112 to double
%114 = fdiv double %113, 1.000000e+06
%115 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %111, double %114)
%116 = load i32, i32* %8
%117 = sitofp i32 %116 to double
%118 = load i32, i32* %10
%119 = sitofp i32 %118 to double
%120 = fdiv double %117, %119
store double %120, double* %20
%121 = load i32, i32* %9
%122 = sitofp i32 %121 to double
%123 = load i32, i32* %10
%124 = sitofp i32 %123 to double
%125 = fdiv double %122, %124
%126 = load double, double* %20
%127 = load double, double* %20
%128 = fneg double %126
%129 = call double @llvm.fmuladd.f64(double %128, double %127, double %125)
store double %129, double* %22
%130 = load double, double* %22
%131 = call double @sqrt(double %130)
store double %131, double* %21
%132 = load i32, i32* %7
%133 = sitofp i32 %132 to double
%134 = fdiv double %133, 1.000000e+06
%135 = fptosi double %134 to i32
%136 = load double, double* %20
%137 = fdiv double %136, 1.000000e+06
%138 = load double, double* %21
%139 = fdiv double %138, 1.000000e+06
%140 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %135, double %137, double %139)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@.str = [10 x i8] c"127.0.0.1\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@F_GETFL = global i32 0
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@errno = global i64 0
@EINPROGRESS = global i64 0
@.str.1 = [10 x i8] c"connect()\00"
@.str.2 = [13 x i8] c"took %.3fms\0A\00"
@.str.3 = [23 x i8] c"min=%.3fms tot=%.3fms\0A\00"
@.str.4 = [28 x i8] c"min %.3f avg %.3f var %.3f\0A\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = bitcast %struct.sockaddr_in* %1 to i8*
%3 = call i32 @memset(%struct.sockaddr_in* %1, i32 0, i32 12)
%4 = load i32, i32* @AF_INET
%5 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %4, i32* %5
%6 = call i32 @htons(i32 1025)
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %6, i32* %7
%8 = load i32, i32* @AF_INET
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%10 = call i32 @inet_pton(i32 %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %9)
%11 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%12 = call i32 (...) @realtime_now()
br label %13
13: ; preds = %0, %45
%14 = phi i32 [ -1, %0 ], [ %49, %45 ]
%15 = phi i32 [ 0, %0 ], [ %54, %45 ]
%16 = phi i32 [ 0, %0 ], [ %56, %45 ]
%17 = phi i32 [ 0, %0 ], [ %57, %45 ]
%18 = load i32, i32* @PF_INET
%19 = load i32, i32* @SOCK_STREAM
%20 = load i32, i32* @IPPROTO_TCP
%21 = call i32 @socket(i32 %18, i32 %19, i32 %20)
%22 = load i32, i32* @F_GETFL
%23 = call i32 @fcntl(i32 %21, i32 %22, i32 0)
%24 = load i32, i32* @F_SETFL
%25 = load i32, i32* @O_NONBLOCK
%26 = or i32 %25, %23
%27 = call i32 @fcntl(i32 %21, i32 %24, i32 %26)
%28 = call i32 (...) @realtime_now()
%29 = call i32 @connect(i32 %21, %struct.sockaddr* %11, i32 12)
%30 = call i32 (...) @realtime_now()
%31 = icmp slt i32 %29, 0
br i1 %31, label %32, label %38
32: ; preds = %13
%33 = load i64, i64* @errno
%34 = load i64, i64* @EINPROGRESS
%35 = icmp eq i64 %33, %34
br i1 %35, label %38, label %36
36: ; preds = %32
%37 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %38
38: ; preds = %36, %32, %13
%39 = call i32 @close(i32 %21)
br label %40
40: ; preds = %38, %40
%41 = phi i32 [ 0, %38 ], [ %43, %40 ]
%42 = call i32 (...) @sched_yield()
%43 = add nuw nsw i32 %41, 1
%44 = icmp eq i32 %43, 1000
br i1 %44, label %45, label %40
45: ; preds = %40
%46 = call i32 @sleep(i32 1)
%47 = sub nsw i32 %30, %28
%48 = icmp sgt i32 %14, %47
%49 = select i1 %48, i32 %47, i32 %14
%50 = sitofp i32 %47 to double
%51 = fdiv double %50, 1.000000e+06
%52 = fptosi double %51 to i32
%53 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 %52)
%54 = add nsw i32 %47, %15
%55 = mul nsw i32 %47, %47
%56 = add nuw nsw i32 %55, %16
%57 = add nuw nsw i32 %17, 1
%58 = icmp eq i32 %57, 16
br i1 %58, label %59, label %13
59: ; preds = %45
%60 = call i32 (...) @realtime_now()
%61 = sub nsw i32 %60, %12
%62 = sitofp i32 %49 to double
%63 = fdiv double %62, 1.000000e+06
%64 = fptosi double %63 to i32
%65 = sitofp i32 %61 to double
%66 = fdiv double %65, 1.000000e+06
%67 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %64, double %66)
%68 = sitofp i32 %54 to double
%69 = fmul double %68, 6.250000e-02
%70 = sitofp i32 %56 to double
%71 = fmul double %70, 6.250000e-02
%72 = fneg double %69
%73 = call double @llvm.fmuladd.f64(double %72, double %69, double %71)
%74 = call double @sqrt(double %73)
%75 = fdiv double %69, 1.000000e+06
%76 = fdiv double %74, 1.000000e+06
%77 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0), i32 %64, double %75, double %76)
ret i32 0
}