#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 {
  int /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ server_addr;
typedef int /*<<< orphan*/ client_addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ fserver(int, struct sockaddr *, int);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ perror(char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int socketfd;
  struct sockaddr_in server_addr, client_addr;
  char *pname;
  pname = argv[0];
  if ((socketfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    perror("servidor: no se puede abrir el datagrama");
  }
  bzero((char *)&server_addr, sizeof(server_addr));
  server_addr.sin_family = AF_INET;
  server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
  server_addr.sin_port = htons(6544);
  if (bind(socketfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) <
      0) {
    perror("servidor: no se puede unir a la direccion local");
  }
  fserver(socketfd, (struct sockaddr *)&client_addr, sizeof(client_addr));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    0x2e37(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11c2 <main+0x52>
lea    0xe43(%rip),%rdi
call   1070 <perror@plt>
lea    -0x20(%rbp),%rdi
mov    $0xc,%esi
call   1080 <bzero@plt>
mov    0x2e11(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x1990,%edi
call   1030 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   1060 <bind@plt>
cmp    $0x0,%rax
jge    1221 <main+0xb1>
lea    0xe0d(%rip),%rdi
call   1070 <perror@plt>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
mov    $0xc,%edx
call   1050 <fserver@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    0x2e68(%rip),%r15
mov    (%r15),%edi
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
mov    %eax,%ebx
test   %eax,%eax
js     1200 <main+0x90>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xc,%esi
call   1080 <bzero@plt>
mov    (%r15),%eax
mov    %eax,0x8(%rsp)
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1040 <htonl@plt>
mov    %eax,0x4(%rsp)
mov    $0x1990,%edi
call   1030 <htons@plt>
mov    %eax,(%rsp)
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0xc,%edx
call   1060 <bind@plt>
test   %rax,%rax
js     120e <main+0x9e>
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   1050 <fserver@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xdf9(%rip),%rdi
call   1070 <perror@plt>
jmp    1199 <main+0x29>
lea    0xe14(%rip),%rdi
call   1070 <perror@plt>
jmp    11e3 <main+0x73>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [41 x i8] c"servidor: no se puede abrir el datagrama\00"
@INADDR_ANY = global i32 0
@.str.1 = [48 x i8] c"servidor: no se puede unir a la direccion local\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca %struct.sockaddr_in
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
store i8* %12, i8** %9
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @SOCK_DGRAM
%15 = call i32 @socket(i32 %13, i32 %14, i32 0)
store i32 %15, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %2
%20 = bitcast %struct.sockaddr_in* %7 to i8*
%21 = call i32 @bzero(i8* %20, i32 12)
%22 = load i32, i32* @AF_INET
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
store i32 %22, i32* %23
%24 = load i32, i32* @INADDR_ANY
%25 = call i32 @htonl(i32 %24)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
%27 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %26, i32 0, i32 0
store i32 %25, i32* %27
%28 = call i32 @htons(i32 6544)
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %28, i32* %29
%30 = load i32, i32* %6
%31 = bitcast %struct.sockaddr_in* %7 to %struct.sockaddr*
%32 = call i64 @bind(i32 %30, %struct.sockaddr* %31, i32 12)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %19
%35 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
br label %36
36: ; preds = %34, %19
%37 = load i32, i32* %6
%38 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%39 = call i32 @fserver(i32 %37, %struct.sockaddr* %38, i32 12)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [41 x i8] c"servidor: no se puede abrir el datagrama\00"
@INADDR_ANY = global i32 0
@.str.1 = [48 x i8] c"servidor: no se puede unir a la direccion local\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = bitcast %struct.sockaddr_in* %3 to i8*
%6 = bitcast %struct.sockaddr_in* %4 to i8*
%7 = load i32, i32* @AF_INET
%8 = load i32, i32* @SOCK_DGRAM
%9 = tail call i32 @socket(i32 %7, i32 %8, i32 0)
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @perror(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = call i32 @bzero(i8* %5, i32 12)
%15 = load i32, i32* @AF_INET
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %15, i32* %16
%17 = load i32, i32* @INADDR_ANY
%18 = tail call i32 @htonl(i32 %17)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %18, i32* %19
%20 = tail call i32 @htons(i32 6544)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %20, i32* %21
%22 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%23 = call i64 @bind(i32 %9, %struct.sockaddr* %22, i32 12)
%24 = icmp slt i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %13
%26 = call i32 @perror(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %25, %13
%28 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%29 = call i32 @fserver(i32 %9, %struct.sockaddr* %28, i32 12)
ret i32 0
}