#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 atoi(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ permutations_count(int *, int);
int /*<<< orphan*/ printf(char *, long);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc != 2) {
    fprintf(stderr, "usage: %s <N>\n", argv[0]);
    return 1;
  }
  int N = atoi(argv[1]);
  if (N <= 0)
    return 1;
  long combinations = 0;
  for (int block_size = 2; block_size <= 4; block_size++)
    for (int block_count = 1; block_count <= N / block_size; block_count++) {
      int blocks_of_size_one = N - block_size * block_count;
      int block_counts[] = {block_count, blocks_of_size_one};
      combinations += permutations_count(block_counts, 2);
    }
  printf("%ld\n", combinations);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1188 <main+0x48>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe89(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1251 <main+0x111>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     11ae <main+0x6e>
movl   $0x1,-0x4(%rbp)
jmp    1251 <main+0x111>
movq   $0x0,-0x20(%rbp)
movl   $0x2,-0x24(%rbp)
cmpl   $0x4,-0x24(%rbp)
jg     123a <main+0xfa>
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jg     1227 <main+0xe7>
mov    -0x14(%rbp),%eax
mov    -0x24(%rbp),%ecx
imul   -0x28(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x30(%rbp)
lea    -0x34(%rbp),%rdi
mov    $0x2,%esi
call   1060 <permutations_count@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11ce <main+0x8e>
jmp    122c <main+0xec>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11bd <main+0x7d>
mov    -0x20(%rbp),%rsi
lea    0xdca(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    116f <main+0x2f>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
test   %eax,%eax
jle    1187 <main+0x47>
mov    %eax,%r15d
xor    %r14d,%r14d
cmp    $0x1,%eax
jne    1192 <main+0x52>
xor    %ebx,%ebx
jmp    129d <main+0x15d>
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe7e(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%r14d
jmp    12ac <main+0x16c>
mov    %r15d,%r13d
shr    %r13d
neg    %r13d
lea    -0x2(%r15),%ebp
mov    $0x1,%r14d
xor    %ebx,%ebx
mov    %rsp,%r12
nopw   0x0(%rax,%rax,1)
mov    %r14d,(%rsp)
mov    %ebp,0x4(%rsp)
mov    %r12,%rdi
mov    $0x2,%esi
call   1060 <permutations_count@plt>
add    %rax,%rbx
lea    (%r14,%r13,1),%eax
add    $0x1,%eax
mov    %r14d,%ecx
add    $0x1,%ecx
add    $0xfffffffe,%ebp
mov    %ecx,%r14d
cmp    $0x1,%eax
jne    11b0 <main+0x70>
cmp    $0x3,%r15d
jge    11ee <main+0xae>
xor    %r14d,%r14d
jmp    129d <main+0x15d>
mov    %r15d,%eax
mov    $0xaaaaaaab,%r13d
imul   %rax,%r13
shr    $0x21,%r13
neg    %r13d
lea    -0x3(%r15),%ebp
mov    $0x1,%r14d
mov    %rsp,%r12
nop
mov    %r14d,(%rsp)
mov    %ebp,0x4(%rsp)
mov    %r12,%rdi
mov    $0x2,%esi
call   1060 <permutations_count@plt>
add    %rax,%rbx
lea    (%r14,%r13,1),%eax
add    $0x1,%eax
mov    %r14d,%ecx
add    $0x1,%ecx
add    $0xfffffffd,%ebp
mov    %ecx,%r14d
cmp    $0x1,%eax
jne    1210 <main+0xd0>
cmp    $0x4,%r15d
mov    $0x0,%r14d
jl     129d <main+0x15d>
mov    %r15d,%r13d
shr    $0x2,%r13d
neg    %r13d
add    $0xfffffffc,%r15d
mov    $0x1,%ebp
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,(%rsp)
mov    %r15d,0x4(%rsp)
mov    %r12,%rdi
mov    $0x2,%esi
call   1060 <permutations_count@plt>
add    %rax,%rbx
lea    0x1(%r13,%rbp,1),%eax
mov    %ebp,%ecx
add    $0x1,%ecx
add    $0xfffffffc,%r15d
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    1270 <main+0x130>
lea    0xd6b(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s <N>\0A\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [2 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 2
br i1 %13, label %14, label %20
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %63
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @atoi(i8* %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp sle i32 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %20
store i32 1, i32* %3
br label %63
28: ; preds = %20
store i64 0, i64* %7
store i32 2, i32* %8
br label %29
29: ; preds = %57, %28
%30 = load i32, i32* %8
%31 = icmp sle i32 %30, 4
br i1 %31, label %32, label %60
32: ; preds = %29
store i32 1, i32* %9
br label %33
33: ; preds = %53, %32
%34 = load i32, i32* %9
%35 = load i32, i32* %6
%36 = load i32, i32* %8
%37 = sdiv i32 %35, %36
%38 = icmp sle i32 %34, %37
br i1 %38, label %39, label %56
39: ; preds = %33
%40 = load i32, i32* %6
%41 = load i32, i32* %8
%42 = load i32, i32* %9
%43 = mul nsw i32 %41, %42
%44 = sub nsw i32 %40, %43
store i32 %44, i32* %10
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%46 = load i32, i32* %9
store i32 %46, i32* %45
%47 = getelementptr inbounds i32, i32* %45, i64 1
%48 = load i32, i32* %10
store i32 %48, i32* %47
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %11, i64 0, i64 0
%50 = call i64 @permutations_count(i32* %49, i32 2)
%51 = load i64, i64* %7
%52 = add nsw i64 %51, %50
store i64 %52, i64* %7
br label %53
53: ; preds = %39
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
br label %33
56: ; preds = %33
br label %57
57: ; preds = %56
%58 = load i32, i32* %8
%59 = add nsw i32 %58, 1
store i32 %59, i32* %8
br label %29
60: ; preds = %29
%61 = load i64, i64* %7
%62 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %61)
store i32 0, i32* %3
br label %63
63: ; preds = %60, %27, %14
%64 = load i32, i32* %3
ret i32 %64
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [15 x i8] c"usage: %s <N>\0A\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [2 x i32]
%4 = icmp eq i32 %0, 2
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = load i32, i32* @stderr
%7 = load i8*, i8** %1
%8 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %7)
br label %59
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = icmp slt i32 %12, 1
br i1 %13, label %59, label %14
14: ; preds = %9
%15 = bitcast [2 x i32]* %3 to i8*
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%18 = icmp eq i32 %12, 1
br i1 %18, label %47, label %19
19: ; preds = %14
%20 = lshr i32 %12, 1
br label %50
21: ; preds = %50
%22 = icmp slt i32 %12, 3
br i1 %22, label %47, label %23
23: ; preds = %21
%24 = udiv i32 %12, 3
br label %25
25: ; preds = %25, %23
%26 = phi i32 [ %32, %25 ], [ 1, %23 ]
%27 = phi i64 [ %31, %25 ], [ %56, %23 ]
%28 = mul i32 %26, -3
%29 = add i32 %28, %12
store i32 %26, i32* %16
store i32 %29, i32* %17
%30 = call i64 @permutations_count(i32* %16, i32 2)
%31 = add nsw i64 %30, %27
%32 = add nuw nsw i32 %26, 1
%33 = icmp eq i32 %26, %24
br i1 %33, label %34, label %25
34: ; preds = %25
%35 = icmp slt i32 %12, 4
br i1 %35, label %47, label %36
36: ; preds = %34
%37 = lshr i32 %12, 2
br label %38
38: ; preds = %38, %36
%39 = phi i32 [ %45, %38 ], [ 1, %36 ]
%40 = phi i64 [ %44, %38 ], [ %31, %36 ]
%41 = mul i32 %39, -4
%42 = add i32 %41, %12
store i32 %39, i32* %16
store i32 %42, i32* %17
%43 = call i64 @permutations_count(i32* %16, i32 2)
%44 = add nsw i64 %43, %40
%45 = add nuw nsw i32 %39, 1
%46 = icmp eq i32 %39, %37
br i1 %46, label %47, label %38
47: ; preds = %38, %14, %21, %34
%48 = phi i64 [ %31, %34 ], [ %56, %21 ], [ 0, %14 ], [ %44, %38 ]
%49 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %48)
br label %59
50: ; preds = %19, %50
%51 = phi i32 [ %57, %50 ], [ 1, %19 ]
%52 = phi i64 [ %56, %50 ], [ 0, %19 ]
%53 = mul i32 %51, -2
%54 = add i32 %53, %12
store i32 %51, i32* %16
store i32 %54, i32* %17
%55 = call i64 @permutations_count(i32* %16, i32 2)
%56 = add nsw i64 %55, %52
%57 = add nuw nsw i32 %51, 1
%58 = icmp eq i32 %51, %20
br i1 %58, label %21, label %50
59: ; preds = %47, %9, %5
%60 = phi i32 [ 1, %5 ], [ 0, %47 ], [ 1, %9 ]
ret i32 %60
}