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

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_PRIORITY;
int /*<<< orphan*/ SO_RCVBUF;
int /*<<< orphan*/ SO_SNDBUF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ formatout(int /*<<< orphan*/, char *, int, ...);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
void set_opts(int sockfd, int priority, int window_size, char *fn) {
  int ret =
      setsockopt(sockfd, SOL_SOCKET, SO_PRIORITY, &priority, sizeof(priority));
  if (ret != 0) {
    formatout(0, "Failed setting priority to %i in %s() call!\n", priority, fn);
    exit(-1);
    return;
  }
  formatout(0, "FD %i set to piroirty %i using %s()\n", sockfd, priority, fn);
  ret = setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, &window_size,
                   sizeof(window_size));
  if (ret != 0) {
    formatout(0, "Failed setting RCV window size to %i in %s() call!\n",
              window_size, fn);
    exit(-1);
    return;
  }
  formatout(0, "FD %i set RCV window size to %i using %s()\n", sockfd,
            window_size, fn);
  ret = setsockopt(sockfd, SOL_SOCKET, SO_SNDBUF, &window_size,
                   sizeof(window_size));
  if (ret != 0) {
    formatout(0, "Failed setting SND window size to %i in %s() call!\n",
              window_size, fn);
    exit(-1);
    return;
  }
  formatout(0, "FD %i set SND window size to %i using %s()\n", sockfd,
            window_size, fn);
}


x86 assembly (clang, -O0):
<set_opts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1197 <set_opts+0x67>
mov    -0x8(%rbp),%edx
mov    -0x18(%rbp),%rcx
xor    %edi,%edi
lea    0xe7a(%rip),%rsi
mov    $0x0,%al
call   1040 <formatout@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
mov    -0x18(%rbp),%r8
xor    %edi,%edi
lea    0xe83(%rip),%rsi
mov    $0x0,%al
call   1040 <formatout@plt>
mov    -0x4(%rbp),%edi
mov    0x2e25(%rip),%rax
mov    (%rax),%esi
mov    0x2e04(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1203 <set_opts+0xd3>
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
xor    %edi,%edi
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1040 <formatout@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%r8
xor    %edi,%edi
lea    0xe70(%rip),%rsi
mov    $0x0,%al
call   1040 <formatout@plt>
mov    -0x4(%rbp),%edi
mov    0x2db9(%rip),%rax
mov    (%rax),%esi
mov    0x2da8(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     126f <set_opts+0x13f>
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
xor    %edi,%edi
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1040 <formatout@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x18(%rbp),%r8
xor    %edi,%edi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1040 <formatout@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_opts>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%rbx
mov    %edi,%ebp
mov    %esi,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    0x2e94(%rip),%r14
mov    (%r14),%esi
mov    0x2e9a(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    0xc(%rsp),%ecx
test   %eax,%eax
jne    1208 <set_opts+0xd8>
lea    0xeb2(%rip),%rsi
xor    %edi,%edi
mov    %ebp,%edx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <formatout@plt>
mov    (%r14),%esi
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    0x8(%rsp),%ecx
test   %eax,%eax
jne    1211 <set_opts+0xe1>
lea    0xed0(%rip),%rsi
xor    %edi,%edi
mov    %ebp,%edx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <formatout@plt>
mov    (%r14),%esi
mov    0x2e0a(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    0x8(%rsp),%ecx
test   %eax,%eax
jne    121a <set_opts+0xea>
lea    0xef5(%rip),%rsi
xor    %edi,%edi
mov    %ebp,%edx
mov    %rbx,%r8
xor    %eax,%eax
call   1040 <formatout@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xdf1(%rip),%rsi
jmp    1221 <set_opts+0xf1>
lea    0xe3a(%rip),%rsi
jmp    1221 <set_opts+0xf1>
lea    0xe91(%rip),%rsi
xor    %edi,%edi
mov    %ecx,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1040 <formatout@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@SOL_SOCKET = global i32 0
@SO_PRIORITY = global i32 0
@.str = [45 x i8] c"Failed setting priority to %i in %s() call!\0A\00"
@.str.1 = [37 x i8] c"FD %i set to piroirty %i using %s()\0A\00"
@SO_RCVBUF = global i32 0
@.str.2 = [52 x i8] c"Failed setting RCV window size to %i in %s() call!\0A\00"
@.str.3 = [44 x i8] c"FD %i set RCV window size to %i using %s()\0A\00"
@SO_SNDBUF = global i32 0
@.str.4 = [52 x i8] c"Failed setting SND window size to %i in %s() call!\0A\00"
@.str.5 = [44 x i8] c"FD %i set SND window size to %i using %s()\0A\00"
define void @set_opts(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i32, i32* %5
%11 = load i32, i32* @SOL_SOCKET
%12 = load i32, i32* @SO_PRIORITY
%13 = call i32 @setsockopt(i32 %10, i32 %11, i32 %12, i32* %6, i32 4)
store i32 %13, i32* %9
%14 = load i32, i32* %9
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %4
%17 = load i32, i32* %6
%18 = load i8*, i8** %8
%19 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %17, i8* %18)
%20 = call i32 @exit(i32 -1)
unreachable
21: ; preds = %4
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = load i8*, i8** %8
%25 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i8* %24)
%26 = load i32, i32* %5
%27 = load i32, i32* @SOL_SOCKET
%28 = load i32, i32* @SO_RCVBUF
%29 = call i32 @setsockopt(i32 %26, i32 %27, i32 %28, i32* %7, i32 4)
store i32 %29, i32* %9
%30 = load i32, i32* %9
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %37
32: ; preds = %21
%33 = load i32, i32* %7
%34 = load i8*, i8** %8
%35 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %33, i8* %34)
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %21
%38 = load i32, i32* %5
%39 = load i32, i32* %7
%40 = load i8*, i8** %8
%41 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %38, i32 %39, i8* %40)
%42 = load i32, i32* %5
%43 = load i32, i32* @SOL_SOCKET
%44 = load i32, i32* @SO_SNDBUF
%45 = call i32 @setsockopt(i32 %42, i32 %43, i32 %44, i32* %7, i32 4)
store i32 %45, i32* %9
%46 = load i32, i32* %9
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %37
%49 = load i32, i32* %7
%50 = load i8*, i8** %8
%51 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i32 %49, i8* %50)
%52 = call i32 @exit(i32 -1)
unreachable
53: ; preds = %37
%54 = load i32, i32* %5
%55 = load i32, i32* %7
%56 = load i8*, i8** %8
%57 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %54, i32 %55, i8* %56)
ret void
}

LLVM IR (-O2):
@SOL_SOCKET = global i32 0
@SO_PRIORITY = global i32 0
@.str = [45 x i8] c"Failed setting priority to %i in %s() call!\0A\00"
@.str.1 = [37 x i8] c"FD %i set to piroirty %i using %s()\0A\00"
@SO_RCVBUF = global i32 0
@.str.2 = [52 x i8] c"Failed setting RCV window size to %i in %s() call!\0A\00"
@.str.3 = [44 x i8] c"FD %i set RCV window size to %i using %s()\0A\00"
@SO_SNDBUF = global i32 0
@.str.4 = [52 x i8] c"Failed setting SND window size to %i in %s() call!\0A\00"
@.str.5 = [44 x i8] c"FD %i set SND window size to %i using %s()\0A\00"
define void @set_opts(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* @SOL_SOCKET
%8 = load i32, i32* @SO_PRIORITY
%9 = call i32 @setsockopt(i32 %0, i32 %7, i32 %8, i32* %5, i32 4)
%10 = icmp eq i32 %9, 0
%11 = load i32, i32* %5
br i1 %10, label %15, label %12
12: ; preds = %4
%13 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %11, i8* %3)
%14 = call i32 @exit(i32 -1)
unreachable
15: ; preds = %4
%16 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %11, i8* %3)
%17 = load i32, i32* @SOL_SOCKET
%18 = load i32, i32* @SO_RCVBUF
%19 = call i32 @setsockopt(i32 %0, i32 %17, i32 %18, i32* %6, i32 4)
%20 = icmp eq i32 %19, 0
%21 = load i32, i32* %6
br i1 %20, label %25, label %22
22: ; preds = %15
%23 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %21, i8* %3)
%24 = call i32 @exit(i32 -1)
unreachable
25: ; preds = %15
%26 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %0, i32 %21, i8* %3)
%27 = load i32, i32* @SOL_SOCKET
%28 = load i32, i32* @SO_SNDBUF
%29 = call i32 @setsockopt(i32 %0, i32 %27, i32 %28, i32* %6, i32 4)
%30 = icmp eq i32 %29, 0
%31 = load i32, i32* %6
br i1 %30, label %35, label %32
32: ; preds = %25
%33 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0), i32 %31, i8* %3)
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %25
%36 = call i32 (i32, i8*, i32, ...) @formatout(i32 0, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %0, i32 %31, i8* %3)
ret void
}