#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;
  struct timeval tv = {60, 0};
  int max;
  while (1) {
    FD_ZERO(&set);
    FD_SET(localfd, &set);
    max = localfd;
    max = select(max + 1, &set, NULL, NULL, &tv);
    if (max != -1)
      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    -0x8(%rbp),%edi
lea    -0xc(%rbp),%rsi
call   1060 <FD_SET@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%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,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
je     11ad <client_loop+0x6d>
mov    -0x1c(%rbp),%edi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    -0xc(%rbp),%rsi
call   1050 <client_process@plt>
jmp    1159 <client_loop+0x19>

x86 assembly (clang, -O2):
<client_loop>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%r14d
movq   $0x3c,(%rsp)
lea    0x1(%rbx),%r15d
lea    0xc(%rsp),%rbp
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
call   1030 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
call   1060 <FD_SET@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %r12,%r8
call   1040 <select@plt>
cmp    $0xffffffff,%eax
je     1170 <client_loop+0x30>
mov    %eax,%edi
mov    %rbp,%rsi
mov    %r14d,%edx
mov    %ebx,%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 %struct.timeval
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = bitcast %struct.timeval* %6 to i8*
br label %9
9: ; preds = %2, %24
%10 = call i32 @FD_ZERO(i32* %5)
%11 = load i32, i32* %4
%12 = call i32 @FD_SET(i32 %11, i32* %5)
%13 = load i32, i32* %4
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = add nsw i32 %14, 1
%16 = call i32 @select(i32 %15, i32* %5, i32* null, i32* null, %struct.timeval* %6)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, -1
br i1 %18, label %19, label %24
19: ; preds = %9
%20 = load i32, i32* %7
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @client_process(i32 %20, i32* %5, i32 %21, i32 %22)
br label %24
24: ; preds = %19, %9
br label %9
}

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*
store i64 60, i64* %4
%8 = add nsw i32 %1, 1
br label %9
9: ; preds = %16, %2
%10 = call i32 @FD_ZERO(i32* %3)
%11 = call i32 @FD_SET(i32 %1, i32* %3)
%12 = call i32 @select(i32 %8, i32* %3, i32* null, i32* null, %struct.timeval* %5)
%13 = icmp eq i32 %12, -1
br i1 %13, label %16, label %14
14: ; preds = %9
%15 = call i32 @client_process(i32 %12, i32* %3, i32 %0, i32 %1)
br label %16
16: ; preds = %14, %9
br label %9
}