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

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_SNDBUF;
int /*<<< orphan*/ fatal(char *, char *);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char *, int);
void set_txbuf_size(int fd, int buffer_size) {
  int msg_size = buffer_size;
  int status = setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char *)&msg_size,
                          sizeof(msg_size));
  if (status == -1)
    fatal("setsockopt", "Unable to set socket buffer size");
}


x86 assembly (clang, -O0):
<set_txbuf_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2eaa(%rip),%rax
mov    (%rax),%esi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    1178 <set_txbuf_size+0x58>
lea    0xe94(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1040 <fatal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_txbuf_size>:
push   %rax
mov    %esi,0x4(%rsp)
mov    0x2ebc(%rip),%rax
mov    (%rax),%esi
mov    0x2eab(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     114e <set_txbuf_size+0x2e>
pop    %rax
ret
lea    0xeab(%rip),%rdi
lea    0xeaf(%rip),%rsi
call   1040 <fatal@plt>
pop    %rax
ret

LLVM IR (-O0):
@SOL_SOCKET = global i32 0
@SO_SNDBUF = global i32 0
@.str = [11 x i8] c"setsockopt\00"
@.str.1 = [33 x i8] c"Unable to set socket buffer size\00"
define void @set_txbuf_size(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
store i32 %7, i32* %5
%8 = load i32, i32* %3
%9 = load i32, i32* @SOL_SOCKET
%10 = load i32, i32* @SO_SNDBUF
%11 = bitcast i32* %5 to i8*
%12 = call i32 @setsockopt(i32 %8, i32 %9, i32 %10, i8* %11, i32 4)
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @fatal(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %15, %2
ret void
}

LLVM IR (-O2):
@SOL_SOCKET = global i32 0
@SO_SNDBUF = global i32 0
@.str = [11 x i8] c"setsockopt\00"
@.str.1 = [33 x i8] c"Unable to set socket buffer size\00"
define void @set_txbuf_size(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 %1, i32* %3
%5 = load i32, i32* @SOL_SOCKET
%6 = load i32, i32* @SO_SNDBUF
%7 = call i32 @setsockopt(i32 %0, i32 %5, i32 %6, i8* %4, i32 4)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = call i32 @fatal(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
ret void
}