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

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVBUF;
int /*<<< orphan*/ SO_SNDBUF;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ log_message(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int set_tcp_buffer_len(int f, int bytes) {
  if (setsockopt(f, SOL_SOCKET, SO_SNDBUF, &bytes, sizeof(bytes)) == -1) {
    log_message("set_tcp_buffer_len: setsockopt: %s (errno %d)",
                strerror(errno), errno);
    return -1;
  }
  if (setsockopt(f, SOL_SOCKET, SO_RCVBUF, &bytes, sizeof(bytes)) == -1) {
    log_message("set_tcp_buffer_len: setsockopt: %s (errno %d)",
                strerror(errno), errno);
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<set_tcp_buffer_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ea0(%rip),%rax
mov    (%rax),%esi
mov    0x2e8f(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    119c <set_tcp_buffer_len+0x6c>
mov    0x2e56(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %eax,%esi
mov    0x2e46(%rip),%rax
mov    (%rax),%edx
lea    0xe75(%rip),%rdi
call   1040 <log_message@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1201 <set_tcp_buffer_len+0xd1>
mov    -0x8(%rbp),%edi
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
mov    0x2e21(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    11fa <set_tcp_buffer_len+0xca>
mov    0x2df8(%rip),%rax
mov    (%rax),%edi
call   1050 <strerror@plt>
mov    %eax,%esi
mov    0x2de8(%rip),%rax
mov    (%rax),%edx
lea    0xe17(%rip),%rdi
call   1040 <log_message@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1201 <set_tcp_buffer_len+0xd1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_tcp_buffer_len>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %esi,0x4(%rsp)
mov    0x2ea7(%rip),%r14
mov    (%r14),%esi
mov    0x2e95(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     1189 <set_tcp_buffer_len+0x59>
mov    (%r14),%esi
mov    0x2e64(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
jne    11ac <set_tcp_buffer_len+0x7c>
mov    0x2e38(%rip),%rbx
mov    (%rbx),%edi
call   1050 <strerror@plt>
mov    (%rbx),%edx
lea    0xe60(%rip),%rdi
mov    %eax,%esi
call   1040 <log_message@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@SOL_SOCKET = global i32 0
@SO_SNDBUF = global i32 0
@.str = [46 x i8] c"set_tcp_buffer_len: setsockopt: %s (errno %d)\00"
@errno = global i32 0
@SO_RCVBUF = global i32 0
define i32 @set_tcp_buffer_len(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = load i32, i32* @SOL_SOCKET
%8 = load i32, i32* @SO_SNDBUF
%9 = call i32 @setsockopt(i32 %6, i32 %7, i32 %8, i32* %5, i32 4)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = load i32, i32* @errno
%15 = call i32 @log_message(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %14)
store i32 -1, i32* %3
br label %28
16: ; preds = %2
%17 = load i32, i32* %4
%18 = load i32, i32* @SOL_SOCKET
%19 = load i32, i32* @SO_RCVBUF
%20 = call i32 @setsockopt(i32 %17, i32 %18, i32 %19, i32* %5, i32 4)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %27
22: ; preds = %16
%23 = load i32, i32* @errno
%24 = call i32 @strerror(i32 %23)
%25 = load i32, i32* @errno
%26 = call i32 @log_message(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %24, i32 %25)
store i32 -1, i32* %3
br label %28
27: ; preds = %16
store i32 0, i32* %3
br label %28
28: ; preds = %27, %22, %11
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
@SOL_SOCKET = global i32 0
@SO_SNDBUF = global i32 0
@.str = [46 x i8] c"set_tcp_buffer_len: setsockopt: %s (errno %d)\00"
@errno = global i32 0
@SO_RCVBUF = global i32 0
define i32 @set_tcp_buffer_len(i32 %0, i32 %1) {
%3 = alloca i32
store i32 %1, i32* %3
%4 = load i32, i32* @SOL_SOCKET
%5 = load i32, i32* @SO_SNDBUF
%6 = call i32 @setsockopt(i32 %0, i32 %4, i32 %5, i32* %3, i32 4)
%7 = icmp eq i32 %6, -1
br i1 %7, label %13, label %8
8: ; preds = %2
%9 = load i32, i32* @SOL_SOCKET
%10 = load i32, i32* @SO_RCVBUF
%11 = call i32 @setsockopt(i32 %0, i32 %9, i32 %10, i32* %3, i32 4)
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %18
13: ; preds = %8, %2
%14 = load i32, i32* @errno
%15 = call i32 @strerror(i32 %14)
%16 = load i32, i32* @errno
%17 = call i32 @log_message(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %16)
br label %18
18: ; preds = %13, %8
%19 = phi i32 [ 0, %8 ], [ -1, %13 ]
ret i32 %19
}