#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 */
typedef int /*<<< orphan*/ on;

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEPORT;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, char *);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int set_reuseport(int fd) {
  int on = 1;
  do {
    if ((setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &on, sizeof(on)) == -1)) {
      fprintf(stderr, "[ERROR in %s:%d]: %s\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/"
              "src/net.c",
              42, (strerror(errno)));
      return ((-1));
    }
  } while (0);
  return (0);
}


x86 assembly (clang, -O0):
<set_reuseport>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
mov    0x2e8b(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    11b3 <set_reuseport+0x83>
mov    0x2e5a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    -0x10(%rbp),%edi
mov    %rax,%r8
lea    0xe6a(%rip),%rsi
lea    0xe79(%rip),%rdx
mov    $0x2a,%ecx
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bf <set_reuseport+0x8f>
jmp    11b8 <set_reuseport+0x88>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_reuseport>:
push   %rbx
sub    $0x10,%rsp
movl   $0x1,0xc(%rsp)
mov    0x2ea4(%rip),%rax
mov    (%rax),%esi
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
jne    11a1 <set_reuseport+0x71>
mov    0x2e61(%rip),%rax
mov    (%rax),%ebx
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
lea    0xe7a(%rip),%rsi
lea    0xe89(%rip),%rdx
mov    %ebx,%edi
mov    $0x2a,%ecx
mov    %rax,%r8
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@SOL_SOCKET = global i32 0
@SO_REUSEPORT = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"[ERROR in %s:%d]: %s\0A\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/src/net.c\00"
@errno = global i32 0
define i32 @set_reuseport(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
br label %5
5: ; preds = %1
%6 = load i32, i32* %3
%7 = load i32, i32* @SOL_SOCKET
%8 = load i32, i32* @SO_REUSEPORT
%9 = call i32 @setsockopt(i32 %6, i32 %7, i32 %8, i32* %4, i32 4)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %16
11: ; preds = %5
%12 = load i32, i32* @stderr
%13 = load i32, i32* @errno
%14 = call i8* @strerror(i32 %13)
%15 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 42, i8* %14)
store i32 -1, i32* %2
br label %18
16: ; preds = %5
br label %17
17: ; preds = %16
store i32 0, i32* %2
br label %18
18: ; preds = %17, %11
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@SOL_SOCKET = global i32 0
@SO_REUSEPORT = global i32 0
@stderr = global i32 0
@.str = [22 x i8] c"[ERROR in %s:%d]: %s\0A\00"
@.str.1 = [135 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/zhaolei1023/muse/refs/heads/master/src/net.c\00"
@errno = global i32 0
define i32 @set_reuseport(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%4 = load i32, i32* @SOL_SOCKET
%5 = load i32, i32* @SO_REUSEPORT
%6 = call i32 @setsockopt(i32 %0, i32 %4, i32 %5, i32* %2, i32 4)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %13
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = load i32, i32* @errno
%11 = call i8* @strerror(i32 %10)
%12 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([135 x i8], [135 x i8]* @.str.1, i64 0, i64 0), i32 42, i8* %11)
br label %13
13: ; preds = %1, %8
%14 = phi i32 [ -1, %8 ], [ 0, %1 ]
ret i32 %14
}