#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
char *strerror(int /*<<< orphan*/);
void _creer_adresse_locale(struct sockaddr_in *adr_local, int num_port,
                           int sock) {
  memset((char *)adr_local, 0, sizeof(*adr_local));
  adr_local->sin_family = AF_INET;
  adr_local->sin_port = htons(num_port);
  adr_local->sin_addr.s_addr = INADDR_ANY;
  if (bind(sock, (struct sockaddr *)adr_local, sizeof(struct sockaddr_in)))
    printf("Echec de la creation de l'adresse locale : %s\n", strerror(errno));
  else
    printf("Succes de la creation de l'adresse locale\n");
}


x86 assembly (clang, -O0):
<_creer_adresse_locale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
mov    0x2e6f(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0xc(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    0x2e46(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    $0xc,%edx
call   1060 <bind@plt>
cmp    $0x0,%rax
je     11e1 <_creer_adresse_locale+0x91>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    %rax,%rsi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11ef <_creer_adresse_locale+0x9f>
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_creer_adresse_locale>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0xc,%edx
call   1060 <memset@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rbx)
mov    %ebp,%edi
call   1040 <htons@plt>
mov    %eax,0x4(%rbx)
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rbx)
mov    %r14d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   1070 <bind@plt>
test   %rax,%rax
je     11d1 <_creer_adresse_locale+0x71>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe3d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <printf@plt>
lea    0xe57(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str = [47 x i8] c"Echec de la creation de l'adresse locale : %s\0A\00"
@errno = global i32 0
@.str.1 = [43 x i8] c"Succes de la creation de l'adresse locale\0A\00"
define void @_creer_adresse_locale(%struct.sockaddr_in* %0, i32 %1, i32 %2) {
%4 = alloca %struct.sockaddr_in*
%5 = alloca i32
%6 = alloca i32
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%8 = bitcast %struct.sockaddr_in* %7 to i8*
%9 = call i32 @memset(i8* %8, i32 0, i32 12)
%10 = load i32, i32* @AF_INET
%11 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %10, i32* %12
%13 = load i32, i32* %5
%14 = call i32 @htons(i32 %13)
%15 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
store i32 %14, i32* %16
%17 = load i32, i32* @INADDR_ANY
%18 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 0
%20 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %19, i32 0, i32 0
store i32 %17, i32* %20
%21 = load i32, i32* %6
%22 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%23 = bitcast %struct.sockaddr_in* %22 to %struct.sockaddr*
%24 = call i64 @bind(i32 %21, %struct.sockaddr* %23, i32 12)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %3
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %32
30: ; preds = %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %32
32: ; preds = %30, %26
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@.str = [47 x i8] c"Echec de la creation de l'adresse locale : %s\0A\00"
@errno = global i32 0
@str = [42 x i8] c"Succes de la creation de l'adresse locale\00"
define void @_creer_adresse_locale(%struct.sockaddr_in* %0, i32 %1, i32 %2) {
%4 = bitcast %struct.sockaddr_in* %0 to i8*
%5 = tail call i32 @memset(i8* %4, i32 0, i32 12)
%6 = load i32, i32* @AF_INET
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 2
store i32 %6, i32* %7
%8 = tail call i32 @htons(i32 %1)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 1
store i32 %8, i32* %9
%10 = load i32, i32* @INADDR_ANY
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0, i32 0
store i32 %10, i32* %11
%12 = bitcast %struct.sockaddr_in* %0 to %struct.sockaddr*
%13 = tail call i64 @bind(i32 %2, %struct.sockaddr* %12, i32 12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %3
%16 = load i32, i32* @errno
%17 = tail call i8* @strerror(i32 %16)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %17)
br label %21
19: ; preds = %3
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %21
21: ; preds = %19, %15
ret void
}