#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*/ AF_INET;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int /*<<< orphan*/ report_errno_with_data(char *, int);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
void set_socket_options(int *svr_socket) {
  int set_option = 1;
  *svr_socket = socket(AF_INET, SOCK_STREAM, 0);
  if (*svr_socket < 1) {
    report_errno_with_data("/scratch/repos/new/home/jordi_armengol_estape/"
                           "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                           "14bmkelley/WebC/refs/heads/master/src/config.c",
                           51);
  }
  set_option = setsockopt(*svr_socket, SOL_SOCKET, SO_REUSEADDR, &set_option,
                          sizeof(int));
  if (set_option < 0) {
    report_errno_with_data("/scratch/repos/new/home/jordi_armengol_estape/"
                           "c-scraper/outputs/2022-01-22/02-19-57/repos/"
                           "14bmkelley/WebC/refs/heads/master/src/config.c",
                           59);
  }
}


x86 assembly (clang, -O0):
<set_socket_options>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%edi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
cmpl   $0x1,(%rax)
jge    1182 <set_socket_options+0x52>
lea    0xe88(%rip),%rdi
mov    $0x33,%esi
call   1040 <report_errno_with_data@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    0x2e59(%rip),%rax
mov    (%rax),%esi
mov    0x2e30(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11c7 <set_socket_options+0x97>
lea    0xe43(%rip),%rdi
mov    $0x3b,%esi
call   1040 <report_errno_with_data@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_socket_options>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movl   $0x1,0xc(%rsp)
mov    0x2e99(%rip),%rax
mov    (%rax),%edi
mov    0x2e80(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1050 <socket@plt>
mov    %eax,(%rbx)
test   %eax,%eax
jg     1172 <set_socket_options+0x42>
lea    0xe9a(%rip),%rdi
mov    $0x33,%esi
call   1040 <report_errno_with_data@plt>
mov    (%rbx),%eax
mov    0x2e6f(%rip),%rcx
mov    (%rcx),%esi
mov    0x2e46(%rip),%rcx
mov    (%rcx),%edx
lea    0xc(%rsp),%rcx
mov    %eax,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
jns    11af <set_socket_options+0x7f>
lea    0xe5b(%rip),%rdi
mov    $0x3b,%esi
call   1040 <report_errno_with_data@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/14bmkelley/WebC/refs/heads/master/src/config.c\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
define void @set_socket_options(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 1, i32* %3
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_STREAM
%6 = call i32 @socket(i32 %4, i32 %5, i32 0)
%7 = load i32*, i32** %2
store i32 %6, i32* %7
%8 = load i32*, i32** %2
%9 = load i32, i32* %8
%10 = icmp slt i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %1
%12 = call i32 @report_errno_with_data(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i32 51)
br label %13
13: ; preds = %11, %1
%14 = load i32*, i32** %2
%15 = load i32, i32* %14
%16 = load i32, i32* @SOL_SOCKET
%17 = load i32, i32* @SO_REUSEADDR
%18 = call i32 @setsockopt(i32 %15, i32 %16, i32 %17, i32* %3, i32 4)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = call i32 @report_errno_with_data(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i32 59)
br label %23
23: ; preds = %21, %13
ret void
}

LLVM IR (-O2):
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [137 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/14bmkelley/WebC/refs/heads/master/src/config.c\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
define void @set_socket_options(i32* nocapture %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%4 = load i32, i32* @AF_INET
%5 = load i32, i32* @SOCK_STREAM
%6 = tail call i32 @socket(i32 %4, i32 %5, i32 0)
store i32 %6, i32* %0
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = tail call i32 @report_errno_with_data(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i32 51)
%10 = load i32, i32* %0
br label %11
11: ; preds = %8, %1
%12 = phi i32 [ %10, %8 ], [ %6, %1 ]
%13 = load i32, i32* @SOL_SOCKET
%14 = load i32, i32* @SO_REUSEADDR
%15 = call i32 @setsockopt(i32 %12, i32 %13, i32 %14, i32* %2, i32 4)
store i32 %15, i32* %2
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @report_errno_with_data(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i32 59)
br label %19
19: ; preds = %17, %11
ret void
}