#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*/ abort();
scalar_t__ net_accept(int, int *, int /*<<< orphan*/ *);
scalar_t__ net_bind(int *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ net_close(int);
int /*<<< orphan*/ net_recv(int *, char *, int);
scalar_t__ net_set_block(int);
void receiver(char *msg) {
  int socket1;
  int socket2;
  char message[40];
  if (net_bind(&socket1, NULL, 121212) != 0)
    abort();
  if (net_accept(socket1, &socket2, NULL) != 0)
    abort();
  if (net_set_block(socket2) != 0)
    abort();
  net_recv(&socket2, msg, 40);
  net_close(socket1);
  net_close(socket2);
}


x86 assembly (clang, -O0):
<receiver>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x1d97c,%edx
call   1050 <net_bind@plt>
cmp    $0x0,%rax
je     118f <receiver+0x2f>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0xc(%rbp),%edi
lea    -0x10(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <net_accept@plt>
cmp    $0x0,%rax
je     11b0 <receiver+0x50>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%edi
call   1040 <net_set_block@plt>
cmp    $0x0,%rax
je     11c9 <receiver+0x69>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rsi
lea    -0x10(%rbp),%rdi
mov    $0x28,%edx
call   1070 <net_recv@plt>
mov    -0xc(%rbp),%edi
call   1060 <net_close@plt>
mov    -0x10(%rbp),%edi
call   1060 <net_close@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<receiver>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xc(%rsp),%rdi
xor    %esi,%esi
mov    $0x1d97c,%edx
call   1050 <net_bind@plt>
test   %rax,%rax
jne    11cb <receiver+0x6b>
mov    0xc(%rsp),%edi
lea    0x8(%rsp),%rsi
xor    %edx,%edx
call   1080 <net_accept@plt>
test   %rax,%rax
jne    11cb <receiver+0x6b>
mov    0x8(%rsp),%edi
call   1040 <net_set_block@plt>
test   %rax,%rax
jne    11cb <receiver+0x6b>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x28,%edx
call   1070 <net_recv@plt>
mov    0xc(%rsp),%edi
call   1060 <net_close@plt>
mov    0x8(%rsp),%edi
call   1060 <net_close@plt>
add    $0x10,%rsp
pop    %rbx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define void @receiver(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [40 x i8]
store i8* %0, i8** %2
%6 = call i64 @net_bind(i32* %3, i32* null, i32 121212)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %1
%11 = load i32, i32* %3
%12 = call i64 @net_accept(i32 %11, i32* %4, i32* null)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = call i32 (...) @abort()
unreachable
16: ; preds = %10
%17 = load i32, i32* %4
%18 = call i64 @net_set_block(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %16
%23 = load i8*, i8** %2
%24 = call i32 @net_recv(i32* %4, i8* %23, i32 40)
%25 = load i32, i32* %3
%26 = call i32 @net_close(i32 %25)
%27 = load i32, i32* %4
%28 = call i32 @net_close(i32 %27)
ret void
}

LLVM IR (-O2):
define void @receiver(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %2 to i8*
%5 = bitcast i32* %3 to i8*
%6 = call i64 @net_bind(i32* %2, i32* null, i32 121212)
%7 = icmp eq i64 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = call i32 (...) @abort()
unreachable
10: ; preds = %1
%11 = load i32, i32* %2
%12 = call i64 @net_accept(i32 %11, i32* %3, i32* null)
%13 = icmp eq i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %10
%15 = call i32 (...) @abort()
unreachable
16: ; preds = %10
%17 = load i32, i32* %3
%18 = call i64 @net_set_block(i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %16
%23 = call i32 @net_recv(i32* %3, i8* %0, i32 40)
%24 = load i32, i32* %2
%25 = call i32 @net_close(i32 %24)
%26 = load i32, i32* %3
%27 = call i32 @net_close(i32 %26)
ret void
}