char *BG_SurfaceToString(int surfaceFlags) {
  if (surfaceFlags & 0x1000) {
    return "Metal";
  } else if (surfaceFlags & 0x100000) {
    return "Wood";
  } else if (surfaceFlags & 0x200000) {
    return "Dirt/Grass";
  } else if (surfaceFlags & 0x400000) {
    return "Snow";
  } else if (surfaceFlags & 0x800000) {
    return "Sand";
  } else if (surfaceFlags & 0x1000000) {
    return "Glass";
  } else if (surfaceFlags & 0x2000000) {
    return "Soft";
  } else {
    return "Concrete";
  }
}


x86 assembly (clang, -O0):
<BG_SurfaceToString>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
je     1128 <BG_SurfaceToString+0x28>
lea    0xee1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <BG_SurfaceToString+0xf9>
mov    -0xc(%rbp),%eax
and    $0x100000,%eax
cmp    $0x0,%eax
je     1149 <BG_SurfaceToString+0x49>
lea    0xec6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <BG_SurfaceToString+0xf9>
mov    -0xc(%rbp),%eax
and    $0x200000,%eax
cmp    $0x0,%eax
je     116a <BG_SurfaceToString+0x6a>
lea    0xeaa(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <BG_SurfaceToString+0xf9>
mov    -0xc(%rbp),%eax
and    $0x400000,%eax
cmp    $0x0,%eax
je     118b <BG_SurfaceToString+0x8b>
lea    0xe94(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <BG_SurfaceToString+0xf9>
mov    -0xc(%rbp),%eax
and    $0x800000,%eax
cmp    $0x0,%eax
je     11ac <BG_SurfaceToString+0xac>
lea    0xe78(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <BG_SurfaceToString+0xf9>
mov    -0xc(%rbp),%eax
and    $0x1000000,%eax
cmp    $0x0,%eax
je     11cd <BG_SurfaceToString+0xcd>
lea    0xe5c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <BG_SurfaceToString+0xf9>
mov    -0xc(%rbp),%eax
and    $0x2000000,%eax
cmp    $0x0,%eax
je     11ee <BG_SurfaceToString+0xee>
lea    0xe41(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11f9 <BG_SurfaceToString+0xf9>
lea    0xe36(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<BG_SurfaceToString>:
test   $0x1000,%edi
jne    1149 <BG_SurfaceToString+0x49>
test   $0x100000,%edi
jne    1151 <BG_SurfaceToString+0x51>
test   $0x200000,%edi
jne    1159 <BG_SurfaceToString+0x59>
test   $0x400000,%edi
jne    1161 <BG_SurfaceToString+0x61>
test   $0x800000,%edi
jne    1169 <BG_SurfaceToString+0x69>
test   $0x1000000,%edi
jne    1171 <BG_SurfaceToString+0x71>
test   $0x2000000,%edi
lea    0xeee(%rip),%rcx
lea    0xee2(%rip),%rax
cmove  %rcx,%rax
ret
lea    0xeb0(%rip),%rax
ret
lea    0xeae(%rip),%rax
ret
lea    0xeab(%rip),%rax
ret
lea    0xeae(%rip),%rax
ret
lea    0xeab(%rip),%rax
ret
lea    0xea8(%rip),%rax
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Metal\00"
@.str.1 = [5 x i8] c"Wood\00"
@.str.2 = [11 x i8] c"Dirt/Grass\00"
@.str.3 = [5 x i8] c"Snow\00"
@.str.4 = [5 x i8] c"Sand\00"
@.str.5 = [6 x i8] c"Glass\00"
@.str.6 = [5 x i8] c"Soft\00"
@.str.7 = [9 x i8] c"Concrete\00"
define i8* @BG_SurfaceToString(i32 %0) {
%2 = alloca i8*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = and i32 %4, 4096
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
br label %39
8: ; preds = %1
%9 = load i32, i32* %3
%10 = and i32 %9, 1048576
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %8
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %39
13: ; preds = %8
%14 = load i32, i32* %3
%15 = and i32 %14, 2097152
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %13
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %39
18: ; preds = %13
%19 = load i32, i32* %3
%20 = and i32 %19, 4194304
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %39
23: ; preds = %18
%24 = load i32, i32* %3
%25 = and i32 %24, 8388608
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %39
28: ; preds = %23
%29 = load i32, i32* %3
%30 = and i32 %29, 16777216
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %39
33: ; preds = %28
%34 = load i32, i32* %3
%35 = and i32 %34, 33554432
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %33
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %39
38: ; preds = %33
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %39
39: ; preds = %38, %37, %32, %27, %22, %17, %12, %7
%40 = load i8*, i8** %2
ret i8* %40
}

LLVM IR (-O2):
@.str = [6 x i8] c"Metal\00"
@.str.1 = [5 x i8] c"Wood\00"
@.str.2 = [11 x i8] c"Dirt/Grass\00"
@.str.3 = [5 x i8] c"Snow\00"
@.str.4 = [5 x i8] c"Sand\00"
@.str.5 = [6 x i8] c"Glass\00"
@.str.6 = [5 x i8] c"Soft\00"
@.str.7 = [9 x i8] c"Concrete\00"
define i8* @BG_SurfaceToString(i32 %0) {
%2 = and i32 %0, 4096
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %23
4: ; preds = %1
%5 = and i32 %0, 1048576
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = and i32 %0, 2097152
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = and i32 %0, 4194304
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = and i32 %0, 8388608
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = and i32 %0, 16777216
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = and i32 %0, 33554432
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0)
br label %23
23: ; preds = %19, %16, %13, %10, %7, %4, %1
%24 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %10 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), %13 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %16 ], [ %22, %19 ]
ret i8* %24
}