#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 tv_sec;
  int tv_usec;
};
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ STDOUT_FILENO;
int atoi(char *);
int /*<<< orphan*/ close(int);
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int open(char *, int /*<<< orphan*/);
int read(int, unsigned char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ write(int /*<<< orphan*/, unsigned char *, int);
int main(int argc, char *argv[]) {
  int input_file;
  int result;
  int stable;
  int backup_file;
  int byte_read;
  int timeout;
  int index;
  fd_set set;
  struct timeval tv;
  unsigned char ts_packet[188];
  if (argc >= 4) {
    input_file = open(argv[1], O_RDONLY);
    if (input_file < 0) {
      fprintf(stderr, "Can't open file %s\n", argv[1]);
      return 0;
    }
    backup_file = open(argv[2], O_RDONLY);
    if (backup_file < 0) {
      fprintf(stderr, "Can't open file %s\n", argv[2]);
      return 0;
    }
    timeout = atoi(argv[3]);
    if (timeout == 0) {
      fprintf(stderr, "Timeout has to be bigger than 0\n");
      return 0;
    }
  } else {
    fprintf(stderr,
            "Usage: 'tstimeout inputfile.ts backupfile.ts timeout_in_ms'\n");
    return 0;
  }
  fcntl(input_file, F_SETFL, fcntl(input_file, F_GETFL, 0) | O_NONBLOCK);
  index = 0;
  tv.tv_sec = timeout / 1000;
  tv.tv_usec = (timeout % 1000) * 1000;
  stable = 1;
  while (1) {
    FD_ZERO(&set);
    FD_SET(input_file, &set);
    if (stable) {
      tv.tv_sec = timeout / 1000;
      tv.tv_usec = (timeout % 1000) * 1000;
    } else {
      tv.tv_sec = 0LL;
      tv.tv_usec = 0LL;
    }
    result = select(input_file + 1, &set, NULL, NULL, &tv);
    if (result > 0) {
      if (FD_ISSET(input_file, &set)) {
        byte_read = read(input_file, ts_packet + index, 188 - index);
        if (byte_read > 0) {
          stable = 1;
          index += byte_read;
          if (index == 188) {
            write(STDOUT_FILENO, ts_packet, 188);
            index = 0;
          }
        }
      }
    } else {
      stable = 0;
      read(backup_file, ts_packet, 188);
      write(STDOUT_FILENO, ts_packet, 188);
    }
  }
  close(input_file);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jl     12a1 <main+0x101>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1211 <main+0x71>
mov    0x2ddb(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe02(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    147e <main+0x2de>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2db8(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    125f <main+0xbf>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdb4(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    147e <main+0x2de>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    129c <main+0xfc>
mov    0x2d48(%rip),%rax
mov    (%rax),%edi
lea    0xd8b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    147e <main+0x2de>
jmp    12c4 <main+0x124>
mov    0x2d20(%rip),%rax
mov    (%rax),%edi
lea    0xd84(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    147e <main+0x2de>
mov    -0x14(%rbp),%eax
mov    %eax,-0x108(%rbp)
mov    0x2cec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x104(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2cd2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    -0x108(%rbp),%edi
mov    -0x104(%rbp),%esi
mov    %eax,%edx
mov    0x2cdc(%rip),%rax
or     (%rax),%edx
call   1030 <fcntl@plt>
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
imul   $0x3e8,%edx,%eax
mov    %eax,-0x34(%rbp)
movl   $0x1,-0x1c(%rbp)
lea    -0x30(%rbp),%rdi
call   1080 <FD_ZERO@plt>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   10c0 <FD_SET@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1381 <main+0x1e1>
mov    -0x28(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
mov    -0x28(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
imul   $0x3e8,%edx,%eax
mov    %eax,-0x34(%rbp)
jmp    138f <main+0x1ef>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x14(%rbp),%edi
add    $0x1,%edi
lea    -0x30(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x38(%rbp),%r8
mov    %rcx,%rdx
call   1090 <select@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jle    1444 <main+0x2a4>
mov    -0x14(%rbp),%edi
lea    -0x30(%rbp),%rsi
call   1050 <FD_ISSET@plt>
cmp    $0x0,%rax
je     143f <main+0x29f>
mov    -0x14(%rbp),%edi
lea    -0x100(%rbp),%rsi
movslq -0x2c(%rbp),%rax
add    %rax,%rsi
mov    $0xbc,%edx
sub    -0x2c(%rbp),%edx
call   1060 <read@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jle    143a <main+0x29a>
movl   $0x1,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
cmpl   $0xbc,-0x2c(%rbp)
jne    1435 <main+0x295>
mov    0x2bd5(%rip),%rax
mov    (%rax),%edi
lea    -0x100(%rbp),%rsi
mov    $0xbc,%edx
call   1040 <write@plt>
movl   $0x0,-0x2c(%rbp)
jmp    143a <main+0x29a>
jmp    143f <main+0x29f>
jmp    1479 <main+0x2d9>
movl   $0x0,-0x1c(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x100(%rbp),%rsi
mov    $0xbc,%edx
call   1060 <read@plt>
mov    0x2b8a(%rip),%rax
mov    (%rax),%edi
lea    -0x100(%rbp),%rsi
mov    $0xbc,%edx
call   1040 <write@plt>
jmp    133b <main+0x19b>
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
cmp    $0x4,%edi
jl     1379 <main+0x1d9>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
mov    0x2e10(%rip),%r14
mov    (%r14),%esi
call   10a0 <open@plt>
test   %eax,%eax
js     1392 <main+0x1f2>
mov    %eax,%ebx
mov    0x10(%rbp),%rdi
mov    (%r14),%esi
call   10a0 <open@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
js     13a1 <main+0x201>
mov    0x18(%rbp),%rdi
call   10b0 <atoi@plt>
test   %eax,%eax
je     13d0 <main+0x230>
mov    %eax,%ebp
mov    0x2db4(%rip),%rax
mov    (%rax),%r14d
mov    0x2da2(%rip),%rax
mov    (%rax),%esi
xor    %r13d,%r13d
mov    %ebx,%edi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    0x2db5(%rip),%rcx
or     (%rcx),%eax
mov    %ebx,%edi
mov    %r14d,%esi
mov    %eax,%edx
call   1030 <fcntl@plt>
movslq %ebp,%rax
imul   $0x10624dd3,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x26,%rcx
add    %eax,%ecx
mov    %ecx,(%rsp)
mov    %rcx,0x20(%rsp)
imul   $0x3e8,%ecx,%eax
sub    %eax,%ebp
imul   $0x3e8,%ebp,%eax
mov    %eax,0x10(%rsp)
mov    %eax,0x4(%rsp)
mov    %ebx,%eax
add    $0x1,%eax
mov    %eax,0x14(%rsp)
mov    $0x1,%r12d
lea    0x2c(%rsp),%rbp
jmp    12c9 <main+0x129>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0xc(%rsp),%edi
lea    0x30(%rsp),%rsi
mov    $0xbc,%edx
call   1060 <read@plt>
xor    %r12d,%r12d
mov    0x18(%rsp),%rax
mov    %eax,%r14d
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
lea    0x30(%rsp),%rsi
mov    $0xbc,%edx
call   1040 <write@plt>
mov    %r14d,%r13d
test   %r12d,%r12d
mov    0x20(%rsp),%rax
mov    %eax,%r15d
cmove  %r12d,%r15d
cmovne 0x10(%rsp),%r12d
mov    %r13,0x18(%rsp)
movslq %r13d,%rax
lea    (%rsp,%rax,1),%r14
add    $0x30,%r14
mov    $0xbc,%r13d
sub    %eax,%r13d
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1080 <FD_ZERO@plt>
mov    %ebx,%edi
mov    %rbp,%rsi
call   10c0 <FD_SET@plt>
mov    %r15d,(%rsp)
mov    %r12d,0x4(%rsp)
mov    0x14(%rsp),%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
mov    %rsp,%r8
call   1090 <select@plt>
test   %eax,%eax
jle    1290 <main+0xf0>
mov    %ebx,%edi
mov    %rbp,%rsi
call   1050 <FD_ISSET@plt>
test   %rax,%rax
je     1300 <main+0x160>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r13d,%edx
call   1060 <read@plt>
test   %eax,%eax
jle    1300 <main+0x160>
mov    0x18(%rsp),%r13
add    %eax,%r13d
xor    %r14d,%r14d
mov    $0x1,%r12d
cmp    $0xbc,%r13d
jne    12c9 <main+0x129>
jmp    12ae <main+0x10e>
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
lea    0xcac(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    13bc <main+0x21c>
mov    0x2c2f(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbp),%rdx
jmp    13ae <main+0x20e>
mov    0x2c20(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbp),%rdx
lea    0xc4b(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bf1(%rip),%rax
mov    (%rax),%edi
lea    0xc34(%rip),%rsi
jmp    1389 <main+0x1e9>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"Can't open file %s\0A\00"
@.str.1 = [33 x i8] c"Timeout has to be bigger than 0\0A\00"
@.str.2 = [61 x i8] c"Usage: 'tstimeout inputfile.ts backupfile.ts timeout_in_ms'\0A\00"
@F_SETFL = global i32 0
@F_GETFL = global i32 0
@O_NONBLOCK = global i32 0
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca %struct.timeval
%15 = alloca [188 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp sge i32 %16, 4
br i1 %17, label %18, label %57
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = load i32, i32* @O_RDONLY
%23 = call i32 @open(i8* %21, i32 %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %32
26: ; preds = %18
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %30)
store i32 0, i32* %3
br label %135
32: ; preds = %18
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = load i32, i32* @O_RDONLY
%37 = call i32 @open(i8* %35, i32 %36)
store i32 %37, i32* %9
%38 = load i32, i32* %9
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %46
40: ; preds = %32
%41 = load i32, i32* @stderr
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %44)
store i32 0, i32* %3
br label %135
46: ; preds = %32
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 3
%49 = load i8*, i8** %48
%50 = call i32 @atoi(i8* %49)
store i32 %50, i32* %11
%51 = load i32, i32* %11
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %46
%54 = load i32, i32* @stderr
%55 = call i32 (i32, i8*, ...) @fprintf(i32 %54, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %135
56: ; preds = %46
br label %60
57: ; preds = %2
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %3
br label %135
60: ; preds = %56
%61 = load i32, i32* %6
%62 = load i32, i32* @F_SETFL
%63 = load i32, i32* %6
%64 = load i32, i32* @F_GETFL
%65 = call i32 @fcntl(i32 %63, i32 %64, i32 0)
%66 = load i32, i32* @O_NONBLOCK
%67 = or i32 %65, %66
%68 = call i32 @fcntl(i32 %61, i32 %62, i32 %67)
store i32 0, i32* %12
%69 = load i32, i32* %11
%70 = sdiv i32 %69, 1000
%71 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
store i32 %70, i32* %71
%72 = load i32, i32* %11
%73 = srem i32 %72, 1000
%74 = mul nsw i32 %73, 1000
%75 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
store i32 %74, i32* %75
store i32 1, i32* %8
br label %76
76: ; preds = %60, %134
%77 = call i32 @FD_ZERO(i32* %13)
%78 = load i32, i32* %6
%79 = call i32 @FD_SET(i32 %78, i32* %13)
%80 = load i32, i32* %8
%81 = icmp ne i32 %80, 0
br i1 %81, label %82, label %90
82: ; preds = %76
%83 = load i32, i32* %11
%84 = sdiv i32 %83, 1000
%85 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
store i32 %84, i32* %85
%86 = load i32, i32* %11
%87 = srem i32 %86, 1000
%88 = mul nsw i32 %87, 1000
%89 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
store i32 %88, i32* %89
br label %93
90: ; preds = %76
%91 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
store i32 0, i32* %91
%92 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
store i32 0, i32* %92
br label %93
93: ; preds = %90, %82
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 1
%96 = call i32 @select(i32 %95, i32* %13, i32* null, i32* null, %struct.timeval* %14)
store i32 %96, i32* %7
%97 = load i32, i32* %7
%98 = icmp sgt i32 %97, 0
br i1 %98, label %99, label %127
99: ; preds = %93
%100 = load i32, i32* %6
%101 = call i64 @FD_ISSET(i32 %100, i32* %13)
%102 = icmp ne i64 %101, 0
br i1 %102, label %103, label %126
103: ; preds = %99
%104 = load i32, i32* %6
%105 = getelementptr inbounds [188 x i8], [188 x i8]* %15, i64 0, i64 0
%106 = load i32, i32* %12
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds i8, i8* %105, i64 %107
%109 = load i32, i32* %12
%110 = sub nsw i32 188, %109
%111 = call i32 @read(i32 %104, i8* %108, i32 %110)
store i32 %111, i32* %10
%112 = load i32, i32* %10
%113 = icmp sgt i32 %112, 0
br i1 %113, label %114, label %125
114: ; preds = %103
store i32 1, i32* %8
%115 = load i32, i32* %10
%116 = load i32, i32* %12
%117 = add nsw i32 %116, %115
store i32 %117, i32* %12
%118 = load i32, i32* %12
%119 = icmp eq i32 %118, 188
br i1 %119, label %120, label %124
120: ; preds = %114
%121 = load i32, i32* @STDOUT_FILENO
%122 = getelementptr inbounds [188 x i8], [188 x i8]* %15, i64 0, i64 0
%123 = call i32 @write(i32 %121, i8* %122, i32 188)
store i32 0, i32* %12
br label %124
124: ; preds = %120, %114
br label %125
125: ; preds = %124, %103
br label %126
126: ; preds = %125, %99
br label %134
127: ; preds = %93
store i32 0, i32* %8
%128 = load i32, i32* %9
%129 = getelementptr inbounds [188 x i8], [188 x i8]* %15, i64 0, i64 0
%130 = call i32 @read(i32 %128, i8* %129, i32 188)
%131 = load i32, i32* @STDOUT_FILENO
%132 = getelementptr inbounds [188 x i8], [188 x i8]* %15, i64 0, i64 0
%133 = call i32 @write(i32 %131, i8* %132, i32 188)
br label %134
134: ; preds = %127, %126
br label %76
135: ; preds = %57, %53, %40, %26
%136 = load i32, i32* %3
ret i32 %136
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
@O_RDONLY = global i32 0
@stderr = global i32 0
@.str = [20 x i8] c"Can't open file %s\0A\00"
@.str.1 = [33 x i8] c"Timeout has to be bigger than 0\0A\00"
@.str.2 = [61 x i8] c"Usage: 'tstimeout inputfile.ts backupfile.ts timeout_in_ms'\0A\00"
@F_SETFL = global i32 0
@F_GETFL = global i32 0
@O_NONBLOCK = global i32 0
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.timeval
%5 = alloca [188 x i8]
%6 = bitcast i32* %3 to i8*
%7 = bitcast %struct.timeval* %4 to i8*
%8 = getelementptr inbounds [188 x i8], [188 x i8]* %5, i64 0, i64 0
%9 = icmp sgt i32 %0, 3
br i1 %9, label %10, label %38
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = load i32, i32* @O_RDONLY
%14 = tail call i32 @open(i8* %12, i32 %13)
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %11
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %88
20: ; preds = %10
%21 = getelementptr inbounds i8*, i8** %1, i64 2
%22 = load i8*, i8** %21
%23 = load i32, i32* @O_RDONLY
%24 = tail call i32 @open(i8* %22, i32 %23)
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %21
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %28)
br label %88
30: ; preds = %20
%31 = getelementptr inbounds i8*, i8** %1, i64 3
%32 = load i8*, i8** %31
%33 = tail call i32 @atoi(i8* %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %41
35: ; preds = %30
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %88
38: ; preds = %2
%39 = load i32, i32* @stderr
%40 = tail call i32 (i32, i8*, ...) @fprintf(i32 %39, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.2, i64 0, i64 0))
br label %88
41: ; preds = %30
%42 = load i32, i32* @F_SETFL
%43 = load i32, i32* @F_GETFL
%44 = tail call i32 @fcntl(i32 %14, i32 %43, i32 0)
%45 = load i32, i32* @O_NONBLOCK
%46 = or i32 %45, %44
%47 = tail call i32 @fcntl(i32 %14, i32 %42, i32 %46)
%48 = sdiv i32 %33, 1000
%49 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
store i32 %48, i32* %49
%50 = srem i32 %33, 1000
%51 = mul nsw i32 %50, 1000
%52 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
store i32 %51, i32* %52
%53 = add nuw nsw i32 %14, 1
br label %54
54: ; preds = %78, %41
%55 = phi i32 [ 1, %41 ], [ %79, %78 ]
%56 = phi i32 [ 0, %41 ], [ %80, %78 ]
%57 = icmp eq i32 %55, 0
%58 = select i1 %57, i32 0, i32 %48
%59 = select i1 %57, i32 0, i32 %51
%60 = sext i32 %56 to i64
%61 = getelementptr inbounds [188 x i8], [188 x i8]* %5, i64 0, i64 %60
%62 = sub nsw i32 188, %56
br label %63
63: ; preds = %71, %54
%64 = call i32 @FD_ZERO(i32* %3)
%65 = call i32 @FD_SET(i32 %14, i32* %3)
store i32 %58, i32* %49
store i32 %59, i32* %52
%66 = call i32 @select(i32 %53, i32* %3, i32* null, i32* null, %struct.timeval* %4)
%67 = icmp sgt i32 %66, 0
br i1 %67, label %68, label %81
68: ; preds = %63
%69 = call i64 @FD_ISSET(i32 %14, i32* %3)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %72
71: ; preds = %68, %72
br label %63
72: ; preds = %68
%73 = call i32 @read(i32 %14, i8* %61, i32 %62)
%74 = icmp sgt i32 %73, 0
br i1 %74, label %75, label %71
75: ; preds = %72
%76 = add nsw i32 %73, %56
%77 = icmp eq i32 %76, 188
br i1 %77, label %83, label %78
78: ; preds = %75, %83
%79 = phi i32 [ %84, %83 ], [ 1, %75 ]
%80 = phi i32 [ %85, %83 ], [ %76, %75 ]
br label %54
81: ; preds = %63
%82 = call i32 @read(i32 %24, i8* %8, i32 188)
br label %83
83: ; preds = %75, %81
%84 = phi i32 [ 0, %81 ], [ 1, %75 ]
%85 = phi i32 [ %56, %81 ], [ 0, %75 ]
%86 = load i32, i32* @STDOUT_FILENO
%87 = call i32 @write(i32 %86, i8* %8, i32 188)
br label %78
88: ; preds = %38, %35, %26, %16
ret i32 0
}