#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 next(char);
int prev(char);
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, char *, char *);
int main() {
  char note[3], tonality[6];
  int case_number = 1;
  while (scanf("%s %s", note, tonality) == 2) {
    printf("Case %d: ", case_number++);
    if (note[1] == '#') {
      printf("%cb %s\n", next(note[0]), tonality);
    } else if (note[1] == 'b') {
      printf("%c# %s\n", prev(note[0]), tonality);
    } else {
      printf("UNIQUE\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
lea    -0x7(%rbp),%rsi
lea    -0xd(%rbp),%rdx
lea    0xe9b(%rip),%rdi
call   1060 <scanf@plt>
cmp    $0x2,%eax
jne    1202 <main+0xc2>
mov    -0x14(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x6(%rbp),%eax
cmp    $0x23,%eax
jne    11bb <main+0x7b>
movsbl -0x7(%rbp),%edi
call   1050 <next@plt>
mov    %eax,%esi
lea    -0xd(%rbp),%rdx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fd <main+0xbd>
movsbl -0x6(%rbp),%eax
cmp    $0x62,%eax
jne    11ea <main+0xaa>
movsbl -0x7(%rbp),%edi
call   1030 <prev@plt>
mov    %eax,%esi
lea    -0xd(%rbp),%rdx
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f8 <main+0xb8>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11fd <main+0xbd>
jmp    1156 <main+0x16>
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
sub    $0x18,%rsp
lea    0xe9b(%rip),%rdi
lea    0xf(%rsp),%rsi
lea    0x12(%rsp),%rdx
call   1070 <scanf@plt>
cmp    $0x2,%eax
jne    121f <main+0xcf>
mov    $0x1,%ebx
lea    0xe7d(%rip),%r14
lea    0x12(%rsp),%r12
lea    0xe6b(%rip),%r13
lea    0xf(%rsp),%rbp
lea    0xe7f(%rip),%r15
jmp    11ce <main+0x7e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
call   1070 <scanf@plt>
add    $0x1,%ebx
cmp    $0x2,%eax
jne    121f <main+0xcf>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
movzbl 0x10(%rsp),%eax
cmp    $0x62,%al
je     1200 <main+0xb0>
cmp    $0x23,%al
jne    11b0 <main+0x60>
movsbl 0xf(%rsp),%edi
call   1060 <next@plt>
lea    0xe18(%rip),%rdi
jmp    1211 <main+0xc1>
nopw   0x0(%rax,%rax,1)
movsbl 0xf(%rsp),%edi
call   1040 <prev@plt>
lea    0xe07(%rip),%rdi
mov    %eax,%esi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11b8 <main+0x68>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [10 x i8] c"Case %d: \00"
@.str.2 = [8 x i8] c"%cb %s\0A\00"
@.str.3 = [8 x i8] c"%c# %s\0A\00"
@.str.4 = [8 x i8] c"UNIQUE\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [3 x i8]
%3 = alloca [6 x i8]
%4 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %4
br label %5
5: ; preds = %38, %0
%6 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %6, i8* %7)
%9 = icmp eq i32 %8, 2
br i1 %9, label %10, label %39
10: ; preds = %5
%11 = load i32, i32* %4
%12 = add nsw i32 %11, 1
store i32 %12, i32* %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%14 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 35
br i1 %17, label %18, label %24
18: ; preds = %10
%19 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%20 = load i8, i8* %19
%21 = call i32 @next(i8 signext %20)
%22 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %21, i8* %22)
br label %38
24: ; preds = %10
%25 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 98
br i1 %28, label %29, label %35
29: ; preds = %24
%30 = getelementptr inbounds [3 x i8], [3 x i8]* %2, i64 0, i64 0
%31 = load i8, i8* %30
%32 = call i32 @prev(i8 signext %31)
%33 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %32, i8* %33)
br label %37
35: ; preds = %24
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %37
37: ; preds = %35, %29
br label %38
38: ; preds = %37, %18
br label %5
39: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s %s\00"
@.str.1 = [10 x i8] c"Case %d: \00"
@.str.2 = [8 x i8] c"%cb %s\0A\00"
@.str.3 = [8 x i8] c"%c# %s\0A\00"
@str = [7 x i8] c"UNIQUE\00"
define i32 @main() {
%1 = alloca [3 x i8]
%2 = alloca [6 x i8]
%3 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%6 = icmp eq i32 %5, 2
br i1 %6, label %7, label %27
7: ; preds = %0
%8 = getelementptr inbounds [3 x i8], [3 x i8]* %1, i64 0, i64 1
br label %9
9: ; preds = %7, %24
%10 = phi i32 [ 1, %7 ], [ %11, %24 ]
%11 = add nuw nsw i32 %10, 1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%13 = load i8, i8* %8
switch i8 %13, label %22 [
i8 35, label %14
i8 98, label %18
]
14: ; preds = %9
%15 = load i8, i8* %3
%16 = call i32 @next(i8 signext %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %16, i8* %4)
br label %24
18: ; preds = %9
%19 = load i8, i8* %3
%20 = call i32 @prev(i8 signext %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 %20, i8* %4)
br label %24
22: ; preds = %9
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %18, %22, %14
%25 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %3, i8* %4)
%26 = icmp eq i32 %25, 2
br i1 %26, label %9, label %27
27: ; preds = %24, %0
ret i32 0
}