#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 */
scalar_t__ lw_netmap_recv(int *, void **);
scalar_t__ lw_sock_send_str(int *, char *);
scalar_t__ recv_ok(int *);
int lw_protocol_recv_map(int *sock, void **map) {
  int result = 0;
  if (*sock >= 0 && lw_sock_send_str(sock, "RECVMAP")) {
    if (lw_netmap_recv(sock, map)) {
      if (recv_ok(sock)) {
        result = 1;
      }
    }
  }
  return result;
}


x86 assembly (clang, -O0):
<lw_protocol_recv_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmpl   $0x0,(%rax)
jl     11a9 <lw_protocol_recv_map+0x79>
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
call   1050 <lw_sock_send_str@plt>
cmp    $0x0,%rax
je     11a9 <lw_protocol_recv_map+0x79>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <lw_netmap_recv@plt>
cmp    $0x0,%rax
je     11a4 <lw_protocol_recv_map+0x74>
mov    -0x8(%rbp),%rdi
call   1040 <recv_ok@plt>
cmp    $0x0,%rax
je     119f <lw_protocol_recv_map+0x6f>
movl   $0x1,-0x14(%rbp)
jmp    11a4 <lw_protocol_recv_map+0x74>
jmp    11a9 <lw_protocol_recv_map+0x79>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lw_protocol_recv_map>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
cmpl   $0x0,(%rdi)
js     1173 <lw_protocol_recv_map+0x43>
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xeb8(%rip),%rsi
call   1050 <lw_sock_send_str@plt>
test   %rax,%rax
je     1173 <lw_protocol_recv_map+0x43>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <lw_netmap_recv@plt>
test   %rax,%rax
je     1173 <lw_protocol_recv_map+0x43>
mov    %rbx,%rdi
call   1040 <recv_ok@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"RECVMAP\00"
define i32 @lw_protocol_recv_map(i32* %0, i8** %1) {
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca i32
store i32* %0, i32** %3
store i8** %1, i8*** %4
store i32 0, i32* %5
%6 = load i32*, i32** %3
%7 = load i32, i32* %6
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %25
9: ; preds = %2
%10 = load i32*, i32** %3
%11 = call i64 @lw_sock_send_str(i32* %10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = load i32*, i32** %3
%15 = load i8**, i8*** %4
%16 = call i64 @lw_netmap_recv(i32* %14, i8** %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %13
%19 = load i32*, i32** %3
%20 = call i64 @recv_ok(i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 1, i32* %5
br label %23
23: ; preds = %22, %18
br label %24
24: ; preds = %23, %13
br label %25
25: ; preds = %24, %9, %2
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
@.str = [8 x i8] c"RECVMAP\00"
define i32 @lw_protocol_recv_map(i32* %0, i8** %1) {
%3 = load i32, i32* %0
%4 = icmp sgt i32 %3, -1
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = tail call i64 @lw_sock_send_str(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %5
%9 = tail call i64 @lw_netmap_recv(i32* %0, i8** %1)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = tail call i64 @recv_ok(i32* %0)
%13 = icmp ne i64 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %11, %8, %5, %2
%16 = phi i32 [ 0, %8 ], [ 0, %5 ], [ 0, %2 ], [ %14, %11 ]
ret i32 %16
}