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

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_KEEPALIVE;
int /*<<< orphan*/ set_socket_options(int const);
scalar_t__ setsockopt(int const, int /*<<< orphan*/, int /*<<< orphan*/,
                      int const *, int);
int set_socket_options_low_volume(const int sock) {
  const int flag = 1;
  if (!set_socket_options(sock))
    return 0;
  if (setsockopt(sock, SOL_SOCKET, SO_KEEPALIVE, &flag, sizeof(flag))) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<set_socket_options_low_volume>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <set_socket_options@plt>
cmp    $0x0,%eax
jne    114f <set_socket_options_low_volume+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1190 <set_socket_options_low_volume+0x70>
mov    -0x8(%rbp),%edi
mov    0x2e8f(%rip),%rax
mov    (%rax),%esi
mov    0x2e6e(%rip),%rax
mov    (%rax),%edx
lea    -0xc(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
je     1189 <set_socket_options_low_volume+0x69>
movl   $0x0,-0x4(%rbp)
jmp    1190 <set_socket_options_low_volume+0x70>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_socket_options_low_volume>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movl   $0x1,0xc(%rsp)
call   1040 <set_socket_options@plt>
test   %eax,%eax
je     1169 <set_socket_options_low_volume+0x49>
mov    0x2ea9(%rip),%rax
mov    (%rax),%esi
mov    0x2e88(%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
jmp    116b <set_socket_options_low_volume+0x4b>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@SOL_SOCKET = global i32 0
@SO_KEEPALIVE = global i32 0
define i32 @set_socket_options_low_volume(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 1, i32* %4
%5 = load i32, i32* %3
%6 = call i32 @set_socket_options(i32 %5)
%7 = icmp ne i32 %6, 0
br i1 %7, label %9, label %8
8: ; preds = %1
store i32 0, i32* %2
br label %17
9: ; preds = %1
%10 = load i32, i32* %3
%11 = load i32, i32* @SOL_SOCKET
%12 = load i32, i32* @SO_KEEPALIVE
%13 = call i64 @setsockopt(i32 %10, i32 %11, i32 %12, i32* %4, i32 4)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %9
store i32 0, i32* %2
br label %17
16: ; preds = %9
store i32 1, i32* %2
br label %17
17: ; preds = %16, %15, %8
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@SOL_SOCKET = global i32 0
@SO_KEEPALIVE = global i32 0
define i32 @set_socket_options_low_volume(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%4 = tail call i32 @set_socket_options(i32 %0)
%5 = icmp eq i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = load i32, i32* @SOL_SOCKET
%8 = load i32, i32* @SO_KEEPALIVE
%9 = call i64 @setsockopt(i32 %0, i32 %7, i32 %8, i32* %2, i32 4)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %6, %1
%13 = phi i32 [ 0, %1 ], [ %11, %6 ]
ret i32 %13
}