#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*/ tone(int, int, int);
void playNote(char note, int duration, int speakerPin) {
  char names[] = {'c', 'd', 'e', 'f', 'g', 'a', 's',
                  'b', 'C', 'D', 'E', 'F', 'G', 'A'};
  int tones[] = {262, 294, 330, 349, 392, 440, 466,
                 493, 523, 587, 659, 698, 784, 880};
  for (int i = 0; i < 14; i++) {
    if (names[i] == note) {
      tone(speakerPin, tones[i], duration);
    }
  }
}


x86 assembly (clang, -O0):
<playNote>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    0xec5(%rip),%rax
mov    %rax,-0x1a(%rbp)
mov    0xec3(%rip),%eax
mov    %eax,-0x12(%rbp)
mov    0xebd(%rip),%ax
mov    %ax,-0xe(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb2(%rip),%rsi
mov    $0x38,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x64(%rbp)
cmpl   $0xe,-0x64(%rbp)
jge    11b4 <playNote+0x94>
movslq -0x64(%rbp),%rax
movsbl -0x1a(%rbp,%rax,1),%eax
movsbl -0x1(%rbp),%ecx
cmp    %ecx,%eax
jne    11a1 <playNote+0x81>
mov    -0xc(%rbp),%edi
movslq -0x64(%rbp),%rax
mov    -0x60(%rbp,%rax,4),%esi
mov    -0x8(%rbp),%edx
call   1040 <tone@plt>
jmp    11a6 <playNote+0x86>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    116f <playNote+0x4f>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<playNote>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %esi,%r15d
mov    %edi,%r12d
lea    0xee5(%rip),%rbp
xor    %ebx,%ebx
lea    0xecc(%rip),%r13
jmp    114e <playNote+0x3e>
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
add    $0x4,%rbp
cmp    $0xe,%rbx
je     1164 <playNote+0x54>
cmp    %r12b,(%rbx,%r13,1)
jne    1140 <playNote+0x30>
mov    0x0(%rbp),%esi
mov    %r14d,%edi
mov    %r15d,%edx
call   1030 <tone@plt>
jmp    1140 <playNote+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.playNote.names = [14 x i8] c"cdefgasbCDEFGA"
@__const.playNote.tones = [14 x i32] [i32 262, i32 294, i32 330, i32 349, i32 392, i32 440, i32 466, i32 493, i32 523, i32 587, i32 659, i32 698, i32 784, i32 880]
define void @playNote(i8 signext %0, i32 %1, i32 %2) {
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca [14 x i8]
%8 = alloca [14 x i32]
%9 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%10 = bitcast [14 x i8]* %7 to i8*
%11 = bitcast [14 x i32]* %8 to i8*
store i32 0, i32* %9
br label %12
12: ; preds = %33, %3
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 14
br i1 %14, label %15, label %36
15: ; preds = %12
%16 = load i32, i32* %9
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [14 x i8], [14 x i8]* %7, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %20, %22
br i1 %23, label %24, label %32
24: ; preds = %15
%25 = load i32, i32* %6
%26 = load i32, i32* %9
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [14 x i32], [14 x i32]* %8, i64 0, i64 %27
%29 = load i32, i32* %28
%30 = load i32, i32* %5
%31 = call i32 @tone(i32 %25, i32 %29, i32 %30)
br label %32
32: ; preds = %24, %15
br label %33
33: ; preds = %32
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %12
36: ; preds = %12
ret void
}

LLVM IR (-O2):
@__const.playNote.names = [14 x i8] c"cdefgasbCDEFGA"
@__const.playNote.tones = [14 x i32] [i32 262, i32 294, i32 330, i32 349, i32 392, i32 440, i32 466, i32 493, i32 523, i32 587, i32 659, i32 698, i32 784, i32 880]
define void @playNote(i8 signext %0, i32 %1, i32 %2) {
br label %5
4: ; preds = %14
ret void
5: ; preds = %3, %14
%6 = phi i64 [ 0, %3 ], [ %15, %14 ]
%7 = getelementptr inbounds [14 x i8], [14 x i8]* @__const.playNote.names, i64 0, i64 %6
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, %0
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = getelementptr inbounds [14 x i32], [14 x i32]* @__const.playNote.tones, i64 0, i64 %6
%12 = load i32, i32* %11
%13 = tail call i32 @tone(i32 %2, i32 %12, i32 %1)
br label %14
14: ; preds = %5, %10
%15 = add nuw nsw i64 %6, 1
%16 = icmp eq i64 %15, 14
br i1 %16, label %4, label %5
}