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

/* Variables and functions */
int /*<<< orphan*/ createStreams(int, char **);
long currentTimeMillis();
int /*<<< orphan*/ doPersistenceCheck();
int /*<<< orphan*/ setupSignalHandler();
int /*<<< orphan*/ waitForInputs(int);
int main(int argc, char *argv[]) {
  long lastPersistenceCheck = currentTimeMillis();
  setupSignalHandler();
  createStreams(argc, argv);
  while (1) {
    long time = currentTimeMillis();
    if ((time - lastPersistenceCheck) > 5000) {
      doPersistenceCheck();
      time = lastPersistenceCheck = currentTimeMillis();
    }
    waitForInputs(5000 - (time - lastPersistenceCheck));
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1040 <currentTimeMillis@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1070 <setupSignalHandler@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1050 <createStreams@plt>
mov    $0x0,%al
call   1040 <currentTimeMillis@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x18(%rbp),%rax
cmp    $0x1388,%rax
jle    11b9 <main+0x69>
mov    $0x0,%al
call   1060 <doPersistenceCheck@plt>
mov    $0x0,%al
call   1040 <currentTimeMillis@plt>
mov    %rax,-0x18(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
sub    -0x18(%rbp),%rcx
mov    $0x1388,%eax
sub    %rcx,%rax
mov    %eax,%edi
call   1030 <waitForInputs@plt>
jmp    1184 <main+0x34>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
xor    %eax,%eax
call   1040 <currentTimeMillis@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1070 <setupSignalHandler@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1050 <createStreams@plt>
jmp    118f <main+0x3f>
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%edi
sub    %eax,%edi
add    $0x1388,%edi
call   1030 <waitForInputs@plt>
xor    %eax,%eax
call   1040 <currentTimeMillis@plt>
mov    %rax,%rcx
sub    %rbx,%rcx
cmp    $0x1389,%rcx
jl     1180 <main+0x30>
xor    %eax,%eax
call   1060 <doPersistenceCheck@plt>
xor    %eax,%eax
call   1040 <currentTimeMillis@plt>
mov    %rax,%rbx
jmp    1180 <main+0x30>

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i64 (...) @currentTimeMillis()
store i64 %8, i64* %6
%9 = call i32 (...) @setupSignalHandler()
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = call i32 @createStreams(i32 %10, i8** %11)
br label %13
13: ; preds = %2, %22
%14 = call i64 (...) @currentTimeMillis()
store i64 %14, i64* %7
%15 = load i64, i64* %7
%16 = load i64, i64* %6
%17 = sub nsw i64 %15, %16
%18 = icmp sgt i64 %17, 5000
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = call i32 (...) @doPersistenceCheck()
%21 = call i64 (...) @currentTimeMillis()
store i64 %21, i64* %6
store i64 %21, i64* %7
br label %22
22: ; preds = %19, %13
%23 = load i64, i64* %7
%24 = load i64, i64* %6
%25 = sub nsw i64 %23, %24
%26 = sub nsw i64 5000, %25
%27 = trunc i64 %26 to i32
%28 = call i32 @waitForInputs(i32 %27)
br label %13
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i64 (...) @currentTimeMillis()
%4 = tail call i32 (...) @setupSignalHandler()
%5 = tail call i32 @createStreams(i32 %0, i8** %1)
br label %6
6: ; preds = %14, %2
%7 = phi i64 [ %3, %2 ], [ %15, %14 ]
%8 = tail call i64 (...) @currentTimeMillis()
%9 = sub nsw i64 %8, %7
%10 = icmp sgt i64 %9, 5000
br i1 %10, label %11, label %14
11: ; preds = %6
%12 = tail call i32 (...) @doPersistenceCheck()
%13 = tail call i64 (...) @currentTimeMillis()
br label %14
14: ; preds = %11, %6
%15 = phi i64 [ %13, %11 ], [ %7, %6 ]
%16 = phi i64 [ %13, %11 ], [ %8, %6 ]
%17 = sub i64 %15, %16
%18 = trunc i64 %17 to i32
%19 = add i32 %18, 5000
%20 = tail call i32 @waitForInputs(i32 %19)
br label %6
}