#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 pow(int, int);
int integerBreak(int n) {
  if (n == 2)
    return 1;
  if (n == 3)
    return 2;
  switch (n % 3) {
  case 0:
    return pow(3, n / 3);
  case 1:
    return pow(3, n / 3 - 1) * 4;
  case 2:
    return pow(3, n / 3) * 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<integerBreak>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    1131 <integerBreak+0x21>
movl   $0x1,-0x4(%rbp)
jmp    1205 <integerBreak+0xf5>
cmpl   $0x3,-0x8(%rbp)
jne    1147 <integerBreak+0x37>
movl   $0x2,-0x4(%rbp)
jmp    1205 <integerBreak+0xf5>
movslq -0x8(%rbp),%rcx
mov    %ecx,%eax
imul   $0x55555556,%rcx,%rdx
mov    %rdx,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
je     1198 <integerBreak+0x88>
jmp    1176 <integerBreak+0x66>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     11b7 <integerBreak+0xa7>
jmp    1187 <integerBreak+0x77>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     11dc <integerBreak+0xcc>
jmp    11fe <integerBreak+0xee>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x3,%edi
call   1030 <pow@plt>
mov    %eax,-0x4(%rbp)
jmp    1205 <integerBreak+0xf5>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
sub    $0x1,%esi
mov    $0x3,%edi
call   1030 <pow@plt>
shl    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    1205 <integerBreak+0xf5>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x3,%edi
call   1030 <pow@plt>
shl    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1205 <integerBreak+0xf5>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<integerBreak>:
push   %rax
cmp    $0x2,%edi
je     1122 <integerBreak+0x12>
cmp    $0x3,%edi
jne    1129 <integerBreak+0x19>
mov    $0x2,%eax
pop    %rcx
ret
mov    $0x1,%eax
pop    %rcx
ret
movslq %edi,%rax
imul   $0x55555556,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rsi
lea    (%rsi,%rcx,1),%eax
lea    (%rax,%rax,2),%edx
sub    %edx,%edi
cmp    $0x2,%edi
je     1163 <integerBreak+0x53>
cmp    $0x1,%edi
je     1173 <integerBreak+0x63>
xor    %eax,%eax
test   %edi,%edi
jne    1171 <integerBreak+0x61>
add    %ecx,%esi
mov    $0x3,%edi
pop    %rax
jmp    1030 <pow@plt>
mov    $0x3,%edi
mov    %eax,%esi
call   1030 <pow@plt>
add    %eax,%eax
pop    %rcx
ret
add    %ecx,%esi
add    $0xffffffff,%esi
mov    $0x3,%edi
call   1030 <pow@plt>
shl    $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @integerBreak(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp eq i32 %4, 2
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 1, i32* %2
br label %30
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp eq i32 %8, 3
br i1 %9, label %10, label %11
10: ; preds = %7
store i32 2, i32* %2
br label %30
11: ; preds = %7
%12 = load i32, i32* %3
%13 = srem i32 %12, 3
switch i32 %13, label %29 [
i32 0, label %14
i32 1, label %18
i32 2, label %24
]
14: ; preds = %11
%15 = load i32, i32* %3
%16 = sdiv i32 %15, 3
%17 = call i32 @pow(i32 3, i32 %16)
store i32 %17, i32* %2
br label %30
18: ; preds = %11
%19 = load i32, i32* %3
%20 = sdiv i32 %19, 3
%21 = sub nsw i32 %20, 1
%22 = call i32 @pow(i32 3, i32 %21)
%23 = mul nsw i32 %22, 4
store i32 %23, i32* %2
br label %30
24: ; preds = %11
%25 = load i32, i32* %3
%26 = sdiv i32 %25, 3
%27 = call i32 @pow(i32 3, i32 %26)
%28 = mul nsw i32 %27, 2
store i32 %28, i32* %2
br label %30
29: ; preds = %11
store i32 0, i32* %2
br label %30
30: ; preds = %29, %24, %18, %14, %10, %6
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
define i32 @integerBreak(i32 %0) {
switch i32 %0, label %3 [
i32 2, label %17
i32 3, label %2
]
2: ; preds = %1
br label %17
3: ; preds = %1
%4 = srem i32 %0, 3
%5 = sdiv i32 %0, 3
switch i32 %4, label %17 [
i32 0, label %6
i32 1, label %9
i32 2, label %14
]
6: ; preds = %3
%7 = sdiv i32 %0, 3
%8 = tail call i32 @pow(i32 3, i32 %7)
br label %17
9: ; preds = %3
%10 = sdiv i32 %0, 3
%11 = add nsw i32 %10, -1
%12 = tail call i32 @pow(i32 3, i32 %11)
%13 = shl nsw i32 %12, 2
br label %17
14: ; preds = %3
%15 = tail call i32 @pow(i32 3, i32 %5)
%16 = shl nsw i32 %15, 1
br label %17
17: ; preds = %3, %1, %14, %9, %6, %2
%18 = phi i32 [ 2, %2 ], [ %16, %14 ], [ %13, %9 ], [ %8, %6 ], [ 1, %1 ], [ 0, %3 ]
ret i32 %18
}