#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;
scalar_t__ CreerSockAddr(char *, int);
int /*<<< orphan*/ SOCK_DGRAM;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ perror(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int SockUdp(char *nom, int numport) {
  int sock;
  struct sockaddr_in *adsock =
      (struct sockaddr_in *)CreerSockAddr(nom, numport);
  if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) <= 0) {
    perror("\n pb creation socket \n");
  }
  if (bind(sock, (struct sockaddr *)adsock, sizeof(*adsock)) < 0) {
    perror("\n pb bind");
  }
  return (sock);
}


x86 assembly (clang, -O0):
<SockUdp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <CreerSockAddr@plt>
mov    %rax,-0x18(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
mov    %eax,-0x10(%rbp)
cmp    $0x0,%eax
jg     1190 <SockUdp+0x50>
lea    0xe75(%rip),%rdi
call   1050 <perror@plt>
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <bind@plt>
cmp    $0x0,%rax
jge    11b7 <SockUdp+0x77>
lea    0xe65(%rip),%rdi
call   1050 <perror@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SockUdp>:
push   %r14
push   %rbx
push   %rax
call   1030 <CreerSockAddr@plt>
mov    %rax,%r14
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
mov    0x2e84(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1060 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
jle    1189 <SockUdp+0x49>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x4,%edx
call   1040 <bind@plt>
test   %rax,%rax
js     1197 <SockUdp+0x57>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe70(%rip),%rdi
call   1050 <perror@plt>
jmp    116b <SockUdp+0x2b>
lea    0xe79(%rip),%rdi
call   1050 <perror@plt>
jmp    117f <SockUdp+0x3f>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [23 x i8] c"\0A pb creation socket \0A\00"
@.str.1 = [10 x i8] c"\0A pb bind\00"
define i32 @SockUdp(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_in*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = load i32, i32* %4
%9 = call i64 @CreerSockAddr(i8* %7, i32 %8)
%10 = inttoptr i64 %9 to %struct.sockaddr_in*
store %struct.sockaddr_in* %10, %struct.sockaddr_in** %6
%11 = load i32, i32* @AF_INET
%12 = load i32, i32* @SOCK_DGRAM
%13 = call i32 @socket(i32 %11, i32 %12, i32 0)
store i32 %13, i32* %5
%14 = icmp sle i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %2
%18 = load i32, i32* %5
%19 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%20 = bitcast %struct.sockaddr_in* %19 to %struct.sockaddr*
%21 = call i64 @bind(i32 %18, %struct.sockaddr* %20, i32 4)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %17
%26 = load i32, i32* %5
ret i32 %26
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [23 x i8] c"\0A pb creation socket \0A\00"
@.str.1 = [10 x i8] c"\0A pb bind\00"
define i32 @SockUdp(i8* %0, i32 %1) {
%3 = tail call i64 @CreerSockAddr(i8* %0, i32 %1)
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_DGRAM
%6 = tail call i32 @socket(i32 %4, i32 %5, i32 0)
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = inttoptr i64 %3 to %struct.sockaddr*
%12 = tail call i64 @bind(i32 %6, %struct.sockaddr* %11, i32 4)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = tail call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %14, %10
ret i32 %6
}