int GetFontId(fname)
char *fname;
{
  char aux[10];
  int i, ret;
  memcpy(aux, &(fname[3]), 2);
  aux[2] = 0;
  i = atoi(aux);
  ret = 1000 + (i * 10);
  switch (toupper(fname[5])) {
  case 'N':
    break;
  case 'B':
    ret += 5;
    break;
  case 'I':
    ret += 3;
    break;
  default:
    break;
  }
  return ret;
}


x86 assembly (clang, -O0):
<GetFontId>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    0x3(%rax),%ax
mov    %ax,-0x12(%rbp)
movb   $0x0,-0x10(%rbp)
xor    %eax,%eax
lea    -0x12(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,4),%ecx
mov    %ecx,%eax
lea    0x3e8(%rax,%rax,1),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x5(%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    %ecx,-0x20(%rbp)
sub    $0x42,%eax
je     11a5 <GetFontId+0x85>
jmp    117e <GetFontId+0x5e>
mov    -0x20(%rbp),%eax
sub    $0x49,%eax
je     11b3 <GetFontId+0x93>
jmp    118f <GetFontId+0x6f>
mov    -0x20(%rbp),%eax
sub    $0x4e,%eax
jne    11c1 <GetFontId+0xa1>
jmp    11a0 <GetFontId+0x80>
jmp    11c6 <GetFontId+0xa6>
mov    -0x1c(%rbp),%eax
add    $0x5,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c6 <GetFontId+0xa6>
mov    -0x1c(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c6 <GetFontId+0xa6>
jmp    11c6 <GetFontId+0xa6>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetFontId>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbp
movzwl 0x3(%rdi),%eax
mov    %ax,0x6(%rsp)
movb   $0x0,0x8(%rsp)
lea    0x6(%rsp),%rdi
xor    %eax,%eax
call   1040 <atoi@plt>
mov    %eax,%ebx
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%r14d
movsbl 0x5(%rbp),%edi
call   1030 <toupper@plt>
cmp    $0x49,%eax
je     1169 <GetFontId+0x49>
cmp    $0x42,%eax
jne    1172 <GetFontId+0x52>
add    $0x3ed,%r14d
jmp    117d <GetFontId+0x5d>
add    $0x3eb,%r14d
jmp    117d <GetFontId+0x5d>
lea    (%rbx,%rbx,4),%r14d
add    $0x3e8,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @GetFontId(i8* %0) {
%2 = alloca i8*
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %2
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 3
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 2
store i8 0, i8* %9
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%11 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %10)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = mul nsw i32 %12, 10
%14 = add nsw i32 1000, %13
store i32 %14, i32* %5
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i64 5
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = call i32 @toupper(i32 %18)
switch i32 %19, label %27 [
i32 78, label %20
i32 66, label %21
i32 73, label %24
]
20: ; preds = %1
br label %28
21: ; preds = %1
%22 = load i32, i32* %5
%23 = add nsw i32 %22, 5
store i32 %23, i32* %5
br label %28
24: ; preds = %1
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 3
store i32 %26, i32* %5
br label %28
27: ; preds = %1
br label %28
28: ; preds = %27, %24, %21, %20
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
define i32 @GetFontId(i8* nocapture %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = getelementptr inbounds i8, i8* %0, i64 3
%5 = bitcast i8* %4 to i16*
%6 = bitcast [10 x i8]* %2 to i16*
%7 = load i16, i16* %5
store i16 %7, i16* %6
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 2
store i8 0, i8* %8
%9 = call i32 (i8*, ...) bitcast (i32 (...)* @atoi to i32 (i8*, ...)*)(i8* %3)
%10 = mul nsw i32 %9, 10
%11 = add nsw i32 %10, 1000
%12 = getelementptr inbounds i8, i8* %0, i64 5
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = call i32 @toupper(i32 %14)
switch i32 %15, label %20 [
i32 73, label %18
i32 66, label %16
]
16: ; preds = %1
%17 = add nsw i32 %10, 1005
br label %20
18: ; preds = %1
%19 = add nsw i32 %10, 1003
br label %20
20: ; preds = %1, %18, %16
%21 = phi i32 [ %11, %1 ], [ %17, %16 ], [ %19, %18 ]
ret i32 %21
}