#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*/ O_WRONLY;
int _Getch();
int /*<<< orphan*/ close(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int main(void) {
  int buzzer = open("/dev/rtbuzzer0", O_WRONLY);
  int c = 1;
  while (c) {
    switch (_Getch()) {
    case '0':
      write(buzzer, "0", 2);
      break;
    case 'a':
      write(buzzer, "261", 4);
      break;
    case 'w':
      write(buzzer, "277", 4);
      break;
    case 's':
      write(buzzer, "293", 4);
      break;
    case 'e':
      write(buzzer, "311", 4);
      break;
    case 'd':
      write(buzzer, "329", 4);
      break;
    case 'f':
      write(buzzer, "349", 4);
      break;
    case 't':
      write(buzzer, "370", 4);
      break;
    case 'g':
      write(buzzer, "392", 4);
      break;
    case 'y':
      write(buzzer, "415", 4);
      break;
    case 'h':
      write(buzzer, "440", 4);
      break;
    case 'u':
      write(buzzer, "466", 4);
      break;
    case 'j':
      write(buzzer, "493", 4);
      break;
    case 'k':
      write(buzzer, "523", 4);
      break;
    case 'c':
      write(buzzer, "0", 2);
      c = 0;
      break;
    }
  }
  close(buzzer);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
lea    0xfc9(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1323 <main+0x1e3>
xor    %eax,%eax
call   1060 <_Getch@plt>
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x49,%eax
ja     131e <main+0x1de>
mov    -0x18(%rbp),%rax
lea    0xe64(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%edi
lea    0xfae(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xf6f(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xf5a(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xf45(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xf30(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xf1b(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xf06(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xef1(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xedc(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xec7(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xeb2(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xe9d(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xe88(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xe73(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
jmp    131e <main+0x1de>
mov    -0x8(%rbp),%edi
lea    0xe50(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
movl   $0x0,-0xc(%rbp)
jmp    116e <main+0x2e>
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e86(%rip),%rax
mov    (%rax),%esi
lea    0xfcd(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
lea    0xe97(%rip),%rbp
lea    0xfdf(%rip),%r14
lea    0xfe8(%rip),%r15
lea    0xfbd(%rip),%r12
lea    0xfd2(%rip),%r13
jmp    119a <main+0x5a>
mov    %ebx,%edi
lea    0xfa7(%rip),%rsi
mov    $0x4,%edx
call   1030 <write@plt>
xor    %eax,%eax
call   1060 <_Getch@plt>
add    $0xffffffd0,%eax
cmp    $0x49,%eax
ja     119a <main+0x5a>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %ebx,%edi
lea    0xfa1(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
jmp    119a <main+0x5a>
mov    %ebx,%edi
lea    0xf76(%rip),%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
lea    0xf67(%rip),%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
lea    0xf64(%rip),%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
lea    0xf61(%rip),%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
lea    0xf5e(%rip),%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
lea    0xf5b(%rip),%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
lea    0xf54(%rip),%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
lea    0xf1e(%rip),%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
mov    %r14,%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
mov    %r15,%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
mov    %r12,%rsi
jmp    1190 <main+0x50>
mov    %ebx,%edi
mov    %r13,%rsi
jmp    1190 <main+0x50>
lea    0xf08(%rip),%rsi
mov    %ebx,%edi
mov    $0x2,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1040 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [15 x i8] c"/dev/rtbuzzer0\00"
@O_WRONLY = global i32 0
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [4 x i8] c"261\00"
@.str.3 = [4 x i8] c"277\00"
@.str.4 = [4 x i8] c"293\00"
@.str.5 = [4 x i8] c"311\00"
@.str.6 = [4 x i8] c"329\00"
@.str.7 = [4 x i8] c"349\00"
@.str.8 = [4 x i8] c"370\00"
@.str.9 = [4 x i8] c"392\00"
@.str.10 = [4 x i8] c"415\00"
@.str.11 = [4 x i8] c"440\00"
@.str.12 = [4 x i8] c"466\00"
@.str.13 = [4 x i8] c"493\00"
@.str.14 = [4 x i8] c"523\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @O_WRONLY
%5 = call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %2
store i32 1, i32* %3
br label %6
6: ; preds = %56, %0
%7 = load i32, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %57
9: ; preds = %6
%10 = call i32 (...) @_Getch()
switch i32 %10, label %56 [
i32 48, label %11
i32 97, label %14
i32 119, label %17
i32 115, label %20
i32 101, label %23
i32 100, label %26
i32 102, label %29
i32 116, label %32
i32 103, label %35
i32 121, label %38
i32 104, label %41
i32 117, label %44
i32 106, label %47
i32 107, label %50
i32 99, label %53
]
11: ; preds = %9
%12 = load i32, i32* %2
%13 = call i32 @write(i32 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %56
14: ; preds = %9
%15 = load i32, i32* %2
%16 = call i32 @write(i32 %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 4)
br label %56
17: ; preds = %9
%18 = load i32, i32* %2
%19 = call i32 @write(i32 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 4)
br label %56
20: ; preds = %9
%21 = load i32, i32* %2
%22 = call i32 @write(i32 %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 4)
br label %56
23: ; preds = %9
%24 = load i32, i32* %2
%25 = call i32 @write(i32 %24, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 4)
br label %56
26: ; preds = %9
%27 = load i32, i32* %2
%28 = call i32 @write(i32 %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 4)
br label %56
29: ; preds = %9
%30 = load i32, i32* %2
%31 = call i32 @write(i32 %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 4)
br label %56
32: ; preds = %9
%33 = load i32, i32* %2
%34 = call i32 @write(i32 %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 4)
br label %56
35: ; preds = %9
%36 = load i32, i32* %2
%37 = call i32 @write(i32 %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 4)
br label %56
38: ; preds = %9
%39 = load i32, i32* %2
%40 = call i32 @write(i32 %39, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 4)
br label %56
41: ; preds = %9
%42 = load i32, i32* %2
%43 = call i32 @write(i32 %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 4)
br label %56
44: ; preds = %9
%45 = load i32, i32* %2
%46 = call i32 @write(i32 %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i32 4)
br label %56
47: ; preds = %9
%48 = load i32, i32* %2
%49 = call i32 @write(i32 %48, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 4)
br label %56
50: ; preds = %9
%51 = load i32, i32* %2
%52 = call i32 @write(i32 %51, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i32 4)
br label %56
53: ; preds = %9
%54 = load i32, i32* %2
%55 = call i32 @write(i32 %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 2)
store i32 0, i32* %3
br label %56
56: ; preds = %9, %53, %50, %47, %44, %41, %38, %35, %32, %29, %26, %23, %20, %17, %14, %11
br label %6
57: ; preds = %6
%58 = load i32, i32* %2
%59 = call i32 @close(i32 %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"/dev/rtbuzzer0\00"
@O_WRONLY = global i32 0
@.str.1 = [2 x i8] c"0\00"
@.str.2 = [4 x i8] c"261\00"
@.str.3 = [4 x i8] c"277\00"
@.str.4 = [4 x i8] c"293\00"
@.str.5 = [4 x i8] c"311\00"
@.str.6 = [4 x i8] c"329\00"
@.str.7 = [4 x i8] c"349\00"
@.str.8 = [4 x i8] c"370\00"
@.str.9 = [4 x i8] c"392\00"
@.str.10 = [4 x i8] c"415\00"
@.str.11 = [4 x i8] c"440\00"
@.str.12 = [4 x i8] c"466\00"
@.str.13 = [4 x i8] c"493\00"
@.str.14 = [4 x i8] c"523\00"
define i32 @main() {
%1 = load i32, i32* @O_WRONLY
%2 = tail call i32 @open(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %1)
br label %3
3: ; preds = %5, %0
%4 = tail call i32 (...) @_Getch()
switch i32 %4, label %5 [
i32 48, label %6
i32 97, label %8
i32 119, label %10
i32 115, label %12
i32 101, label %14
i32 100, label %16
i32 102, label %18
i32 116, label %20
i32 103, label %22
i32 121, label %24
i32 104, label %26
i32 117, label %28
i32 106, label %30
i32 107, label %32
i32 99, label %34
]
5: ; preds = %3, %32, %30, %28, %26, %24, %22, %20, %18, %16, %14, %12, %10, %8, %6
br label %3
6: ; preds = %3
%7 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 2)
br label %5
8: ; preds = %3
%9 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 4)
br label %5
10: ; preds = %3
%11 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 4)
br label %5
12: ; preds = %3
%13 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 4)
br label %5
14: ; preds = %3
%15 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 4)
br label %5
16: ; preds = %3
%17 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 4)
br label %5
18: ; preds = %3
%19 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 4)
br label %5
20: ; preds = %3
%21 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 4)
br label %5
22: ; preds = %3
%23 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 4)
br label %5
24: ; preds = %3
%25 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 4)
br label %5
26: ; preds = %3
%27 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i32 4)
br label %5
28: ; preds = %3
%29 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i32 4)
br label %5
30: ; preds = %3
%31 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i32 4)
br label %5
32: ; preds = %3
%33 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.14, i64 0, i64 0), i32 4)
br label %5
34: ; preds = %3
%35 = tail call i32 @write(i32 %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 2)
%36 = tail call i32 @close(i32 %2)
ret i32 0
}