#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 scalar_t__ off_t;

/* Variables and functions */
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int const);
scalar_t__ lseek(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int sprintf(char *, char *, int const);
int /*<<< orphan*/ stderr;
int write(int, char *, int);
void timeoutArray(int *fdArray, const int len, const int timeoutSec) {
  for (size_t i = 0; i < len; i++) {
    fprintf(stderr, "%d ", fdArray[i]);
    char buf[100];
    int l = sprintf(buf, "%d", timeoutSec);
    int w = write(fdArray[i], buf, l);
    if (w < 0) {
      perror(buf);
      exit(-1);
    }
    off_t ot = lseek(fdArray[i], 0, SEEK_SET);
    if (ot < 0) {
      perror(buf);
      exit(-1);
    }
  }
  fprintf(stderr, "  -> %d\n", timeoutSec);
}


x86 assembly (clang, -O0):
<timeoutArray>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
cmp    %rcx,%rax
jae    1260 <timeoutArray+0x100>
mov    0x2e4b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe57(%rip),%rsi
call   1050 <fprintf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xe48(%rip),%rsi
call   1070 <sprintf@plt>
mov    %eax,-0x84(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
lea    -0x80(%rbp),%rsi
mov    -0x84(%rbp),%edx
call   1030 <write@plt>
mov    %eax,-0x88(%rbp)
cmpl   $0x0,-0x88(%rbp)
jge    1207 <timeoutArray+0xa7>
lea    -0x80(%rbp),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2dbf(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %rax,-0x90(%rbp)
cmpq   $0x0,-0x90(%rbp)
jge    124a <timeoutArray+0xea>
lea    -0x80(%rbp),%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    124f <timeoutArray+0xef>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    117d <timeoutArray+0x1d>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%edx
lea    0xd94(%rip),%rsi
call   1050 <fprintf@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timeoutArray>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %edx,%r12d
test   %esi,%esi
je     11e9 <timeoutArray+0x89>
mov    %rdi,%rbx
movslq %esi,%r13
xor    %r14d,%r14d
mov    %rsp,%rbp
mov    0x2e50(%rip),%r15
nopl   0x0(%rax,%rax,1)
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
mov    (%rbx,%r14,4),%edx
lea    0xe5c(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbp,%rdi
lea    0xe51(%rip),%rsi
mov    %r12d,%edx
call   1070 <sprintf@plt>
mov    (%rbx,%r14,4),%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %eax,%eax
js     120f <timeoutArray+0xaf>
mov    (%rbx,%r14,4),%edi
mov    (%r15),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
test   %rax,%rax
js     120f <timeoutArray+0xaf>
add    $0x1,%r14
cmp    %r14,%r13
jne    1190 <timeoutArray+0x30>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe0e(%rip),%rsi
mov    %r12d,%edx
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fprintf@plt>
mov    %rsp,%rdi
call   1060 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"%d\00"
@SEEK_SET = global i32 0
@.str.2 = [9 x i8] c" -> %d\0A\00"
define void @timeoutArray(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca [100 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i64 0, i64* %7
br label %12
12: ; preds = %54, %3
%13 = load i64, i64* %7
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %57
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = load i32*, i32** %4
%20 = load i64, i64* %7
%21 = getelementptr inbounds i32, i32* %19, i64 %20
%22 = load i32, i32* %21
%23 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%25 = load i32, i32* %6
%26 = call i32 @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %25)
store i32 %26, i32* %9
%27 = load i32*, i32** %4
%28 = load i64, i64* %7
%29 = getelementptr inbounds i32, i32* %27, i64 %28
%30 = load i32, i32* %29
%31 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%32 = load i32, i32* %9
%33 = call i32 @write(i32 %30, i8* %31, i32 %32)
store i32 %33, i32* %10
%34 = load i32, i32* %10
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %17
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%38 = call i32 @perror(i8* %37)
%39 = call i32 @exit(i32 -1)
unreachable
40: ; preds = %17
%41 = load i32*, i32** %4
%42 = load i64, i64* %7
%43 = getelementptr inbounds i32, i32* %41, i64 %42
%44 = load i32, i32* %43
%45 = load i32, i32* @SEEK_SET
%46 = call i64 @lseek(i32 %44, i32 0, i32 %45)
store i64 %46, i64* %11
%47 = load i64, i64* %11
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %40
%50 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%51 = call i32 @perror(i8* %50)
%52 = call i32 @exit(i32 -1)
unreachable
53: ; preds = %40
br label %54
54: ; preds = %53
%55 = load i64, i64* %7
%56 = add i64 %55, 1
store i64 %56, i64* %7
br label %12
57: ; preds = %12
%58 = load i32, i32* @stderr
%59 = load i32, i32* %6
%60 = call i32 @fprintf(i32 %58, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %59)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [4 x i8] c"%d \00"
@.str.1 = [3 x i8] c"%d\00"
@SEEK_SET = global i32 0
@.str.2 = [9 x i8] c" -> %d\0A\00"
define void @timeoutArray(i32* nocapture %0, i32 %1, i32 %2) {
%4 = alloca [100 x i8]
%5 = icmp eq i32 %1, 0
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = sext i32 %1 to i64
br label %12
9: ; preds = %33, %3
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %2)
ret void
12: ; preds = %6, %33
%13 = phi i64 [ 0, %6 ], [ %34, %33 ]
%14 = load i32, i32* @stderr
%15 = getelementptr inbounds i32, i32* %0, i64 %13
%16 = load i32, i32* %15
%17 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = call i32 @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%19 = load i32, i32* %15
%20 = call i32 @write(i32 %19, i8* %7, i32 %18)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %12
%23 = call i32 @perror(i8* %7)
%24 = tail call i32 @exit(i32 -1)
unreachable
25: ; preds = %12
%26 = load i32, i32* %15
%27 = load i32, i32* @SEEK_SET
%28 = tail call i64 @lseek(i32 %26, i32 0, i32 %27)
%29 = icmp slt i64 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = call i32 @perror(i8* %7)
%32 = tail call i32 @exit(i32 -1)
unreachable
33: ; preds = %25
%34 = add nuw i64 %13, 1
%35 = icmp eq i64 %34, %8
br i1 %35, label %9, label %12
}