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

/* Variables and functions */
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ client_process(int, int /*<<< orphan*/ *, int, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
void client_loop(int remotefd, int localfd) {
  fd_set set;
  int max;
  while (1) {
    struct timeval tv = {60, 0};
    FD_ZERO(&set);
    FD_SET(remotefd, &set);
    FD_SET(localfd, &set);
    max = remotefd > localfd ? remotefd : localfd;
    max = select(max + 1, &set, NULL, NULL, &tv);
    if (max > 0)
      client_process(max, &set, remotefd, localfd);
  }
}


x86 assembly (clang, -O0):
<client_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    -0xc(%rbp),%rdi
call   1030 <FD_ZERO@plt>
mov    -0x4(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1060 <FD_SET@plt>
mov    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1060 <FD_SET@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jle    1191 <client_loop+0x51>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1197 <client_loop+0x57>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edi
add    $0x1,%edi
lea    -0xc(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x18(%rbp),%r8
mov    %rcx,%rdx
call   1040 <select@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    11d6 <client_loop+0x96>
mov    -0x10(%rbp),%edi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    -0xc(%rbp),%rsi
call   1050 <client_process@plt>
jmp    114e <client_loop+0xe>

x86 assembly (clang, -O2):
<client_loop>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%r15d
mov    %edi,%ebp
cmp    %esi,%edi
mov    %esi,%r14d
cmovg  %edi,%r14d
add    $0x1,%r14d
lea    0xc(%rsp),%rbx
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
movq   $0x3c,(%rsp)
mov    %rbx,%rdi
call   1030 <FD_ZERO@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <FD_SET@plt>
mov    %r15d,%edi
mov    %rbx,%rsi
call   1060 <FD_SET@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r12,%r8
call   1040 <select@plt>
test   %eax,%eax
jle    1170 <client_loop+0x30>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r15d,%ecx
call   1050 <client_process@plt>
jmp    1170 <client_loop+0x30>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@__const.client_loop.tv = %struct.timeval { i32 60, i32 0 }
define void @client_loop(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.timeval
store i32 %0, i32* %3
store i32 %1, i32* %4
br label %8
8: ; preds = %2, %34
%9 = bitcast %struct.timeval* %7 to i8*
%10 = call i32 @FD_ZERO(i32* %5)
%11 = load i32, i32* %3
%12 = call i32 @FD_SET(i32 %11, i32* %5)
%13 = load i32, i32* %4
%14 = call i32 @FD_SET(i32 %13, i32* %5)
%15 = load i32, i32* %3
%16 = load i32, i32* %4
%17 = icmp sgt i32 %15, %16
br i1 %17, label %18, label %20
18: ; preds = %8
%19 = load i32, i32* %3
br label %22
20: ; preds = %8
%21 = load i32, i32* %4
br label %22
22: ; preds = %20, %18
%23 = phi i32 [ %19, %18 ], [ %21, %20 ]
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
%26 = call i32 @select(i32 %25, i32* %5, i32* null, i32* null, %struct.timeval* %7)
store i32 %26, i32* %6
%27 = load i32, i32* %6
%28 = icmp sgt i32 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %22
%30 = load i32, i32* %6
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = call i32 @client_process(i32 %30, i32* %5, i32 %31, i32 %32)
br label %34
34: ; preds = %29, %22
br label %8
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
define void @client_loop(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = bitcast i64* %4 to %struct.timeval*
%6 = bitcast i32* %3 to i8*
%7 = bitcast i64* %4 to i8*
%8 = icmp sgt i32 %0, %1
%9 = select i1 %8, i32 %0, i32 %1
%10 = add nsw i32 %9, 1
br label %11
11: ; preds = %19, %2
store i64 60, i64* %4
%12 = call i32 @FD_ZERO(i32* %3)
%13 = call i32 @FD_SET(i32 %0, i32* %3)
%14 = call i32 @FD_SET(i32 %1, i32* %3)
%15 = call i32 @select(i32 %10, i32* %3, i32* null, i32* null, %struct.timeval* %5)
%16 = icmp sgt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @client_process(i32 %15, i32* %3, i32 %0, i32 %1)
br label %19
19: ; preds = %17, %11
br label %11
}