#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*/ timeout;
struct timeval {
  int member_0;
  int /*<<< orphan*/ member_1;
};
typedef int /*<<< orphan*/ socklen_t;

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVTIMEO;
int /*<<< orphan*/ SO_SNDTIMEO;
int setsockopt(int const, int /*<<< orphan*/, int /*<<< orphan*/, void const *,
               int /*<<< orphan*/);
bool _set_timeout(const int s) {
  static const struct timeval timeout = {(5), 0};
  if (-1 == setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (const void *)&timeout,
                       (socklen_t)sizeof(timeout))) {
    return false;
  }
  if (-1 == setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (const void *)&timeout,
                       (socklen_t)sizeof(timeout))) {
    return false;
  }
  return true;
}


x86 assembly (clang, -O0):
<_set_timeout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2ebb(%rip),%rax
mov    (%rax),%esi
mov    0x2ea2(%rip),%rax
mov    (%rax),%edx
lea    0xec9(%rip),%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    115d <_set_timeout+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    11a6 <_set_timeout+0x96>
mov    -0x8(%rbp),%edi
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
mov    0x2e80(%rip),%rax
mov    (%rax),%edx
lea    0xe87(%rip),%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
cmp    %ecx,%eax
jne    119f <_set_timeout+0x8f>
movl   $0x0,-0x4(%rbp)
jmp    11a6 <_set_timeout+0x96>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_set_timeout>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2ec3(%rip),%r14
mov    (%r14),%esi
mov    0x2ea9(%rip),%rax
mov    (%rax),%edx
lea    0xed0(%rip),%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     116c <_set_timeout+0x5c>
mov    (%r14),%esi
mov    0x2ea6(%rip),%rax
mov    (%rax),%edx
lea    0xead(%rip),%rcx
mov    %ebx,%edi
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
setne  %al
jmp    116e <_set_timeout+0x5e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@_set_timeout.timeout = internal constant %struct.timeval { i32 5, i32 0 }
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@SO_SNDTIMEO = global i32 0
define i32 @_set_timeout(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = load i32, i32* @SOL_SOCKET
%6 = load i32, i32* @SO_RCVTIMEO
%7 = call i32 @setsockopt(i32 %4, i32 %5, i32 %6, i8* bitcast (%struct.timeval* @_set_timeout.timeout to i8*), i32 8)
%8 = icmp eq i32 -1, %7
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 0, i32* %2
br label %18
10: ; preds = %1
%11 = load i32, i32* %3
%12 = load i32, i32* @SOL_SOCKET
%13 = load i32, i32* @SO_SNDTIMEO
%14 = call i32 @setsockopt(i32 %11, i32 %12, i32 %13, i8* bitcast (%struct.timeval* @_set_timeout.timeout to i8*), i32 8)
%15 = icmp eq i32 -1, %14
br i1 %15, label %16, label %17
16: ; preds = %10
store i32 0, i32* %2
br label %18
17: ; preds = %10
store i32 1, i32* %2
br label %18
18: ; preds = %17, %16, %9
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@_set_timeout.timeout = internal constant %struct.timeval { i32 5, i32 0 }
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@SO_SNDTIMEO = global i32 0
define i32 @_set_timeout(i32 %0) {
%2 = load i32, i32* @SOL_SOCKET
%3 = load i32, i32* @SO_RCVTIMEO
%4 = tail call i32 @setsockopt(i32 %0, i32 %2, i32 %3, i8* bitcast (%struct.timeval* @_set_timeout.timeout to i8*), i32 8)
%5 = icmp eq i32 %4, -1
br i1 %5, label %12, label %6
6: ; preds = %1
%7 = load i32, i32* @SOL_SOCKET
%8 = load i32, i32* @SO_SNDTIMEO
%9 = tail call i32 @setsockopt(i32 %0, i32 %7, i32 %8, i8* bitcast (%struct.timeval* @_set_timeout.timeout to i8*), i32 8)
%10 = icmp ne i32 %9, -1
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %6, %1
%13 = phi i32 [ 0, %1 ], [ %11, %6 ]
ret i32 %13
}