#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*/ tv;
struct timeval {
  unsigned int tv_sec;
  scalar_t__ tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVTIMEO;
int /*<<< orphan*/ SO_SNDTIMEO;
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              char *, int);
void set_socket_timeout(int s, unsigned int w_timeout, unsigned int r_timeout) {
  struct timeval tv;
  tv.tv_sec = w_timeout;
  tv.tv_usec = 0;
  setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, (char *)&tv, sizeof(tv));
  tv.tv_sec = r_timeout;
  setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (char *)&tv, sizeof(tv));
}


x86 assembly (clang, -O0):
<set_socket_timeout>:
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,-0x20(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2ea7(%rip),%rax
mov    (%rax),%esi
mov    0x2eae(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e7d(%rip),%rax
mov    (%rax),%esi
mov    0x2e64(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_socket_timeout>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %edi,%ebp
mov    %esi,0x8(%rsp)
movq   $0x0,0x10(%rsp)
mov    0x2eae(%rip),%r15
mov    (%r15),%esi
mov    0x2eb4(%rip),%rax
mov    (%rax),%edx
lea    0x8(%rsp),%r14
mov    %r14,%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
mov    %ebx,0x8(%rsp)
mov    (%r15),%esi
mov    0x2e71(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    %r14,%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32, i64 }
@SOL_SOCKET = global i32 0
@SO_SNDTIMEO = global i32 0
@SO_RCVTIMEO = global i32 0
define void @set_socket_timeout(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.timeval
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
store i64 0, i64* %10
%11 = load i32, i32* %4
%12 = load i32, i32* @SOL_SOCKET
%13 = load i32, i32* @SO_SNDTIMEO
%14 = bitcast %struct.timeval* %7 to i8*
%15 = call i32 @setsockopt(i32 %11, i32 %12, i32 %13, i8* %14, i32 16)
%16 = load i32, i32* %6
%17 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
store i32 %16, i32* %17
%18 = load i32, i32* %4
%19 = load i32, i32* @SOL_SOCKET
%20 = load i32, i32* @SO_RCVTIMEO
%21 = bitcast %struct.timeval* %7 to i8*
%22 = call i32 @setsockopt(i32 %18, i32 %19, i32 %20, i8* %21, i32 16)
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32, i64 }
@SOL_SOCKET = global i32 0
@SO_SNDTIMEO = global i32 0
@SO_RCVTIMEO = global i32 0
define void @set_socket_timeout(i32 %0, i32 %1, i32 %2) {
%4 = alloca %struct.timeval
%5 = bitcast %struct.timeval* %4 to i8*
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
store i32 %1, i32* %6
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
store i64 0, i64* %7
%8 = load i32, i32* @SOL_SOCKET
%9 = load i32, i32* @SO_SNDTIMEO
%10 = call i32 @setsockopt(i32 %0, i32 %8, i32 %9, i8* %5, i32 16)
store i32 %2, i32* %6
%11 = load i32, i32* @SOL_SOCKET
%12 = load i32, i32* @SO_RCVTIMEO
%13 = call i32 @setsockopt(i32 %0, i32 %11, i32 %12, i8* %5, i32 16)
ret void
}