#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 recv(int, char *, int, int /*<<< orphan*/);
scalar_t__ send(int, char const *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
int client_send_reply(int sock, const char *message, char *result,
                      int result_len) {
  int len;
  if (send(sock, message, strlen(message), 0) < 0) {
    ;
    return -1;
  }
  if ((len = recv(sock, result, result_len, 0)) < 0) {
    ;
    return -1;
  } else {
    return len;
  }
}


x86 assembly (clang, -O0):
<client_send_reply>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
cmp    $0x0,%rax
jge    1183 <client_send_reply+0x53>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b2 <client_send_reply+0x82>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    11ac <client_send_reply+0x7c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b2 <client_send_reply+0x82>
mov    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client_send_reply>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
test   %rax,%rax
js     117a <client_send_reply+0x4a>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,%ecx
test   %eax,%eax
mov    $0xffffffff,%eax
cmovns %ecx,%eax
jmp    117f <client_send_reply+0x4f>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @client_send_reply(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%11 = load i32, i32* %6
%12 = load i8*, i8** %7
%13 = load i8*, i8** %7
%14 = call i32 @strlen(i8* %13)
%15 = call i64 @send(i32 %11, i8* %12, i32 %14, i32 0)
%16 = icmp slt i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %4
store i32 -1, i32* %5
br label %27
18: ; preds = %4
%19 = load i32, i32* %6
%20 = load i8*, i8** %8
%21 = load i32, i32* %9
%22 = call i32 @recv(i32 %19, i8* %20, i32 %21, i32 0)
store i32 %22, i32* %10
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %18
store i32 -1, i32* %5
br label %27
25: ; preds = %18
%26 = load i32, i32* %10
store i32 %26, i32* %5
br label %27
27: ; preds = %25, %24, %17
%28 = load i32, i32* %5
ret i32 %28
}

LLVM IR (-O2):
define i32 @client_send_reply(i32 %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %1)
%6 = tail call i64 @send(i32 %0, i8* %1, i32 %5, i32 0)
%7 = icmp slt i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %4
%9 = tail call i32 @recv(i32 %0, i8* %2, i32 %3, i32 0)
%10 = icmp sgt i32 %9, -1
%11 = select i1 %10, i32 %9, i32 -1
br label %12
12: ; preds = %8, %4
%13 = phi i32 [ -1, %4 ], [ %11, %8 ]
ret i32 %13
}