#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*/ error(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ recv(int, char *, int, int /*<<< orphan*/);
char *recv_(int sock) {
  char *buf = malloc(0x201);
  if (!buf) {
    error("malloc error");
  }
  memset(buf, 0, 0x201);
  if (!recv(sock, buf, 0x200, 0)) {
    error("receive error");
  }
  return buf;
}


x86 assembly (clang, -O0):
<recv_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x201,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1170 <recv_+0x30>
lea    0xe95(%rip),%rdi
call   1060 <error@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x201,%edx
call   1040 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%eax
jne    11a8 <recv_+0x68>
lea    0xe6a(%rip),%rdi
call   1060 <error@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recv_>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x201,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1163 <recv_+0x23>
lea    0xea2(%rip),%rdi
call   1060 <error@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x201,%edx
call   1040 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jne    1193 <recv_+0x53>
lea    0xe7f(%rip),%rdi
call   1060 <error@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"malloc error\00"
@.str.1 = [14 x i8] c"receive error\00"
define i8* @recv_(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = call i8* @malloc(i32 513)
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = load i8*, i8** %3
%11 = call i32 @memset(i8* %10, i32 0, i32 513)
%12 = load i32, i32* %2
%13 = load i8*, i8** %3
%14 = call i32 @recv(i32 %12, i8* %13, i32 512, i32 0)
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %9
%17 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %9
%19 = load i8*, i8** %3
ret i8* %19
}

LLVM IR (-O2):
@.str = [13 x i8] c"malloc error\00"
@.str.1 = [14 x i8] c"receive error\00"
define i8* @recv_(i32 %0) {
%2 = tail call dereferenceable_or_null(513) i8* @malloc(i32 513)
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @error(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = tail call i32 @memset(i8* %2, i32 0, i32 513)
%8 = tail call i32 @recv(i32 %0, i8* %2, i32 512, i32 0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %6
ret i8* %2
}