#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
double getWallTime();
int /*<<< orphan*/ recvUntil(int, char *, char);
int send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
double sendAndRecv(int sockfd, char *text, char *response) {
  double rtt;
  if (send(sockfd, text, strlen(text), 0) == -1) {
    exit(0);
    return 0;
  }
  rtt = getWallTime();
  if (!recvUntil(sockfd, response, '\n')) {
    exit(0);
    return 0;
  }
  rtt = getWallTime() - rtt;
  return rtt;
}


x86 assembly (clang, -O0):
<sendAndRecv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
jne    119a <sendAndRecv+0x4a>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1050 <getWallTime@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1060 <recvUntil@plt>
cmp    $0x0,%eax
jne    11c7 <sendAndRecv+0x77>
xor    %edi,%edi
call   1070 <exit@plt>
mov    $0x0,%al
call   1050 <getWallTime@plt>
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendAndRecv>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
je     11b1 <sendAndRecv+0x61>
xor    %eax,%eax
call   1050 <getWallTime@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0xa,%edx
call   1060 <recvUntil@plt>
test   %eax,%eax
je     11b1 <sendAndRecv+0x61>
xor    %eax,%eax
call   1050 <getWallTime@plt>
subsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
define double @sendAndRecv(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca double
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%8 = load i32, i32* %4
%9 = load i8*, i8** %5
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = call i32 @send(i32 %8, i8* %9, i32 %11, i32 0)
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %3
%17 = call double (...) @getWallTime()
store double %17, double* %7
%18 = load i32, i32* %4
%19 = load i8*, i8** %6
%20 = call i32 @recvUntil(i32 %18, i8* %19, i8 signext 10)
%21 = icmp ne i32 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %16
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %16
%25 = call double (...) @getWallTime()
%26 = load double, double* %7
%27 = fsub double %25, %26
store double %27, double* %7
%28 = load double, double* %7
ret double %28
}

LLVM IR (-O2):
define double @sendAndRecv(i32 %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @send(i32 %0, i8* %1, i32 %4, i32 0)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %3
%10 = tail call double (...) @getWallTime()
%11 = tail call i32 @recvUntil(i32 %0, i8* %2, i8 signext 10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = tail call i32 @exit(i32 0)
unreachable
15: ; preds = %9
%16 = tail call double (...) @getWallTime()
%17 = fsub double %16, %10
ret double %17
}