#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*/ diminish_note(int /*<<< orphan*/);
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_diminish() {
  int i;
  char result[12] = "";
  char *cases[] = {"C", "Db", "C##", "Cb#", "C###"};
  char *answers[] = {"Cb", "Dbb", "C#", "Cb", "C##"};
  start_test("diminish");
  for (i = 0; i < 5; i++) {
    result[0] = '\0';
    note_to_str(diminish_note(str_to_note(cases[i])), result);
    assert(strcmp(result, answers[i]) == 0);
  }
  end_test();
}


x86 assembly (clang, -O0):
<test_diminish>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
lea    0xe51(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe48(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe40(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe39(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe32(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1080 <memset@plt>
lea    0xe1c(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xe14(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xe0d(%rip),%rax
mov    %rax,-0x60(%rbp)
lea    0xdfb(%rip),%rax
mov    %rax,-0x58(%rbp)
lea    0xde3(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xdef(%rip),%rdi
call   1050 <start_test@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x5,-0x4(%rbp)
jge    1298 <test_diminish+0x118>
movb   $0x0,-0x10(%rbp)
movslq -0x4(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rdi
call   1070 <str_to_note@plt>
mov    %eax,%edi
call   1040 <diminish_note@plt>
mov    %eax,%edi
lea    -0x10(%rbp),%rsi
call   1060 <note_to_str@plt>
lea    -0x10(%rbp),%rdi
movslq -0x4(%rbp),%rax
mov    -0x70(%rbp,%rax,8),%rsi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10a0 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1239 <test_diminish+0xb9>
mov    $0x0,%al
call   1030 <end_test@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_diminish>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
movq   $0x0,0x5(%rsp)
lea    0xe8b(%rip),%rdi
call   1050 <start_test@plt>
movb   $0x0,0x4(%rsp)
lea    0xe5e(%rip),%rdi
call   1070 <str_to_note@plt>
mov    %eax,%edi
call   1040 <diminish_note@plt>
lea    0x4(%rsp),%rbx
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <note_to_str@plt>
lea    0xe4e(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
movb   $0x0,0x4(%rsp)
lea    0xe19(%rip),%rdi
call   1070 <str_to_note@plt>
mov    %eax,%edi
call   1040 <diminish_note@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <note_to_str@plt>
lea    0xe0f(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
movb   $0x0,0x4(%rsp)
lea    0xddd(%rip),%r15
mov    %r15,%rdi
call   1070 <str_to_note@plt>
mov    %eax,%edi
call   1040 <diminish_note@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <note_to_str@plt>
lea    0xdd1(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
movb   $0x0,0x4(%rsp)
lea    0xd9f(%rip),%rdi
call   1070 <str_to_note@plt>
mov    %eax,%edi
call   1040 <diminish_note@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <note_to_str@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
movb   $0x0,0x4(%rsp)
lea    0xd68(%rip),%rdi
call   1070 <str_to_note@plt>
mov    %eax,%edi
call   1040 <diminish_note@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1060 <note_to_str@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1080 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
xor    %eax,%eax
call   1030 <end_test@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c"C\00"
@.str.1 = [3 x i8] c"Db\00"
@.str.2 = [4 x i8] c"C##\00"
@.str.3 = [4 x i8] c"Cb#\00"
@.str.4 = [5 x i8] c"C###\00"
@.str.5 = [3 x i8] c"Cb\00"
@.str.6 = [4 x i8] c"Dbb\00"
@.str.7 = [3 x i8] c"C#\00"
@.str.8 = [9 x i8] c"diminish\00"
define void @test_diminish() {
%1 = alloca i32
%2 = alloca [12 x i8]
%3 = alloca [5 x i8*]
%4 = alloca [5 x i8*]
%5 = bitcast [12 x i8]* %2 to i8*
%6 = bitcast [5 x i8*]* %3 to i8*
%7 = bitcast i8* %6 to [5 x i8*]*
%8 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 0
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8** %8
%9 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 1
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8** %9
%10 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8** %10
%11 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 3
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i32 0, i32 0), i8** %11
%12 = getelementptr inbounds [5 x i8*], [5 x i8*]* %7, i32 0, i32 4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i32 0, i32 0), i8** %12
%13 = bitcast [5 x i8*]* %4 to i8*
%14 = bitcast i8* %13 to [5 x i8*]*
%15 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i32 0, i32 0
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8** %15
%16 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i32 0, i32 1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i32 0, i32 0), i8** %16
%17 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i32 0, i32 2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i32 0, i32 0), i8** %17
%18 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i32 0, i32 3
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i32 0, i32 0), i8** %18
%19 = getelementptr inbounds [5 x i8*], [5 x i8*]* %14, i32 0, i32 4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i32 0, i32 0), i8** %19
%20 = call i32 @start_test(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %1
br label %21
21: ; preds = %43, %0
%22 = load i32, i32* %1
%23 = icmp slt i32 %22, 5
br i1 %23, label %24, label %46
24: ; preds = %21
%25 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
store i8 0, i8* %25
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [5 x i8*], [5 x i8*]* %3, i64 0, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @str_to_note(i8* %29)
%31 = call i32 @diminish_note(i32 %30)
%32 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%33 = call i32 @note_to_str(i32 %31, i8* %32)
%34 = getelementptr inbounds [12 x i8], [12 x i8]* %2, i64 0, i64 0
%35 = load i32, i32* %1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [5 x i8*], [5 x i8*]* %4, i64 0, i64 %36
%38 = load i8*, i8** %37
%39 = call i64 @strcmp(i8* %34, i8* %38)
%40 = icmp eq i64 %39, 0
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
br label %43
43: ; preds = %24
%44 = load i32, i32* %1
%45 = add nsw i32 %44, 1
store i32 %45, i32* %1
br label %21
46: ; preds = %21
%47 = call i32 (...) @end_test()
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"C\00"
@.str.1 = [3 x i8] c"Db\00"
@.str.2 = [4 x i8] c"C##\00"
@.str.3 = [4 x i8] c"Cb#\00"
@.str.4 = [5 x i8] c"C###\00"
@.str.5 = [3 x i8] c"Cb\00"
@.str.6 = [4 x i8] c"Dbb\00"
@.str.7 = [3 x i8] c"C#\00"
@.str.8 = [9 x i8] c"diminish\00"
define void @test_diminish() {
%1 = alloca [12 x i8]
%2 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 0
%3 = getelementptr inbounds [12 x i8], [12 x i8]* %1, i64 0, i64 1
%4 = tail call i32 @start_test(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
store i8 0, i8* %2
%5 = call i32 @str_to_note(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @diminish_note(i32 %5)
%7 = call i32 @note_to_str(i32 %6, i8* %2)
%8 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
store i8 0, i8* %2
%12 = call i32 @str_to_note(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @diminish_note(i32 %12)
%14 = call i32 @note_to_str(i32 %13, i8* %2)
%15 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
store i8 0, i8* %2
%19 = call i32 @str_to_note(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @diminish_note(i32 %19)
%21 = call i32 @note_to_str(i32 %20, i8* %2)
%22 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
store i8 0, i8* %2
%26 = call i32 @str_to_note(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%27 = call i32 @diminish_note(i32 %26)
%28 = call i32 @note_to_str(i32 %27, i8* %2)
%29 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
store i8 0, i8* %2
%33 = call i32 @str_to_note(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @diminish_note(i32 %33)
%35 = call i32 @note_to_str(i32 %34, i8* %2)
%36 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = call i32 (...) @end_test()
ret void
}