#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 */
struct sockaddr_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ listen(int, int);
int /*<<< orphan*/ perror(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int init_serveur(struct sockaddr_in *server) {
  int ma_socket;
  ma_socket = socket(AF_INET, SOCK_STREAM, 0);
  if (ma_socket == -1) {
    perror("impossible de creer ton socket de merde\n");
    exit(errno);
  }
  if (bind(ma_socket, (struct sockaddr *)server, sizeof *server) < 0) {
    perror("impossible de joindre les deux bouts\n");
    exit(errno);
  }
  if (listen(ma_socket, 5) < 0) {
    perror("can't listen, je suis sourd\n");
    exit(errno);
  }
  return ma_socket;
}


x86 assembly (clang, -O0):
<init_serveur>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    0x2e6c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    119c <init_serveur+0x4c>
lea    0xe77(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1040 <bind@plt>
cmp    $0x0,%rax
jge    11d1 <init_serveur+0x81>
lea    0xe6b(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%edi
mov    $0x5,%esi
call   1030 <listen@plt>
cmp    $0x0,%rax
jge    1202 <init_serveur+0xb2>
lea    0xe60(%rip),%rdi
call   1050 <perror@plt>
mov    0x2dd5(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_serveur>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1070 <socket@plt>
cmp    $0xffffffff,%eax
je     11a6 <init_serveur+0x56>
mov    %eax,%ebx
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1040 <bind@plt>
test   %rax,%rax
js     11af <init_serveur+0x5f>
mov    %ebx,%edi
mov    $0x5,%esi
call   1030 <listen@plt>
test   %rax,%rax
js     11b8 <init_serveur+0x68>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe53(%rip),%rdi
jmp    11bf <init_serveur+0x6f>
lea    0xe73(%rip),%rdi
jmp    11bf <init_serveur+0x6f>
lea    0xe90(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [41 x i8] c"impossible de creer ton socket de merde\0A\00"
@errno = global i32 0
@.str.1 = [38 x i8] c"impossible de joindre les deux bouts\0A\00"
@.str.2 = [29 x i8] c"can't listen, je suis sourd\0A\00"
define i32 @init_serveur(%struct.sockaddr_in* %0) {
%2 = alloca %struct.sockaddr_in*
%3 = alloca i32
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %2
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_STREAM
%6 = call i32 @socket(i32 %4, i32 %5, i32 0)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @errno
%12 = call i32 @exit(i32 %11)
unreachable
13: ; preds = %1
%14 = load i32, i32* %3
%15 = load %struct.sockaddr_in*, %struct.sockaddr_in** %2
%16 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%17 = call i64 @bind(i32 %14, %struct.sockaddr* %16, i32 4)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @errno
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %13
%24 = load i32, i32* %3
%25 = call i64 @listen(i32 %24, i32 5)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %31
27: ; preds = %23
%28 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%29 = load i32, i32* @errno
%30 = call i32 @exit(i32 %29)
unreachable
31: ; preds = %23
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [41 x i8] c"impossible de creer ton socket de merde\0A\00"
@errno = global i32 0
@.str.1 = [38 x i8] c"impossible de joindre les deux bouts\0A\00"
@.str.2 = [29 x i8] c"can't listen, je suis sourd\0A\00"
define i32 @init_serveur(%struct.sockaddr_in* %0) {
%2 = load i32, i32* @AF_INET
%3 = load i32, i32* @SOCK_STREAM
%4 = tail call i32 @socket(i32 %2, i32 %3, i32 0)
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = tail call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @errno
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %1
%11 = bitcast %struct.sockaddr_in* %0 to %struct.sockaddr*
%12 = tail call i64 @bind(i32 %4, %struct.sockaddr* %11, i32 4)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = tail call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @errno
%17 = tail call i32 @exit(i32 %16)
unreachable
18: ; preds = %10
%19 = tail call i64 @listen(i32 %4, i32 5)
%20 = icmp slt i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %18
%22 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @errno
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %18
ret i32 %4
}