#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*/ fflush(int /*<<< orphan*/);
scalar_t__ got_signal();
int /*<<< orphan*/ printf(char *, unsigned long long, int);
int /*<<< orphan*/ reset_signal();
int /*<<< orphan*/ set_default_signal_count(int);
int /*<<< orphan*/ set_timer(int);
int /*<<< orphan*/ stdout;
int main() {
  unsigned long long i = 0;
  int count = 10;
  set_timer(500);
  set_default_signal_count(100);
  while (1) {
    if (got_signal()) {
      printf("\r%llu, %d", i, count);
      fflush(stdout);
      reset_signal();
    }
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0xa,-0x14(%rbp)
mov    $0x1f4,%edi
call   1080 <set_timer@plt>
mov    $0x64,%edi
call   1040 <set_default_signal_count@plt>
mov    $0x0,%al
call   1030 <got_signal@plt>
cmp    $0x0,%rax
je     11cb <main+0x6b>
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xe4f(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
mov    $0x0,%al
call   1060 <reset_signal@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1192 <main+0x32>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    $0x1f4,%edi
call   1080 <set_timer@plt>
mov    $0x64,%edi
call   1040 <set_default_signal_count@plt>
lea    0xe80(%rip),%r14
mov    0x2e59(%rip),%r15
xor    %ebx,%ebx
jmp    1194 <main+0x34>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
xor    %eax,%eax
call   1030 <got_signal@plt>
test   %rax,%rax
je     1190 <main+0x30>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1050 <printf@plt>
mov    (%r15),%edi
call   1070 <fflush@plt>
xor    %eax,%eax
call   1060 <reset_signal@plt>
jmp    1190 <main+0x30>

LLVM IR (-O0):
@.str = [10 x i8] c"\0D%llu, %d\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
store i32 0, i32* %1
store i64 0, i64* %2
store i32 10, i32* %3
%4 = call i32 @set_timer(i32 500)
%5 = call i32 @set_default_signal_count(i32 100)
br label %6
6: ; preds = %0, %16
%7 = call i64 (...) @got_signal()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i64, i64* %2
%11 = load i32, i32* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %10, i32 %11)
%13 = load i32, i32* @stdout
%14 = call i32 @fflush(i32 %13)
%15 = call i32 (...) @reset_signal()
br label %16
16: ; preds = %9, %6
%17 = load i64, i64* %2
%18 = add i64 %17, 1
store i64 %18, i64* %2
br label %6
}

LLVM IR (-O2):
@.str = [10 x i8] c"\0D%llu, %d\00"
@stdout = global i32 0
define i32 @main() {
%1 = tail call i32 @set_timer(i32 500)
%2 = tail call i32 @set_default_signal_count(i32 100)
br label %3
3: ; preds = %12, %0
%4 = phi i64 [ 0, %0 ], [ %13, %12 ]
%5 = tail call i64 (...) @got_signal()
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %4, i32 10)
%9 = load i32, i32* @stdout
%10 = tail call i32 @fflush(i32 %9)
%11 = tail call i32 (...) @reset_signal()
br label %12
12: ; preds = %7, %3
%13 = add i64 %4, 1
br label %3
}