#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*/ dummy(unsigned int);
int /*<<< orphan*/ led_init();
int /*<<< orphan*/ led_off();
int /*<<< orphan*/ led_on();
int /*<<< orphan*/ uart_init();
int /*<<< orphan*/ uart_puts(char *);
int notmain(void) {
  unsigned int ra;
  uart_init();
  led_init();
  ra = 0;
  while (1) {
    uart_puts("LED on\n");
    led_on();
    for (ra = 0; ra < 0x100000; ra++)
      dummy(ra);
    uart_puts("LED off\n");
    led_off();
    for (ra = 0; ra < 0x100000; ra++)
      dummy(ra);
  }
  return (0);
}


x86 assembly (clang, -O0):
<notmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <uart_init@plt>
mov    $0x0,%al
call   1060 <led_init@plt>
movl   $0x0,-0x4(%rbp)
lea    0xe7c(%rip),%rdi
call   1080 <uart_puts@plt>
mov    $0x0,%al
call   1070 <led_on@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x100000,-0x4(%rbp)
jae    11ba <notmain+0x5a>
mov    -0x4(%rbp),%edi
call   1030 <dummy@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1197 <notmain+0x37>
lea    0xe47(%rip),%rdi
call   1080 <uart_puts@plt>
mov    $0x0,%al
call   1040 <led_off@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x100000,-0x4(%rbp)
jae    11f7 <notmain+0x97>
mov    -0x4(%rbp),%edi
call   1030 <dummy@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11d4 <notmain+0x74>
jmp    117d <notmain+0x1d>

x86 assembly (clang, -O2):
<notmain>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <uart_init@plt>
xor    %eax,%eax
call   1060 <led_init@plt>
lea    0xe87(%rip),%r14
lea    0xe88(%rip),%rbx
mov    %r14,%rdi
call   1080 <uart_puts@plt>
xor    %eax,%eax
call   1070 <led_on@plt>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
call   1030 <dummy@plt>
add    $0x1,%ebp
cmp    $0x100000,%ebp
jne    11a0 <notmain+0x40>
mov    %rbx,%rdi
call   1080 <uart_puts@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <led_off@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebp,%edi
call   1030 <dummy@plt>
add    $0x1,%ebp
cmp    $0x100000,%ebp
jne    11d0 <notmain+0x70>
jmp    1180 <notmain+0x20>

LLVM IR (-O0):
@.str = [8 x i8] c"LED on\0A\00"
@.str.1 = [9 x i8] c"LED off\0A\00"
define i32 @notmain() {
%1 = alloca i32
%2 = call i32 (...) @uart_init()
%3 = call i32 (...) @led_init()
store i32 0, i32* %1
br label %4
4: ; preds = %0, %28
%5 = call i32 @uart_puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @led_on()
store i32 0, i32* %1
br label %7
7: ; preds = %13, %4
%8 = load i32, i32* %1
%9 = icmp ult i32 %8, 1048576
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i32, i32* %1
%12 = call i32 @dummy(i32 %11)
br label %13
13: ; preds = %10
%14 = load i32, i32* %1
%15 = add i32 %14, 1
store i32 %15, i32* %1
br label %7
16: ; preds = %7
%17 = call i32 @uart_puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%18 = call i32 (...) @led_off()
store i32 0, i32* %1
br label %19
19: ; preds = %25, %16
%20 = load i32, i32* %1
%21 = icmp ult i32 %20, 1048576
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i32, i32* %1
%24 = call i32 @dummy(i32 %23)
br label %25
25: ; preds = %22
%26 = load i32, i32* %1
%27 = add i32 %26, 1
store i32 %27, i32* %1
br label %19
28: ; preds = %19
br label %4
}

LLVM IR (-O2):
@.str = [8 x i8] c"LED on\0A\00"
@.str.1 = [9 x i8] c"LED off\0A\00"
define i32 @notmain() {
%1 = tail call i32 (...) @uart_init()
%2 = tail call i32 (...) @led_init()
br label %3
3: ; preds = %14, %0
%4 = tail call i32 @uart_puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (...) @led_on()
br label %6
6: ; preds = %3, %6
%7 = phi i32 [ 0, %3 ], [ %9, %6 ]
%8 = tail call i32 @dummy(i32 %7)
%9 = add nuw nsw i32 %7, 1
%10 = icmp eq i32 %9, 1048576
br i1 %10, label %11, label %6
11: ; preds = %6
%12 = tail call i32 @uart_puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 (...) @led_off()
br label %14
14: ; preds = %11, %14
%15 = phi i32 [ 0, %11 ], [ %17, %14 ]
%16 = tail call i32 @dummy(i32 %15)
%17 = add nuw nsw i32 %15, 1
%18 = icmp eq i32 %17, 1048576
br i1 %18, label %3, label %14
}