#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 get_conn_fd(int /*<<< orphan*/, int);
int /*<<< orphan*/ inet_addr(char *);
int mdaq_net_recv2(int, void *, unsigned int, int);
void SocketRecv(char *ip, int port, unsigned char *data, int *status,
                unsigned int size, unsigned char blocking) {
  int fd = get_conn_fd(inet_addr(ip), port);
  if (fd > -1)
    *status = mdaq_net_recv2(fd, (void *)data, size, blocking ? 0 : 0x40);
}


x86 assembly (clang, -O0):
<SocketRecv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r9b,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %al,-0x25(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <inet_addr@plt>
mov    %eax,%edi
mov    -0xc(%rbp),%esi
call   1030 <get_conn_fd@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jle    119b <SocketRecv+0x6b>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x24(%rbp),%edx
movzbl -0x25(%rbp),%r8d
mov    $0x40,%ecx
xor    %eax,%eax
cmp    $0x0,%r8d
cmovne %eax,%ecx
call   1050 <mdaq_net_recv2@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SocketRecv>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9d,%ebp
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %rdx,%r12
mov    %esi,%ebx
call   1040 <inet_addr@plt>
mov    %eax,%edi
mov    %ebx,%esi
call   1030 <get_conn_fd@plt>
test   %eax,%eax
js     1173 <SocketRecv+0x43>
xor    %ecx,%ecx
test   %bpl,%bpl
sete   %cl
shl    $0x6,%ecx
mov    %eax,%edi
mov    %r12,%rsi
mov    %r15d,%edx
call   1050 <mdaq_net_recv2@plt>
mov    %eax,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @SocketRecv(i8* %0, i32 %1, i8* %2, i32* %3, i32 %4, i8 zeroext %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i8
%13 = alloca i32
store i8* %0, i8** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i32* %3, i32** %10
store i32 %4, i32* %11
store i8 %5, i8* %12
%14 = load i8*, i8** %7
%15 = call i32 @inet_addr(i8* %14)
%16 = load i32, i32* %8
%17 = call i32 @get_conn_fd(i32 %15, i32 %16)
store i32 %17, i32* %13
%18 = load i32, i32* %13
%19 = icmp sgt i32 %18, -1
br i1 %19, label %20, label %31
20: ; preds = %6
%21 = load i32, i32* %13
%22 = load i8*, i8** %9
%23 = load i32, i32* %11
%24 = load i8, i8* %12
%25 = zext i8 %24 to i32
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i32 0, i32 64
%29 = call i32 @mdaq_net_recv2(i32 %21, i8* %22, i32 %23, i32 %28)
%30 = load i32*, i32** %10
store i32 %29, i32* %30
br label %31
31: ; preds = %20, %6
ret void
}

LLVM IR (-O2):
define void @SocketRecv(i8* %0, i32 %1, i8* %2, i32* nocapture writeonly %3, i32 %4, i8 zeroext %5) {
%7 = tail call i32 @inet_addr(i8* %0)
%8 = tail call i32 @get_conn_fd(i32 %7, i32 %1)
%9 = icmp sgt i32 %8, -1
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = icmp eq i8 %5, 0
%12 = select i1 %11, i32 64, i32 0
%13 = tail call i32 @mdaq_net_recv2(i32 %8, i8* %2, i32 %4, i32 %12)
store i32 %13, i32* %3
br label %14
14: ; preds = %10, %6
ret void
}