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

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVBUF;
int /*<<< orphan*/ SO_SNDBUF;
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, char const *,
                      int);
int os_set_sockbufs(int fd, unsigned int ssize, unsigned int rsize) {
  unsigned int sopt = ssize;
  unsigned int ropt = rsize;
  return (
      ((0 == rsize) || (0 == setsockopt(fd, SOL_SOCKET, SO_RCVBUF,
                                        (const char *)&ropt, sizeof(ropt)))) &&
      ((0 == ssize) || (0 == setsockopt(fd, SOL_SOCKET, SO_SNDBUF,
                                        (const char *)&sopt, sizeof(sopt)))));
}


x86 assembly (clang, -O0):
<os_set_sockbufs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmp    -0xc(%rbp),%eax
je     116f <os_set_sockbufs+0x5f>
mov    -0x4(%rbp),%edi
mov    0x2ea6(%rip),%rax
mov    (%rax),%esi
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %rax,%rdx
xor    %eax,%eax
xor    %ecx,%ecx
cmp    %rdx,%rcx
mov    %al,-0x15(%rbp)
jne    11b7 <os_set_sockbufs+0xa7>
mov    $0x1,%al
xor    %ecx,%ecx
cmp    -0x8(%rbp),%ecx
mov    %al,-0x16(%rbp)
je     11b1 <os_set_sockbufs+0xa1>
mov    -0x4(%rbp),%edi
mov    0x2e5f(%rip),%rax
mov    (%rax),%esi
mov    0x2e4e(%rip),%rax
mov    (%rax),%edx
lea    -0x10(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<os_set_sockbufs>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
mov    %esi,0x4(%rsp)
mov    %edx,(%rsp)
test   %edx,%edx
je     114e <os_set_sockbufs+0x3e>
mov    0x2ebf(%rip),%rax
mov    (%rax),%esi
mov    0x2e9e(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    1188 <os_set_sockbufs+0x78>
test   %ebp,%ebp
je     1183 <os_set_sockbufs+0x73>
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
mov    0x2e7e(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
jmp    1188 <os_set_sockbufs+0x78>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@SOL_SOCKET = global i32 0
@SO_RCVBUF = global i32 0
@SO_SNDBUF = global i32 0
define i32 @os_set_sockbufs(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %5
store i32 %9, i32* %7
%10 = load i32, i32* %6
store i32 %10, i32* %8
%11 = load i32, i32* %6
%12 = icmp eq i32 0, %11
br i1 %12, label %20, label %13
13: ; preds = %3
%14 = load i32, i32* %4
%15 = load i32, i32* @SOL_SOCKET
%16 = load i32, i32* @SO_RCVBUF
%17 = bitcast i32* %8 to i8*
%18 = call i64 @setsockopt(i32 %14, i32 %15, i32 %16, i8* %17, i32 4)
%19 = icmp eq i64 0, %18
br i1 %19, label %20, label %32
20: ; preds = %13, %3
%21 = load i32, i32* %5
%22 = icmp eq i32 0, %21
br i1 %22, label %30, label %23
23: ; preds = %20
%24 = load i32, i32* %4
%25 = load i32, i32* @SOL_SOCKET
%26 = load i32, i32* @SO_SNDBUF
%27 = bitcast i32* %7 to i8*
%28 = call i64 @setsockopt(i32 %24, i32 %25, i32 %26, i8* %27, i32 4)
%29 = icmp eq i64 0, %28
br label %30
30: ; preds = %23, %20
%31 = phi i1 [ true, %20 ], [ %29, %23 ]
br label %32
32: ; preds = %30, %13
%33 = phi i1 [ false, %13 ], [ %31, %30 ]
%34 = zext i1 %33 to i32
ret i32 %34
}

LLVM IR (-O2):
@SOL_SOCKET = global i32 0
@SO_RCVBUF = global i32 0
@SO_SNDBUF = global i32 0
define i32 @os_set_sockbufs(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
store i32 %1, i32* %4
%7 = bitcast i32* %5 to i8*
store i32 %2, i32* %5
%8 = icmp eq i32 %2, 0
br i1 %8, label %14, label %9
9: ; preds = %3
%10 = load i32, i32* @SOL_SOCKET
%11 = load i32, i32* @SO_RCVBUF
%12 = call i64 @setsockopt(i32 %0, i32 %10, i32 %11, i8* %7, i32 4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %9, %3
%15 = icmp eq i32 %1, 0
br i1 %15, label %22, label %16
16: ; preds = %14
%17 = load i32, i32* @SOL_SOCKET
%18 = load i32, i32* @SO_SNDBUF
%19 = call i64 @setsockopt(i32 %0, i32 %17, i32 %18, i8* %6, i32 4)
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
br label %22
22: ; preds = %14, %16, %9
%23 = phi i32 [ 0, %9 ], [ 1, %14 ], [ %21, %16 ]
ret i32 %23
}