int checkmode(char *mode, int *seek) {
  int f;
  for (;;) {
    switch (*mode) {
    case 0:
      return f;
    case 'b':
      break;
    case 'r':
      f = 0x000;
      break;
    case 'w':
      f = 0x001 | 0x200;
      break;
    case 'a':
      f = 0x001 | 0x200;
      *seek = 1;
      break;
    case '+':
      f |= 0x002;
      break;
    }
    ++mode;
  }
}


x86 assembly (clang, -O0):
<checkmode>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     1178 <checkmode+0x78>
jmp    1123 <checkmode+0x23>
mov    -0x18(%rbp),%eax
sub    $0x2b,%eax
je     11b0 <checkmode+0xb0>
jmp    1134 <checkmode+0x34>
mov    -0x18(%rbp),%eax
sub    $0x61,%eax
je     119a <checkmode+0x9a>
jmp    1145 <checkmode+0x45>
mov    -0x18(%rbp),%eax
sub    $0x62,%eax
je     117d <checkmode+0x7d>
jmp    1156 <checkmode+0x56>
mov    -0x18(%rbp),%eax
sub    $0x72,%eax
je     1182 <checkmode+0x82>
jmp    1167 <checkmode+0x67>
mov    -0x18(%rbp),%eax
sub    $0x77,%eax
je     118e <checkmode+0x8e>
jmp    11b9 <checkmode+0xb9>
mov    -0x14(%rbp),%eax
pop    %rbp
ret
jmp    11b9 <checkmode+0xb9>
movl   $0x0,-0x14(%rbp)
jmp    11b9 <checkmode+0xb9>
movl   $0x201,-0x14(%rbp)
jmp    11b9 <checkmode+0xb9>
movl   $0x201,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    11b9 <checkmode+0xb9>
mov    -0x14(%rbp),%eax
or     $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    110c <checkmode+0xc>

x86 assembly (clang, -O2):
<checkmode>:
jmp    1109 <checkmode+0x9>
or     $0x2,%eax
add    $0x1,%rdi
movsbl (%rdi),%ecx
cmp    $0x71,%ecx
jg     1130 <checkmode+0x30>
cmp    $0x2b,%ecx
je     1102 <checkmode+0x2>
cmp    $0x61,%ecx
jne    114d <checkmode+0x4d>
movl   $0x1,(%rsi)
mov    $0x201,%eax
add    $0x1,%rdi
jmp    1109 <checkmode+0x9>
nopl   0x0(%rax)
cmp    $0x72,%ecx
je     1145 <checkmode+0x45>
cmp    $0x77,%ecx
jne    1105 <checkmode+0x5>
mov    $0x201,%eax
add    $0x1,%rdi
jmp    1109 <checkmode+0x9>
xor    %eax,%eax
add    $0x1,%rdi
jmp    1109 <checkmode+0x9>
test   %ecx,%ecx
jne    1105 <checkmode+0x5>
ret

LLVM IR (-O0):
define i32 @checkmode(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
br label %6
6: ; preds = %20, %2
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %20 [
i32 0, label %10
i32 98, label %12
i32 114, label %13
i32 119, label %14
i32 97, label %15
i32 43, label %17
]
10: ; preds = %6
%11 = load i32, i32* %5
ret i32 %11
12: ; preds = %6
br label %20
13: ; preds = %6
store i32 0, i32* %5
br label %20
14: ; preds = %6
store i32 513, i32* %5
br label %20
15: ; preds = %6
store i32 513, i32* %5
%16 = load i32*, i32** %4
store i32 1, i32* %16
br label %20
17: ; preds = %6
%18 = load i32, i32* %5
%19 = or i32 %18, 2
store i32 %19, i32* %5
br label %20
20: ; preds = %6, %17, %15, %14, %13, %12
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
br label %6
}

LLVM IR (-O2):
define i32 @checkmode(i8* nocapture %0, i32* nocapture writeonly %1) {
br label %3
3: ; preds = %14, %2
%4 = phi i8* [ %0, %2 ], [ %16, %14 ]
%5 = phi i32 [ undef, %2 ], [ %15, %14 ]
%6 = load i8, i8* %4
%7 = sext i8 %6 to i32
switch i32 %7, label %14 [
i32 0, label %8
i32 43, label %12
i32 114, label %9
i32 119, label %10
i32 97, label %11
]
8: ; preds = %3
ret i32 %5
9: ; preds = %3
br label %14
10: ; preds = %3
br label %14
11: ; preds = %3
store i32 1, i32* %1
br label %14
12: ; preds = %3
%13 = or i32 %5, 2
br label %14
14: ; preds = %3, %12, %11, %10, %9
%15 = phi i32 [ %5, %3 ], [ 513, %11 ], [ 513, %10 ], [ 0, %9 ], [ %13, %12 ]
%16 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
}