#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 */

/* Variables and functions */
int /*<<< orphan*/ PF_INET6;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int j_socket() {
  int sz = 1;
  int fd;
  fd = socket(PF_INET6, SOCK_STREAM, 0);
  if (fd < 0) {
    if (0)
      fprintf(stderr, "no pude hacer un socket\n");
    return -1;
  }
  setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &sz, sizeof sz);
  return (fd);
}


x86 assembly (clang, -O0):
<j_socket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x8(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <socket@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    1161 <j_socket+0x41>
movl   $0xffffffff,-0x4(%rbp)
jmp    118b <j_socket+0x6b>
mov    -0xc(%rbp),%edi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    0x2e54(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<j_socket>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
mov    0x2eac(%rip),%rax
mov    (%rax),%edi
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1040 <socket@plt>
test   %eax,%eax
js     1172 <j_socket+0x52>
mov    %eax,%ebx
mov    0x2e95(%rip),%rax
mov    (%rax),%esi
mov    0x2e6c(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
jmp    1177 <j_socket+0x57>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@PF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@stderr = global i32 0
define i32 @j_socket() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 1, i32* %2
%4 = load i32, i32* @PF_INET6
%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 slt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 -1, i32* %1
br label %16
10: ; preds = %0
%11 = load i32, i32* %3
%12 = load i32, i32* @SOL_SOCKET
%13 = load i32, i32* @SO_REUSEADDR
%14 = call i32 @setsockopt(i32 %11, i32 %12, i32 %13, i32* %2, i32 4)
%15 = load i32, i32* %3
store i32 %15, i32* %1
br label %16
16: ; preds = %10, %9
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@PF_INET6 = global i32 0
@SOCK_STREAM = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@stderr = global i32 0
define i32 @j_socket() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%3 = load i32, i32* @PF_INET6
%4 = load i32, i32* @SOCK_STREAM
%5 = tail call i32 @socket(i32 %3, i32 %4, i32 0)
%6 = icmp slt i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = load i32, i32* @SOL_SOCKET
%9 = load i32, i32* @SO_REUSEADDR
%10 = call i32 @setsockopt(i32 %5, i32 %8, i32 %9, i32* %1, i32 4)
br label %11
11: ; preds = %0, %7
%12 = phi i32 [ %5, %7 ], [ -1, %0 ]
ret i32 %12
}