#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 strlen(char *);
int get_accidentals_value(char *note) {
  int i, val = 0;
  for (i = 1; i < strlen(note); i++) {
    switch (note[i]) {
    case 'b':
      val--;
      break;
    case '#':
      val++;
      break;
    default:
      return -10000;
    }
  }
  return val;
}


x86 assembly (clang, -O0):
<get_accidentals_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    11af <get_accidentals_value+0x9f>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x20(%rbp)
sub    $0x23,%eax
je     1182 <get_accidentals_value+0x72>
jmp    1163 <get_accidentals_value+0x53>
mov    -0x20(%rbp),%eax
sub    $0x62,%eax
jne    1190 <get_accidentals_value+0x80>
jmp    1174 <get_accidentals_value+0x64>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    119c <get_accidentals_value+0x8c>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119c <get_accidentals_value+0x8c>
movl   $0xffffd8f0,-0x4(%rbp)
jmp    11b5 <get_accidentals_value+0xa5>
jmp    11a1 <get_accidentals_value+0x91>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112a <get_accidentals_value+0x1a>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_accidentals_value>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
xor    %ebp,%ebp
cmp    $0x2,%eax
jl     1165 <get_accidentals_value+0x55>
xor    %ebp,%ebp
mov    $0x1,%ebx
jmp    1145 <get_accidentals_value+0x35>
nopl   0x0(%rax)
add    %eax,%ebp
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1165 <get_accidentals_value+0x55>
movsbl (%r14,%rbx,1),%ecx
mov    $0xffffffff,%eax
cmp    $0x62,%ecx
je     1130 <get_accidentals_value+0x20>
cmp    $0x23,%ecx
jne    1160 <get_accidentals_value+0x50>
mov    $0x1,%eax
jmp    1130 <get_accidentals_value+0x20>
mov    $0xffffd8f0,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @get_accidentals_value(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
store i32 1, i32* %4
br label %6
6: ; preds = %26, %1
%7 = load i32, i32* %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %7, %9
br i1 %10, label %11, label %29
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
switch i32 %17, label %24 [
i32 98, label %18
i32 35, label %21
]
18: ; preds = %11
%19 = load i32, i32* %5
%20 = add nsw i32 %19, -1
store i32 %20, i32* %5
br label %25
21: ; preds = %11
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 1
store i32 %23, i32* %5
br label %25
24: ; preds = %11
store i32 -10000, i32* %2
br label %31
25: ; preds = %21, %18
br label %26
26: ; preds = %25
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %6
29: ; preds = %6
%30 = load i32, i32* %5
store i32 %30, i32* %2
br label %31
31: ; preds = %29, %24
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @get_accidentals_value(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 1
br i1 %3, label %4, label %18
4: ; preds = %1, %11
%5 = phi i64 [ %14, %11 ], [ 1, %1 ]
%6 = phi i32 [ %13, %11 ], [ 0, %1 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %18 [
i32 98, label %11
i32 35, label %10
]
10: ; preds = %4
br label %11
11: ; preds = %4, %10
%12 = phi i32 [ 1, %10 ], [ -1, %4 ]
%13 = add nsw i32 %6, %12
%14 = add nuw nsw i64 %5, 1
%15 = tail call i32 @strlen(i8* %0)
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %4, label %18
18: ; preds = %4, %11, %1
%19 = phi i32 [ 0, %1 ], [ %13, %11 ], [ -10000, %4 ]
ret i32 %19
}