#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*/ init();
int /*<<< orphan*/ led_out(unsigned int);
int main(void) {
  unsigned int cnt = 0;
  init();
  for (;;) {
    if (!(*((volatile unsigned int *)0xfffff43c) & 0x00000010)) {
      cnt = cnt < 0x0f ? cnt + 1 : 0;
    }
    led_out(cnt);
    while (*((volatile unsigned int *)0xfffff43c) & 0x00000010)
      ;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1030 <init@plt>
mov    $0xfffff43c,%eax
mov    (%rax),%eax
and    $0x10,%eax
cmp    $0x0,%eax
jne    1178 <main+0x58>
cmpl   $0xf,-0x8(%rbp)
jae    1168 <main+0x48>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <main+0x52>
xor    %eax,%eax
mov    %eax,-0xc(%rbp)
jmp    1172 <main+0x52>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <led_out@plt>
mov    $0xfffff43c,%eax
mov    (%rax),%eax
and    $0x10,%eax
cmp    $0x0,%eax
je     1198 <main+0x78>
jmp    1180 <main+0x60>
jmp    113d <main+0x1d>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0xfffff43c,%ebx
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <init@plt>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%eax
lea    0x1(%rax),%ebp
cmp    $0xf,%eax
cmovae %r14d,%ebp
testl  $0x10,(%rbx)
cmovne %eax,%ebp
mov    %ebp,%edi
call   1040 <led_out@plt>
nopl   0x0(%rax)
testl  $0x10,(%rbx)
jne    1160 <main+0x40>
jmp    1140 <main+0x20>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i32 (...) @init()
br label %4
4: ; preds = %25, %0
%5 = load volatile i32, i32* inttoptr (i64 4294964284 to i32*)
%6 = and i32 %5, 16
%7 = icmp ne i32 %6, 0
br i1 %7, label %17, label %8
8: ; preds = %4
%9 = load i32, i32* %2
%10 = icmp ult i32 %9, 15
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* %2
%13 = add i32 %12, 1
br label %15
14: ; preds = %8
br label %15
15: ; preds = %14, %11
%16 = phi i32 [ %13, %11 ], [ 0, %14 ]
store i32 %16, i32* %2
br label %17
17: ; preds = %15, %4
%18 = load i32, i32* %2
%19 = call i32 @led_out(i32 %18)
br label %20
20: ; preds = %24, %17
%21 = load volatile i32, i32* inttoptr (i64 4294964284 to i32*)
%22 = and i32 %21, 16
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
br label %20
25: ; preds = %20
br label %4
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @init()
br label %2
2: ; preds = %12, %0
%3 = phi i32 [ 0, %0 ], [ %10, %12 ]
%4 = load volatile i32, i32* inttoptr (i64 4294964284 to i32*)
%5 = and i32 %4, 16
%6 = icmp eq i32 %5, 0
%7 = icmp ult i32 %3, 15
%8 = add i32 %3, 1
%9 = select i1 %7, i32 %8, i32 0
%10 = select i1 %6, i32 %9, i32 %3
%11 = tail call i32 @led_out(i32 %10)
br label %12
12: ; preds = %12, %2
%13 = load volatile i32, i32* inttoptr (i64 4294964284 to i32*)
%14 = and i32 %13, 16
%15 = icmp eq i32 %14, 0
br i1 %15, label %2, label %12
}