#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*/ buzzer_freq_sets(unsigned int);
int /*<<< orphan*/ buzzer_init();
int /*<<< orphan*/ delay(int);
int /*<<< orphan*/ key_init();
int /*<<< orphan*/ putccc(int);
int /*<<< orphan*/ uart0_init();
int main(void) {
  unsigned int freq;
  uart0_init();
  key_init();
  buzzer_init();
  putccc('a');
  freq = 1000;
  buzzer_freq_sets(freq);
  while (1) {
    if (((*(volatile unsigned *)0x56000054) & 0x01) == 0) {
      putccc('z');
      putccc(10);
      putccc(13);
      if (freq < 2000)
        freq += 10;
      buzzer_freq_sets(freq);
    }
    if (((*(volatile unsigned *)0x56000054) & 0x02) == 0) {
      putccc('x');
      putccc(10);
      putccc(13);
      if (freq > 200)
        freq -= 10;
      delay(200);
      buzzer_freq_sets(freq);
    }
    delay(200);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <uart0_init@plt>
mov    $0x0,%al
call   1030 <key_init@plt>
mov    $0x0,%al
call   1070 <buzzer_init@plt>
mov    $0x61,%edi
call   1050 <putccc@plt>
movl   $0x3e8,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1080 <buzzer_freq_sets@plt>
mov    $0x56000054,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11ec <main+0x8c>
mov    $0x7a,%edi
call   1050 <putccc@plt>
mov    $0xa,%edi
call   1050 <putccc@plt>
mov    $0xd,%edi
call   1050 <putccc@plt>
cmpl   $0x7d0,-0x8(%rbp)
jae    11e4 <main+0x84>
mov    -0x8(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1080 <buzzer_freq_sets@plt>
mov    $0x56000054,%eax
mov    (%rax),%eax
and    $0x2,%eax
cmp    $0x0,%eax
jne    1245 <main+0xe5>
mov    $0x78,%edi
call   1050 <putccc@plt>
mov    $0xa,%edi
call   1050 <putccc@plt>
mov    $0xd,%edi
call   1050 <putccc@plt>
cmpl   $0xc8,-0x8(%rbp)
jbe    1233 <main+0xd3>
mov    -0x8(%rbp),%eax
sub    $0xa,%eax
mov    %eax,-0x8(%rbp)
mov    $0xc8,%edi
call   1060 <delay@plt>
mov    -0x8(%rbp),%edi
call   1080 <buzzer_freq_sets@plt>
mov    $0xc8,%edi
call   1060 <delay@plt>
jmp    119d <main+0x3d>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <uart0_init@plt>
xor    %eax,%eax
call   1030 <key_init@plt>
xor    %eax,%eax
call   1070 <buzzer_init@plt>
mov    $0x61,%edi
call   1050 <putccc@plt>
mov    $0x3e8,%r14d
mov    $0x3e8,%edi
call   1080 <buzzer_freq_sets@plt>
jmp    11aa <main+0x4a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xc8,%edi
call   1060 <delay@plt>
mov    0x56000054,%eax
test   $0x1,%al
jne    11ec <main+0x8c>
mov    $0x7a,%edi
call   1050 <putccc@plt>
mov    $0xa,%edi
call   1050 <putccc@plt>
mov    $0xd,%edi
call   1050 <putccc@plt>
lea    0xa(%r14),%ebx
cmp    $0x7d0,%r14d
cmovae %r14d,%ebx
mov    %ebx,%edi
call   1080 <buzzer_freq_sets@plt>
mov    %ebx,%r14d
testl  $0x2,0x56000054
jne    11a0 <main+0x40>
mov    $0x78,%edi
call   1050 <putccc@plt>
mov    $0xa,%edi
call   1050 <putccc@plt>
mov    $0xd,%edi
call   1050 <putccc@plt>
lea    -0xa(%r14),%ebx
cmp    $0xc9,%r14d
cmovb  %r14d,%ebx
mov    $0xc8,%edi
call   1060 <delay@plt>
mov    %ebx,%edi
call   1080 <buzzer_freq_sets@plt>
mov    %ebx,%r14d
jmp    11a0 <main+0x40>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @uart0_init()
%4 = call i32 (...) @key_init()
%5 = call i32 (...) @buzzer_init()
%6 = call i32 @putccc(i32 97)
store i32 1000, i32* %2
%7 = load i32, i32* %2
%8 = call i32 @buzzer_freq_sets(i32 %7)
br label %9
9: ; preds = %0, %42
%10 = load volatile i32, i32* inttoptr (i64 1442840660 to i32*)
%11 = and i32 %10, 1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %25
13: ; preds = %9
%14 = call i32 @putccc(i32 122)
%15 = call i32 @putccc(i32 10)
%16 = call i32 @putccc(i32 13)
%17 = load i32, i32* %2
%18 = icmp ult i32 %17, 2000
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i32, i32* %2
%21 = add i32 %20, 10
store i32 %21, i32* %2
br label %22
22: ; preds = %19, %13
%23 = load i32, i32* %2
%24 = call i32 @buzzer_freq_sets(i32 %23)
br label %25
25: ; preds = %22, %9
%26 = load volatile i32, i32* inttoptr (i64 1442840660 to i32*)
%27 = and i32 %26, 2
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %42
29: ; preds = %25
%30 = call i32 @putccc(i32 120)
%31 = call i32 @putccc(i32 10)
%32 = call i32 @putccc(i32 13)
%33 = load i32, i32* %2
%34 = icmp ugt i32 %33, 200
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = load i32, i32* %2
%37 = sub i32 %36, 10
store i32 %37, i32* %2
br label %38
38: ; preds = %35, %29
%39 = call i32 @delay(i32 200)
%40 = load i32, i32* %2
%41 = call i32 @buzzer_freq_sets(i32 %40)
br label %42
42: ; preds = %38, %25
%43 = call i32 @delay(i32 200)
br label %9
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @uart0_init()
%2 = tail call i32 (...) @key_init()
%3 = tail call i32 (...) @buzzer_init()
%4 = tail call i32 @putccc(i32 97)
%5 = tail call i32 @buzzer_freq_sets(i32 1000)
br label %6
6: ; preds = %33, %0
%7 = phi i32 [ 1000, %0 ], [ %34, %33 ]
%8 = load volatile i32, i32* inttoptr (i64 1442840660 to i32*)
%9 = and i32 %8, 1
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %19
11: ; preds = %6
%12 = tail call i32 @putccc(i32 122)
%13 = tail call i32 @putccc(i32 10)
%14 = tail call i32 @putccc(i32 13)
%15 = icmp ult i32 %7, 2000
%16 = add i32 %7, 10
%17 = select i1 %15, i32 %16, i32 %7
%18 = tail call i32 @buzzer_freq_sets(i32 %17)
br label %19
19: ; preds = %11, %6
%20 = phi i32 [ %17, %11 ], [ %7, %6 ]
%21 = load volatile i32, i32* inttoptr (i64 1442840660 to i32*)
%22 = and i32 %21, 2
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %33
24: ; preds = %19
%25 = tail call i32 @putccc(i32 120)
%26 = tail call i32 @putccc(i32 10)
%27 = tail call i32 @putccc(i32 13)
%28 = icmp ugt i32 %20, 200
%29 = add i32 %20, -10
%30 = select i1 %28, i32 %29, i32 %20
%31 = tail call i32 @delay(i32 200)
%32 = tail call i32 @buzzer_freq_sets(i32 %30)
br label %33
33: ; preds = %24, %19
%34 = phi i32 [ %30, %24 ], [ %20, %19 ]
%35 = tail call i32 @delay(i32 200)
br label %6
}