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

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_RCVTIMEO;
int /*<<< orphan*/ SO_SNDTIMEO;
int getsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *,
               int /*<<< orphan*/ *);
int socket_check_timout(int fd) {
  int ret1, ret2;
  int code;
  size_t len = sizeof(int);
  ret1 = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &code, (socklen_t *)&len);
  ret2 = getsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &code, (socklen_t *)&len);
  if ((ret1 || ret2 || code) != 0)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<socket_check_timout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
movq   $0x4,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2eb3(%rip),%rax
mov    (%rax),%esi
mov    0x2e9a(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%r8
lea    -0x14(%rbp),%rcx
call   1030 <getsockopt@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e8e(%rip),%rax
mov    (%rax),%esi
mov    0x2e95(%rip),%rax
mov    (%rax),%edx
lea    -0x20(%rbp),%r8
lea    -0x14(%rbp),%rcx
call   1030 <getsockopt@plt>
mov    %eax,-0x10(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x21(%rbp)
jne    1195 <socket_check_timout+0x85>
mov    $0x1,%al
cmpl   $0x0,-0x10(%rbp)
mov    %al,-0x21(%rbp)
jne    1195 <socket_check_timout+0x85>
cmpl   $0x0,-0x14(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
je     11b2 <socket_check_timout+0xa2>
movl   $0x1,-0x4(%rbp)
jmp    11b9 <socket_check_timout+0xa9>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<socket_check_timout>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movq   $0x4,0x8(%rsp)
mov    0x2eb2(%rip),%r12
mov    (%r12),%esi
mov    0x2e97(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%r14
lea    0x8(%rsp),%r15
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <getsockopt@plt>
mov    %eax,%ebp
mov    (%r12),%esi
mov    0x2e93(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %r14,%rcx
mov    %r15,%r8
call   1030 <getsockopt@plt>
or     %ebp,%eax
xor    %ecx,%ecx
or     0x4(%rsp),%eax
setne  %cl
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@SOL_SOCKET = global i32 0
@SO_RCVTIMEO = global i32 0
@SO_SNDTIMEO = global i32 0
define i32 @socket_check_timout(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = bitcast i32* %2 to i8*
%5 = bitcast i64* %3 to i8*
store i64 4, i64* %3
%6 = load i32, i32* @SOL_SOCKET
%7 = load i32, i32* @SO_RCVTIMEO
%8 = bitcast i64* %3 to i32*
%9 = call i32 @getsockopt(i32 %0, i32 %6, i32 %7, i32* %2, i32* %8)
%10 = load i32, i32* @SOL_SOCKET
%11 = load i32, i32* @SO_SNDTIMEO
%12 = call i32 @getsockopt(i32 %0, i32 %10, i32 %11, i32* %2, i32* %8)
%13 = icmp ne i32 %9, 0
%14 = icmp ne i32 %12, 0
%15 = select i1 %13, i1 true, i1 %14
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 0
%18 = select i1 %15, i1 true, i1 %17
%19 = zext i1 %18 to i32
ret i32 %19
}