#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 {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ sbuf;
typedef int /*<<< orphan*/ hbufnum;
typedef int /*<<< orphan*/ hbufnombre;

/* Variables and functions */
int NI_DGRAM;
int NI_MAXHOST;
int NI_MAXSERV;
int NI_NAMEREQD;
int NI_NUMERICHOST;
int NI_NUMERICSERV;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
char *gai_strerror(int);
int getnameinfo(struct sockaddr const *, int /*<<< orphan*/, char *, int,
                char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
void imprime_extremo_conexion(const struct sockaddr *direccion, socklen_t len,
                              int tipo) {
  char hbufnum[NI_MAXHOST];
  char hbufnombre[NI_MAXHOST];
  char sbuf[NI_MAXSERV];
  int opciones = NI_NUMERICHOST | NI_NUMERICSERV;
  int error = 0;
  if (tipo == 0) {
    opciones |= NI_DGRAM;
  }
  error = getnameinfo(direccion, len, hbufnum, sizeof(hbufnum), sbuf,
                      sizeof(sbuf), opciones);
  if (error == 0) {
    if (tipo == 2)
      printf("Escuchando en ");
    else if (getnameinfo(direccion, len, hbufnombre, sizeof(hbufnombre), NULL,
                         0, NI_NAMEREQD))
      printf("Maquina=(desconocida) ");
    else
      printf("Maquina=%s ", hbufnombre);
    printf("(%s), Puerto=%s", hbufnum, sbuf);
    if (tipo == 0)
      printf(" UDP");
    else
      printf(" TCP");
  } else
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(error));
}


x86 assembly (clang, -O0):
<imprime_extremo_conexion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    0x2e5f(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0x68(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x60(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    (%rax),%eax
mov    %rax,-0x58(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    0x2e2d(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
mov    0x2e03(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1202 <imprime_extremo_conexion+0xc2>
mov    0x2dae(%rip),%rax
mov    (%rax),%eax
or     -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x40(%rbp),%r8
mov    -0x60(%rbp),%rdx
mov    -0x48(%rbp),%rax
mov    -0x68(%rbp),%rcx
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    %eax,%r9d
mov    -0x34(%rbp),%eax
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1050 <getnameinfo@plt>
add    $0x10,%rsp
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
jne    1302 <imprime_extremo_conexion+0x1c2>
cmpl   $0x2,-0x10(%rbp)
jne    1259 <imprime_extremo_conexion+0x119>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bc <imprime_extremo_conexion+0x17c>
mov    -0x50(%rbp),%rdx
mov    -0x58(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    %eax,%ecx
mov    0x2d7f(%rip),%rax
mov    (%rax),%eax
xor    %r8d,%r8d
xor    %r9d,%r9d
sub    $0x10,%rsp
mov    %eax,(%rsp)
call   1050 <getnameinfo@plt>
add    $0x10,%rsp
cmp    $0x0,%eax
je     12a5 <imprime_extremo_conexion+0x165>
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12b7 <imprime_extremo_conexion+0x177>
mov    -0x50(%rbp),%rsi
lea    0xd76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bc <imprime_extremo_conexion+0x17c>
mov    -0x40(%rbp),%rdx
mov    -0x60(%rbp),%rsi
lea    0xd67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    12ef <imprime_extremo_conexion+0x1af>
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12fd <imprime_extremo_conexion+0x1bd>
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1328 <imprime_extremo_conexion+0x1e8>
mov    0x2cbf(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x38(%rbp),%edi
call   1040 <gai_strerror@plt>
mov    -0x6c(%rbp),%edi
mov    %rax,%rdx
lea    0xd29(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<imprime_extremo_conexion>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%r13d
mov    %rdi,%r14
mov    0x2e5a(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%r10
mov    %r15,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r10
mov    %r10,%rsp
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,-0x40(%rbp)
mov    %rbx,%rsp
mov    0x2e4f(%rip),%rax
mov    (%rax),%r9d
mov    %rsp,%r12
mov    %r9,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    0x2e19(%rip),%r8
mov    0x2e32(%rip),%rax
mov    (%rax),%eax
or     (%r8),%eax
xor    %r8d,%r8d
mov    %edx,-0x2c(%rbp)
test   %edx,%edx
jne    11c7 <imprime_extremo_conexion+0x87>
mov    0x2de4(%rip),%rdx
mov    (%rdx),%r8d
or     %r8d,%eax
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r13d,%esi
mov    %r10,%rdx
mov    %r15d,%ecx
mov    %r10,%rbx
mov    %r12,%r8
push   %rax
call   1050 <getnameinfo@plt>
add    $0x10,%rsp
test   %eax,%eax
je     1214 <imprime_extremo_conexion+0xd4>
mov    0x2dd3(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   1040 <gai_strerror@plt>
lea    0xe47(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
jmp    12ab <imprime_extremo_conexion+0x16b>
mov    %rbx,-0x38(%rbp)
cmpl   $0x2,-0x2c(%rbp)
jne    1227 <imprime_extremo_conexion+0xe7>
lea    0xddb(%rip),%rdi
jmp    125f <imprime_extremo_conexion+0x11f>
mov    0x2dc2(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%rsp
mov    %r14,%rdi
mov    %r13d,%esi
mov    -0x40(%rbp),%rbx
mov    %rbx,%rdx
mov    %r15d,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
push   %rax
call   1050 <getnameinfo@plt>
add    $0x10,%rsp
test   %eax,%eax
je     1268 <imprime_extremo_conexion+0x128>
lea    0xdb0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1279 <imprime_extremo_conexion+0x139>
lea    0xdb7(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdb2(%rip),%rdi
mov    -0x38(%rbp),%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
je     129d <imprime_extremo_conexion+0x15d>
lea    0xdac(%rip),%rdi
jmp    12a4 <imprime_extremo_conexion+0x164>
lea    0xd9e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@NI_DGRAM = global i32 0
@.str = [15 x i8] c"Escuchando en \00"
@NI_NAMEREQD = global i32 0
@.str.1 = [23 x i8] c"Maquina=(desconocida) \00"
@.str.2 = [12 x i8] c"Maquina=%s \00"
@.str.3 = [16 x i8] c"(%s), Puerto=%s\00"
@.str.4 = [5 x i8] c" UDP\00"
@.str.5 = [5 x i8] c" TCP\00"
@stderr = global i32 0
@.str.6 = [17 x i8] c"getaddrinfo: %s\0A\00"
define void @imprime_extremo_conexion(%struct.sockaddr* %0, i32 %1, i32 %2) {
%4 = alloca %struct.sockaddr*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
%12 = alloca i32
store %struct.sockaddr* %0, %struct.sockaddr** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%13 = load i32, i32* @NI_MAXHOST
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %7
%16 = alloca i8, i64 %14
store i64 %14, i64* %8
%17 = load i32, i32* @NI_MAXHOST
%18 = zext i32 %17 to i64
%19 = alloca i8, i64 %18
store i64 %18, i64* %9
%20 = load i32, i32* @NI_MAXSERV
%21 = zext i32 %20 to i64
%22 = alloca i8, i64 %21
store i64 %21, i64* %10
%23 = load i32, i32* @NI_NUMERICHOST
%24 = load i32, i32* @NI_NUMERICSERV
%25 = or i32 %23, %24
store i32 %25, i32* %11
store i32 0, i32* %12
%26 = load i32, i32* %6
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %3
%29 = load i32, i32* @NI_DGRAM
%30 = load i32, i32* %11
%31 = or i32 %30, %29
store i32 %31, i32* %11
br label %32
32: ; preds = %28, %3
%33 = load %struct.sockaddr*, %struct.sockaddr** %4
%34 = load i32, i32* %5
%35 = trunc i64 %14 to i32
%36 = trunc i64 %21 to i32
%37 = load i32, i32* %11
%38 = call i32 @getnameinfo(%struct.sockaddr* %33, i32 %34, i8* %16, i32 %35, i8* %22, i32 %36, i32 %37)
store i32 %38, i32* %12
%39 = load i32, i32* %12
%40 = icmp eq i32 %39, 0
br i1 %40, label %41, label %67
41: ; preds = %32
%42 = load i32, i32* %6
%43 = icmp eq i32 %42, 2
br i1 %43, label %44, label %46
44: ; preds = %41
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %58
46: ; preds = %41
%47 = load %struct.sockaddr*, %struct.sockaddr** %4
%48 = load i32, i32* %5
%49 = trunc i64 %18 to i32
%50 = load i32, i32* @NI_NAMEREQD
%51 = call i32 @getnameinfo(%struct.sockaddr* %47, i32 %48, i8* %19, i32 %49, i8* null, i32 0, i32 %50)
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %55
53: ; preds = %46
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %57
55: ; preds = %46
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %57
57: ; preds = %55, %53
br label %58
58: ; preds = %57, %44
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %22)
%60 = load i32, i32* %6
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %64
62: ; preds = %58
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %66
64: ; preds = %58
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %66
66: ; preds = %64, %62
br label %72
67: ; preds = %32
%68 = load i32, i32* @stderr
%69 = load i32, i32* %12
%70 = call i8* @gai_strerror(i32 %69)
%71 = call i32 @fprintf(i32 %68, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %67, %66
%73 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@NI_MAXHOST = global i32 0
@NI_MAXSERV = global i32 0
@NI_NUMERICHOST = global i32 0
@NI_NUMERICSERV = global i32 0
@NI_DGRAM = global i32 0
@.str = [15 x i8] c"Escuchando en \00"
@NI_NAMEREQD = global i32 0
@.str.1 = [23 x i8] c"Maquina=(desconocida) \00"
@.str.2 = [12 x i8] c"Maquina=%s \00"
@.str.3 = [16 x i8] c"(%s), Puerto=%s\00"
@.str.4 = [5 x i8] c" UDP\00"
@.str.5 = [5 x i8] c" TCP\00"
@stderr = global i32 0
@.str.6 = [17 x i8] c"getaddrinfo: %s\0A\00"
define void @imprime_extremo_conexion(%struct.sockaddr* %0, i32 %1, i32 %2) {
%4 = load i32, i32* @NI_MAXHOST
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = alloca i8, i64 %5
%8 = load i32, i32* @NI_MAXSERV
%9 = zext i32 %8 to i64
%10 = alloca i8, i64 %9
%11 = load i32, i32* @NI_NUMERICHOST
%12 = load i32, i32* @NI_NUMERICSERV
%13 = or i32 %12, %11
%14 = icmp eq i32 %2, 0
%15 = load i32, i32* @NI_DGRAM
%16 = select i1 %14, i32 %15, i32 0
%17 = or i32 %13, %16
%18 = call i32 @getnameinfo(%struct.sockaddr* %0, i32 %1, i8* %6, i32 %4, i8* %10, i32 %8, i32 %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %38
20: ; preds = %3
%21 = icmp eq i32 %2, 2
br i1 %21, label %22, label %24
22: ; preds = %20
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %32
24: ; preds = %20
%25 = load i32, i32* @NI_NAMEREQD
%26 = call i32 @getnameinfo(%struct.sockaddr* %0, i32 %1, i8* %7, i32 %4, i8* null, i32 0, i32 %25)
%27 = icmp eq i32 %26, 0
br i1 %27, label %30, label %28
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %32
30: ; preds = %24
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %32
32: ; preds = %28, %30, %22
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %6, i8* %10)
br i1 %14, label %34, label %36
34: ; preds = %32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %42
36: ; preds = %32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
br label %42
38: ; preds = %3
%39 = load i32, i32* @stderr
%40 = call i8* @gai_strerror(i32 %18)
%41 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), i8* %40)
br label %42
42: ; preds = %34, %36, %38
ret void
}