#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*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ ledCleanup();
int /*<<< orphan*/ ledClearAll();
int /*<<< orphan*/ ledSend();
int ledSetup(int, int);
int nice(int);
int /*<<< orphan*/ setColor(int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usleep(int);
int main() {
  int t;
  int nc = nice(-20);
  nc += 0;
  if (ledSetup(18, 60) == -1) {
    fprintf(stderr, "cannot setup serial led.\n");
    return -1;
  }
  usleep(1000 * 1000 * 5);
  for (t = 0; t < 6 * 3600 * 60; t++) {
    int led;
    for (led = 0; led < 60; led++) {
      setColor(t, led);
    }
    ledSend();
    usleep(1000 * 1000 / 60);
  }
  ledClearAll();
  ledCleanup();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xffffffec,%edi
call   1070 <nice@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x0,%eax
mov    %eax,-0xc(%rbp)
mov    $0x12,%edi
mov    $0x3c,%esi
call   1040 <ledSetup@plt>
cmp    $0xffffffff,%eax
jne    11de <main+0x5e>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe33(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    125a <main+0xda>
mov    $0x4c4b40,%edi
call   10a0 <usleep@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x13c680,-0x8(%rbp)
jge    1245 <main+0xc5>
movl   $0x0,-0x10(%rbp)
cmpl   $0x3c,-0x10(%rbp)
jge    1226 <main+0xa6>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1090 <setColor@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1203 <main+0x83>
mov    $0x0,%al
call   1050 <ledSend@plt>
mov    $0x411a,%edi
call   10a0 <usleep@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11ef <main+0x6f>
mov    $0x0,%al
call   1030 <ledClearAll@plt>
mov    $0x0,%al
call   1080 <ledCleanup@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffec,%edi
call   1070 <nice@plt>
mov    $0x12,%edi
mov    $0x3c,%esi
call   1040 <ledSetup@plt>
cmp    $0xffffffff,%eax
je     11ff <main+0x7f>
mov    $0x4c4b40,%edi
call   10a0 <usleep@plt>
xor    %ebx,%ebx
nopl   (%rax)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %ebp,%esi
call   1090 <setColor@plt>
add    $0x1,%ebp
cmp    $0x3c,%ebp
jne    11c0 <main+0x40>
xor    %eax,%eax
call   1050 <ledSend@plt>
mov    $0x411a,%edi
call   10a0 <usleep@plt>
add    $0x1,%ebx
cmp    $0x13c680,%ebx
jne    11b0 <main+0x30>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <ledClearAll@plt>
xor    %eax,%eax
call   1080 <ledCleanup@plt>
jmp    1219 <main+0x99>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xdf1(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"cannot setup serial led.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @nice(i32 -20)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = add nsw i32 %6, 0
store i32 %7, i32* %3
%8 = call i32 @ledSetup(i32 18, i32 60)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %1
br label %38
13: ; preds = %0
%14 = call i32 @usleep(i32 5000000)
store i32 0, i32* %2
br label %15
15: ; preds = %32, %13
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 1296000
br i1 %17, label %18, label %35
18: ; preds = %15
store i32 0, i32* %4
br label %19
19: ; preds = %26, %18
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 60
br i1 %21, label %22, label %29
22: ; preds = %19
%23 = load i32, i32* %2
%24 = load i32, i32* %4
%25 = call i32 @setColor(i32 %23, i32 %24)
br label %26
26: ; preds = %22
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %19
29: ; preds = %19
%30 = call i32 (...) @ledSend()
%31 = call i32 @usleep(i32 16666)
br label %32
32: ; preds = %29
%33 = load i32, i32* %2
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
br label %15
35: ; preds = %15
%36 = call i32 (...) @ledClearAll()
%37 = call i32 (...) @ledCleanup()
store i32 0, i32* %1
br label %38
38: ; preds = %35, %10
%39 = load i32, i32* %1
ret i32 %39
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"cannot setup serial led.\0A\00"
define i32 @main() {
%1 = tail call i32 @nice(i32 -20)
%2 = tail call i32 @ledSetup(i32 18, i32 60)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %7
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %24
7: ; preds = %0
%8 = tail call i32 @usleep(i32 5000000)
br label %9
9: ; preds = %7, %16
%10 = phi i32 [ 0, %7 ], [ %19, %16 ]
br label %11
11: ; preds = %9, %11
%12 = phi i32 [ 0, %9 ], [ %14, %11 ]
%13 = tail call i32 @setColor(i32 %10, i32 %12)
%14 = add nuw nsw i32 %12, 1
%15 = icmp eq i32 %14, 60
br i1 %15, label %16, label %11
16: ; preds = %11
%17 = tail call i32 (...) @ledSend()
%18 = tail call i32 @usleep(i32 16666)
%19 = add nuw nsw i32 %10, 1
%20 = icmp eq i32 %19, 1296000
br i1 %20, label %21, label %9
21: ; preds = %16
%22 = tail call i32 (...) @ledClearAll()
%23 = tail call i32 (...) @ledCleanup()
br label %24
24: ; preds = %21, %4
%25 = phi i32 [ -1, %4 ], [ 0, %21 ]
ret i32 %25
}