int simplify_action(int x, int allow_double, int allow_split,
                    int allow_surrender) {
  if (x < 5) {
    return x;
  }
  switch (x) {
  case 5:
    if (allow_double) {
      return 3;
    } else {
      return 2;
    }
    break;
  case 6:
    if (allow_double) {
      return 3;
    } else {
      return 1;
    }
    break;
  case 7:
    if (allow_split) {
      return 4;
    } else {
      return 2;
    }
    break;
  case 8:
    if (allow_split) {
      return 4;
    } else {
      return 1;
    }
    break;
  case 9:
    if (allow_split) {
      return 4;
    } else {
      return 3;
    }
    break;
  case 10:
    if (allow_surrender) {
      return 0;
    } else {
      return 2;
    }
    break;
  case 11:
    if (allow_surrender) {
      return 0;
    } else {
      return 1;
    }
    break;
  case 12:
    if (allow_surrender) {
      return 0;
    } else {
      return 4;
    }
    break;
  default:
    return 99;
  }
}


x86 assembly (clang, -O0):
<simplify_action>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x5,-0x8(%rbp)
jge    1125 <simplify_action+0x25>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
mov    -0x8(%rbp),%eax
add    $0xfffffffb,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x7,%eax
ja     125e <simplify_action+0x15e>
mov    -0x20(%rbp),%rax
lea    0xebb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0xc(%rbp)
je     1164 <simplify_action+0x64>
movl   $0x3,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
movl   $0x2,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
cmpl   $0x0,-0xc(%rbp)
je     1186 <simplify_action+0x86>
movl   $0x3,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
movl   $0x1,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
cmpl   $0x0,-0x10(%rbp)
je     11a8 <simplify_action+0xa8>
movl   $0x4,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
movl   $0x2,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
cmpl   $0x0,-0x10(%rbp)
je     11ca <simplify_action+0xca>
movl   $0x4,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
movl   $0x1,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
cmpl   $0x0,-0x10(%rbp)
je     11ec <simplify_action+0xec>
movl   $0x4,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
movl   $0x3,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
cmpl   $0x0,-0x14(%rbp)
je     120e <simplify_action+0x10e>
movl   $0x0,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
movl   $0x2,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
cmpl   $0x0,-0x14(%rbp)
je     1230 <simplify_action+0x130>
movl   $0x0,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
movl   $0x1,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
cmpl   $0x0,-0x14(%rbp)
je     1252 <simplify_action+0x152>
movl   $0x0,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
movl   $0x4,-0x4(%rbp)
jmp    1265 <simplify_action+0x165>
movl   $0x63,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<simplify_action>:
mov    %edi,%eax
cmp    $0x5,%edi
jge    1108 <simplify_action+0x8>
ret
add    $0xfffffffb,%eax
cmp    $0x7,%eax
ja     112c <simplify_action+0x2c>
lea    0xee9(%rip),%rdi
movslq (%rdi,%rax,4),%rax
add    %rdi,%rax
jmp    *%rax
cmp    $0x1,%esi
mov    $0x3,%eax
sbb    $0x0,%eax
ret
mov    $0x63,%eax
ret
xor    %eax,%eax
test   %esi,%esi
setne  %al
add    %eax,%eax
add    $0x1,%eax
ret
xor    %eax,%eax
test   %edx,%edx
setne  %al
add    %eax,%eax
add    $0x2,%eax
ret
xor    %eax,%eax
test   %edx,%edx
setne  %al
lea    (%rax,%rax,2),%eax
add    $0x1,%eax
ret
cmp    $0x1,%edx
mov    $0x4,%eax
sbb    $0x0,%eax
ret
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
add    %eax,%eax
ret
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
ret
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
shl    $0x2,%eax
ret

LLVM IR (-O0):
define i32 @simplify_action(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 5
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = load i32, i32* %6
store i32 %13, i32* %5
br label %57
14: ; preds = %4
%15 = load i32, i32* %6
switch i32 %15, label %56 [
i32 5, label %16
i32 6, label %21
i32 7, label %26
i32 8, label %31
i32 9, label %36
i32 10, label %41
i32 11, label %46
i32 12, label %51
]
16: ; preds = %14
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 3, i32* %5
br label %57
20: ; preds = %16
store i32 2, i32* %5
br label %57
21: ; preds = %14
%22 = load i32, i32* %7
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i32 3, i32* %5
br label %57
25: ; preds = %21
store i32 1, i32* %5
br label %57
26: ; preds = %14
%27 = load i32, i32* %8
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %26
store i32 4, i32* %5
br label %57
30: ; preds = %26
store i32 2, i32* %5
br label %57
31: ; preds = %14
%32 = load i32, i32* %8
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %31
store i32 4, i32* %5
br label %57
35: ; preds = %31
store i32 1, i32* %5
br label %57
36: ; preds = %14
%37 = load i32, i32* %8
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %36
store i32 4, i32* %5
br label %57
40: ; preds = %36
store i32 3, i32* %5
br label %57
41: ; preds = %14
%42 = load i32, i32* %9
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %45
44: ; preds = %41
store i32 0, i32* %5
br label %57
45: ; preds = %41
store i32 2, i32* %5
br label %57
46: ; preds = %14
%47 = load i32, i32* %9
%48 = icmp ne i32 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %46
store i32 0, i32* %5
br label %57
50: ; preds = %46
store i32 1, i32* %5
br label %57
51: ; preds = %14
%52 = load i32, i32* %9
%53 = icmp ne i32 %52, 0
br i1 %53, label %54, label %55
54: ; preds = %51
store i32 0, i32* %5
br label %57
55: ; preds = %51
store i32 4, i32* %5
br label %57
56: ; preds = %14
store i32 99, i32* %5
br label %57
57: ; preds = %56, %55, %54, %50, %49, %45, %44, %40, %39, %35, %34, %30, %29, %25, %24, %20, %19, %12
%58 = load i32, i32* %5
ret i32 %58
}

LLVM IR (-O2):
define i32 @simplify_action(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %0, 5
br i1 %5, label %31, label %6
6: ; preds = %4
switch i32 %0, label %31 [
i32 5, label %7
i32 6, label %10
i32 7, label %13
i32 8, label %16
i32 9, label %19
i32 10, label %22
i32 11, label %25
i32 12, label %28
]
7: ; preds = %6
%8 = icmp eq i32 %1, 0
%9 = select i1 %8, i32 2, i32 3
br label %31
10: ; preds = %6
%11 = icmp eq i32 %1, 0
%12 = select i1 %11, i32 1, i32 3
br label %31
13: ; preds = %6
%14 = icmp eq i32 %2, 0
%15 = select i1 %14, i32 2, i32 4
br label %31
16: ; preds = %6
%17 = icmp eq i32 %2, 0
%18 = select i1 %17, i32 1, i32 4
br label %31
19: ; preds = %6
%20 = icmp eq i32 %2, 0
%21 = select i1 %20, i32 3, i32 4
br label %31
22: ; preds = %6
%23 = icmp eq i32 %3, 0
%24 = select i1 %23, i32 2, i32 0
br label %31
25: ; preds = %6
%26 = icmp eq i32 %3, 0
%27 = zext i1 %26 to i32
br label %31
28: ; preds = %6
%29 = icmp eq i32 %3, 0
%30 = select i1 %29, i32 4, i32 0
br label %31
31: ; preds = %6, %28, %25, %22, %19, %16, %13, %10, %7, %4
%32 = phi i32 [ %0, %4 ], [ %9, %7 ], [ %12, %10 ], [ %15, %13 ], [ %18, %16 ], [ %21, %19 ], [ %24, %22 ], [ %27, %25 ], [ %30, %28 ], [ 99, %6 ]
ret i32 %32
}