#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*/ assert(int);
int /*<<< orphan*/ diatonic_interval(int /*<<< orphan*/, int /*<<< orphan*/,
                                     int);
int /*<<< orphan*/ end_test();
int /*<<< orphan*/ note_to_str(int /*<<< orphan*/, char *);
int /*<<< orphan*/ start_test(char *);
int /*<<< orphan*/ str_to_note(char *);
scalar_t__ strcmp(char *, char *);
void test_perfect_fourth() {
  char result[12];
  char *notes[] = {
      "C", "E", "F", "G", "A#", "B", "F#",
  };
  char *answers[] = {"F", "A", "Bb", "C", "D#", "E", "B"};
  int i;
  start_test("perfect_fourth");
  for (i = 0; i < 7; i++) {
    note_to_str(((diatonic_interval((str_to_note(notes[i])),
                                    (str_to_note(notes[i])), 3))),
                result);
    assert(strcmp(result, answers[i]) == 0);
  }
  end_test();
}


x86 assembly (clang, -O0):
<test_perfect_fourth>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
lea    -0x50(%rbp),%rdi
lea    0x2c0a(%rip),%rsi
mov    $0x38,%edx
call   1090 <memcpy@plt>
lea    -0x90(%rbp),%rdi
lea    0x2c32(%rip),%rsi
mov    $0x38,%edx
call   1090 <memcpy@plt>
lea    0xe59(%rip),%rdi
call   1040 <start_test@plt>
movl   $0x0,-0x94(%rbp)
cmpl   $0x7,-0x94(%rbp)
jge    125d <test_perfect_fourth+0xdd>
movslq -0x94(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
call   1060 <str_to_note@plt>
mov    %eax,-0x98(%rbp)
movslq -0x94(%rbp),%rax
mov    -0x50(%rbp,%rax,8),%rdi
call   1060 <str_to_note@plt>
mov    -0x98(%rbp),%edi
mov    %eax,%esi
mov    $0x3,%edx
call   10a0 <diatonic_interval@plt>
mov    %eax,%edi
lea    -0xc(%rbp),%rsi
call   1050 <note_to_str@plt>
lea    -0xc(%rbp),%rdi
movslq -0x94(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rsi
ff
call   1070 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1080 <assert@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11ce <test_perfect_fourth+0x4e>
mov    $0x0,%al
call   1030 <end_test@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_perfect_fourth>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe93(%rip),%rdi
call   1040 <start_test@plt>
lea    0x2c4f(%rip),%r12
xor    %ebp,%ebp
lea    0xc(%rsp),%r14
lea    0xe89(%rip),%r13
nop
mov    (%r12),%rbx
mov    %rbx,%rdi
call   1060 <str_to_note@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1060 <str_to_note@plt>
mov    %r15d,%edi
mov    %eax,%esi
mov    $0x3,%edx
call   1090 <diatonic_interval@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1050 <note_to_str@plt>
movslq 0x0(%rbp,%r13,1),%rsi
add    %r13,%rsi
mov    %r14,%rdi
call   1070 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1080 <assert@plt>
add    $0x4,%rbp
add    $0x8,%r12
cmp    $0x1c,%rbp
jne    11a0 <test_perfect_fourth+0x30>
xor    %eax,%eax
call   1030 <end_test@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"C\00"
@.str.1 = [2 x i8] c"E\00"
@.str.2 = [2 x i8] c"F\00"
@.str.3 = [2 x i8] c"G\00"
@.str.4 = [3 x i8] c"A#\00"
@.str.5 = [2 x i8] c"B\00"
@.str.6 = [3 x i8] c"F#\00"
@__const.test_perfect_fourth.notes = [7 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [2 x i8] c"A\00"
@.str.8 = [3 x i8] c"Bb\00"
@.str.9 = [3 x i8] c"D#\00"
@__const.test_perfect_fourth.answers = [7 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0)]
@.str.10 = [15 x i8] c"perfect_fourth\00"
define void @test_perfect_fourth() {
%1 = alloca [12 x i8]
%2 = alloca [7 x i8*]
%3 = alloca [7 x i8*]
%4 = alloca i32
%5 = bitcast [7 x i8*]* %2 to i8*
%6 = bitcast [7 x i8*]* %3 to i8*
%7 = call i32 @start_test(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %4
br label %8
8: ; preds = %34, %0
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 7
br i1 %10, label %11, label %37
11: ; preds = %8
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 @str_to_note(i8* %15)
%17 = load i32, i32* %4
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [7 x i8*], [7 x i8*]* %2, i64 0, i64 %18
%20 = load i8*, i8** %19
%21 = call i32 @str_to_note(i8* %20)
%22 = call i32 @diatonic_interval(i32 %16, i32 %21, i32 3)
%23 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%24 = call i32 @note_to_str(i32 %22, i8* %23)
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%26 = load i32, i32* %4
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [7 x i8*], [7 x i8*]* %3, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = call i64 @strcmp(i8* %25, i8* %29)
%31 = icmp eq i64 %30, 0
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
br label %34
34: ; preds = %11
%35 = load i32, i32* %4
%36 = add nsw i32 %35, 1
store i32 %36, i32* %4
br label %8
37: ; preds = %8
%38 = call i32 (...) @end_test()
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"C\00"
@.str.1 = [2 x i8] c"E\00"
@.str.2 = [2 x i8] c"F\00"
@.str.3 = [2 x i8] c"G\00"
@.str.4 = [3 x i8] c"A#\00"
@.str.5 = [2 x i8] c"B\00"
@.str.6 = [3 x i8] c"F#\00"
@__const.test_perfect_fourth.notes = [7 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i32 0, i32 0)]
@.str.7 = [2 x i8] c"A\00"
@.str.8 = [3 x i8] c"Bb\00"
@.str.9 = [3 x i8] c"D#\00"
@reltable.test_perfect_fourth = [7 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.2 to i64), i64 ptrtoint ([7 x i32]* @reltable.test_perfect_fourth to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.7 to i64), i64 ptrtoint ([7 x i32]* @reltable.test_perfect_fourth to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.8 to i64), i64 ptrtoint ([7 x i32]* @reltable.test_perfect_fourth to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str to i64), i64 ptrtoint ([7 x i32]* @reltable.test_perfect_fourth to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.9 to i64), i64 ptrtoint ([7 x i32]* @reltable.test_perfect_fourth to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.1 to i64), i64 ptrtoint ([7 x i32]* @reltable.test_perfect_fourth to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str.5 to i64), i64 ptrtoint ([7 x i32]* @reltable.test_perfect_fourth to i64)) to i32)]
@.str.10 = [15 x i8] c"perfect_fourth\00"
define void @test_perfect_fourth() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @start_test(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
br label %4
4: ; preds = %0, %4
%5 = phi i64 [ 0, %0 ], [ %18, %4 ]
%6 = getelementptr inbounds [7 x i8*], [7 x i8*]* @__const.test_perfect_fourth.notes, i64 0, i64 %5
%7 = load i8*, i8** %6
%8 = call i32 @str_to_note(i8* %7)
%9 = call i32 @str_to_note(i8* %7)
%10 = call i32 @diatonic_interval(i32 %8, i32 %9, i32 3)
%11 = call i32 @note_to_str(i32 %10, i8* %2)
%12 = shl i64 %5, 2
%13 = call i8* @llvm.load.relative.i64(i8* bitcast ([7 x i32]* @reltable.test_perfect_fourth to i8*), i64 %12)
%14 = call i64 @strcmp(i8* %2, i8* %13)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
%18 = add nuw nsw i64 %5, 1
%19 = icmp eq i64 %18, 7
br i1 %19, label %20, label %4
20: ; preds = %4
%21 = call i32 (...) @end_test()
ret void
}