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


x86 assembly (clang, -O0):
<integerBreak>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x8(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xed8(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xed6(%rip),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x7,-0x8(%rbp)
jge    1166 <integerBreak+0x56>
movslq -0x8(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%eax
mov    %eax,-0x4(%rbp)
jmp    1221 <integerBreak+0x111>
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,-0x38(%rbp)
je     11b7 <integerBreak+0xa7>
jmp    1195 <integerBreak+0x85>
mov    -0x38(%rbp),%eax
sub    $0x1,%eax
je     11d6 <integerBreak+0xc6>
jmp    11a6 <integerBreak+0x96>
mov    -0x38(%rbp),%eax
sub    $0x2,%eax
je     11fb <integerBreak+0xeb>
jmp    121b <integerBreak+0x10b>
mov    -0x8(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x3,%edi
call   1030 <pow@plt>
mov    %eax,-0x34(%rbp)
jmp    121b <integerBreak+0x10b>
mov    -0x8(%rbp),%eax
sub    $0x4,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x3,%edi
call   1030 <pow@plt>
shl    $0x2,%eax
mov    %eax,-0x34(%rbp)
jmp    121b <integerBreak+0x10b>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x3,%edi
call   1030 <pow@plt>
shl    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<integerBreak>:
push   %rax
mov    %edi,%eax
cmp    $0x6,%edi
jg     1126 <integerBreak+0x16>
cltq
lea    0xedf(%rip),%rcx
mov    (%rcx,%rax,4),%eax
pop    %rcx
ret
mov    %eax,%esi
mov    $0xaaaaaaab,%ecx
imul   %rcx,%rsi
shr    $0x21,%rsi
lea    (%rsi,%rsi,2),%edi
mov    %eax,%edx
sub    %edi,%edx
cmp    $0x2,%edx
je     1157 <integerBreak+0x47>
cmp    $0x1,%edx
je     1172 <integerBreak+0x62>
xor    %eax,%eax
test   %edx,%edx
jne    1170 <integerBreak+0x60>
mov    $0x3,%edi
pop    %rax
jmp    1030 <pow@plt>
add    $0xfffffffe,%eax
imul   %rcx,%rax
shr    $0x21,%rax
mov    $0x3,%edi
mov    %eax,%esi
call   1030 <pow@plt>
add    %eax,%eax
pop    %rcx
ret
add    $0xfffffffc,%eax
mov    $0xaaaaaaab,%esi
imul   %rax,%rsi
shr    $0x21,%rsi
mov    $0x3,%edi
call   1030 <pow@plt>
shl    $0x2,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.integerBreak.init = [7 x i32] [i32 0, i32 0, i32 1, i32 2, i32 4, i32 6, i32 9]
define i32 @integerBreak(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [7 x i32]
%5 = alloca i32
store i32 %0, i32* %3
%6 = bitcast [7 x i32]* %4 to i8*
store i32 0, i32* %5
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 7
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i32, i32* %3
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [7 x i32], [7 x i32]* %4, i64 0, i64 %11
%13 = load i32, i32* %12
store i32 %13, i32* %2
br label %35
14: ; preds = %1
%15 = load i32, i32* %3
%16 = srem i32 %15, 3
switch i32 %16, label %33 [
i32 0, label %17
i32 1, label %21
i32 2, label %27
]
17: ; preds = %14
%18 = load i32, i32* %3
%19 = sdiv i32 %18, 3
%20 = call i32 @pow(i32 3, i32 %19)
store i32 %20, i32* %5
br label %33
21: ; preds = %14
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 4
%24 = sdiv i32 %23, 3
%25 = call i32 @pow(i32 3, i32 %24)
%26 = mul nsw i32 %25, 4
store i32 %26, i32* %5
br label %33
27: ; preds = %14
%28 = load i32, i32* %3
%29 = sub nsw i32 %28, 2
%30 = sdiv i32 %29, 3
%31 = call i32 @pow(i32 3, i32 %30)
%32 = mul nsw i32 %31, 2
store i32 %32, i32* %5
br label %33
33: ; preds = %14, %27, %21, %17
%34 = load i32, i32* %5
store i32 %34, i32* %2
br label %35
35: ; preds = %33, %9
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
@__const.integerBreak.init = [7 x i32] [i32 0, i32 0, i32 1, i32 2, i32 4, i32 6, i32 9]
define i32 @integerBreak(i32 %0) {
%2 = icmp slt i32 %0, 7
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = sext i32 %0 to i64
%5 = getelementptr inbounds [7 x i32], [7 x i32]* @__const.integerBreak.init, i64 0, i64 %4
%6 = load i32, i32* %5
br label %22
7: ; preds = %1
%8 = urem i32 %0, 3
%9 = udiv i32 %0, 3
switch i32 %8, label %22 [
i32 0, label %10
i32 1, label %12
i32 2, label %17
]
10: ; preds = %7
%11 = tail call i32 @pow(i32 3, i32 %9)
br label %22
12: ; preds = %7
%13 = add nsw i32 %0, -4
%14 = udiv i32 %13, 3
%15 = tail call i32 @pow(i32 3, i32 %14)
%16 = shl nsw i32 %15, 2
br label %22
17: ; preds = %7
%18 = add nsw i32 %0, -2
%19 = udiv i32 %18, 3
%20 = tail call i32 @pow(i32 3, i32 %19)
%21 = shl nsw i32 %20, 1
br label %22
22: ; preds = %10, %12, %17, %7, %3
%23 = phi i32 [ %6, %3 ], [ 0, %7 ], [ %21, %17 ], [ %16, %12 ], [ %11, %10 ]
ret i32 %23
}