#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 /*<<< orphan*/ printf(char *);
void compute(int inArg) {
  int st;
  inArg *= 3;
  st = inArg & 0xf;
  do {
    switch (st) {
    case 0:
      printf("Finish\n");
      inArg = -1;
      break;
    case 1:
      inArg *= 2;
      break;
    case 2:
      inArg >>= 2;
      break;
    case 3:
      inArg &= 1;
      break;
    case 4:
      inArg--;
      break;
    default:
      break;
    }
    st = inArg & 0xf;
  } while (inArg >= 0);
}


x86 assembly (clang, -O0):
<compute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
imul   $0x3,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x4,%rax
ja     11a0 <compute+0x90>
mov    -0x10(%rbp),%rax
lea    0xeb9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xebd(%rip),%rdi
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a5 <compute+0x95>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11a5 <compute+0x95>
mov    -0x4(%rbp),%eax
sar    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    11a5 <compute+0x95>
mov    -0x4(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11a5 <compute+0x95>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    11a5 <compute+0x95>
jmp    11a5 <compute+0x95>
mov    -0x4(%rbp),%eax
and    $0xf,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    112b <compute+0x1b>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute>:
lea    (%rdi,%rdi,2),%eax
lea    0xee6(%rip),%rcx
jmp    1124 <compute+0x14>
add    $0xffffffff,%eax
nop
test   %eax,%eax
js     1145 <compute+0x35>
mov    %eax,%edx
and    $0xf,%edx
cmp    $0x4,%edx
ja     1120 <compute+0x10>
movslq (%rcx,%rdx,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
add    %eax,%eax
jmp    1120 <compute+0x10>
sar    $0x2,%eax
jmp    1120 <compute+0x10>
and    $0x1,%eax
jmp    1120 <compute+0x10>
ret
lea    0xec7(%rip),%rdi
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"Finish\0A\00"
define void @compute(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = mul nsw i32 %4, 3
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = and i32 %6, 15
store i32 %7, i32* %3
br label %8
8: ; preds = %28, %1
%9 = load i32, i32* %3
switch i32 %9, label %24 [
i32 0, label %10
i32 1, label %12
i32 2, label %15
i32 3, label %18
i32 4, label %21
]
10: ; preds = %8
%11 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %2
br label %25
12: ; preds = %8
%13 = load i32, i32* %2
%14 = mul nsw i32 %13, 2
store i32 %14, i32* %2
br label %25
15: ; preds = %8
%16 = load i32, i32* %2
%17 = ashr i32 %16, 2
store i32 %17, i32* %2
br label %25
18: ; preds = %8
%19 = load i32, i32* %2
%20 = and i32 %19, 1
store i32 %20, i32* %2
br label %25
21: ; preds = %8
%22 = load i32, i32* %2
%23 = add nsw i32 %22, -1
store i32 %23, i32* %2
br label %25
24: ; preds = %8
br label %25
25: ; preds = %24, %21, %18, %15, %12, %10
%26 = load i32, i32* %2
%27 = and i32 %26, 15
store i32 %27, i32* %3
br label %28
28: ; preds = %25
%29 = load i32, i32* %2
%30 = icmp sge i32 %29, 0
br i1 %30, label %8, label %31
31: ; preds = %28
ret void
}

LLVM IR (-O2):
@str = [7 x i8] c"Finish\00"
define void @compute(i32 %0) {
%2 = mul nsw i32 %0, 3
br label %3
3: ; preds = %16, %1
%4 = phi i32 [ %2, %1 ], [ %17, %16 ]
%5 = and i32 %4, 15
switch i32 %5, label %16 [
i32 0, label %6
i32 1, label %8
i32 2, label %10
i32 3, label %12
i32 4, label %14
]
6: ; preds = %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
br label %19
8: ; preds = %3
%9 = shl nsw i32 %4, 1
br label %16
10: ; preds = %3
%11 = ashr i32 %4, 2
br label %16
12: ; preds = %3
%13 = and i32 %4, 1
br label %16
14: ; preds = %3
%15 = add nsw i32 %4, -1
br label %16
16: ; preds = %3, %14, %12, %10, %8
%17 = phi i32 [ %4, %3 ], [ %15, %14 ], [ %13, %12 ], [ %11, %10 ], [ %9, %8 ]
%18 = icmp sgt i32 %17, -1
br i1 %18, label %3, label %19
19: ; preds = %16, %6
ret void
}