#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)
mov    $0x1,%al
xor    %ecx,%ecx
cmp    -0xc(%rbp),%ecx
mov    %al,-0x15(%rbp)
je     11c2 <os_set_sockbufs+0xb2>
mov    -0x4(%rbp),%edi
mov    0x2ea1(%rip),%rax
mov    (%rax),%esi
mov    0x2e80(%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,-0x16(%rbp)
jne    11bc <os_set_sockbufs+0xac>
mov    $0x1,%al
xor    %ecx,%ecx
cmp    -0x8(%rbp),%ecx
mov    %al,-0x17(%rbp)
je     11b6 <os_set_sockbufs+0xa6>
mov    -0x4(%rbp),%edi
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
mov    0x2e49(%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,-0x17(%rbp)
mov    -0x17(%rbp),%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   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,0xc(%rsp)
mov    %edx,0x8(%rsp)
mov    $0x1,%eax
test   %edx,%edx
je     118c <os_set_sockbufs+0x7c>
mov    %esi,%ebp
mov    %edi,%ebx
mov    0x2eb4(%rip),%r14
mov    (%r14),%esi
mov    0x2e92(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    118c <os_set_sockbufs+0x7c>
mov    $0x1,%eax
test   %ebp,%ebp
je     118c <os_set_sockbufs+0x7c>
mov    (%r14),%esi
mov    0x2e73(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
add    $0x10,%rsp
pop    %rbx
pop    %r14
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 %34, 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
%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 ]
br label %34
34: ; preds = %32, %3
%35 = phi i1 [ true, %3 ], [ %33, %32 ]
%36 = zext i1 %35 to i32
ret i32 %36
}

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 %22, 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
%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 = %9, %16, %14, %3
%23 = phi i32 [ 1, %3 ], [ 0, %9 ], [ 1, %14 ], [ %21, %16 ]
ret i32 %23
}