#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 */
size_t imod5(int);
int diffdpc(int n) {
  int arr[] = {0, 1, 1, 2, 4};
  for (int i = 5; i <= n; i++) {
    arr[imod5(i)] = arr[imod5(i - 1)] + arr[imod5(i - 3)] + arr[imod5(i - 4)];
  }
  return arr[imod5(n)];
}


x86 assembly (clang, -O0):
<diffdpc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    0xede(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xedb(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed9(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x5,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11ac <diffdpc+0x9c>
mov    -0x24(%rbp),%edi
sub    $0x1,%edi
call   1030 <imod5@plt>
mov    -0x20(%rbp,%rax,4),%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%edi
sub    $0x3,%edi
call   1030 <imod5@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%eax
add    -0x20(%rbp,%rcx,4),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%edi
sub    $0x4,%edi
call   1030 <imod5@plt>
mov    %rax,%rcx
mov    -0x2c(%rbp),%eax
add    -0x20(%rbp,%rcx,4),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%edi
call   1030 <imod5@plt>
mov    -0x28(%rbp),%ecx
mov    %ecx,-0x20(%rbp,%rax,4)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1141 <diffdpc+0x31>
mov    -0x4(%rbp),%edi
call   1030 <imod5@plt>
mov    -0x20(%rbp,%rax,4),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<diffdpc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r14d
mov    0xeed(%rip),%eax
mov    %eax,0x10(%rsp)
movaps 0xed2(%rip),%xmm0
movaps %xmm0,(%rsp)
cmp    $0x5,%edi
jl     118e <diffdpc+0x7e>
mov    %r14d,%r15d
neg    %r15d
mov    $0x5,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    -0x1(%rbx),%edi
call   1030 <imod5@plt>
mov    (%rsp,%rax,4),%ebp
lea    -0x3(%rbx),%edi
call   1030 <imod5@plt>
add    (%rsp,%rax,4),%ebp
lea    -0x4(%rbx),%edi
call   1030 <imod5@plt>
add    (%rsp,%rax,4),%ebp
mov    %ebx,%edi
call   1030 <imod5@plt>
mov    %ebp,(%rsp,%rax,4)
lea    (%r15,%rbx,1),%eax
add    $0x1,%eax
mov    %ebx,%ecx
add    $0x1,%ecx
mov    %ecx,%ebx
cmp    $0x1,%eax
jne    1150 <diffdpc+0x40>
mov    %r14d,%edi
call   1030 <imod5@plt>
mov    (%rsp,%rax,4),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@__const.diffdpc.arr = [5 x i32] [i32 0, i32 1, i32 1, i32 2, i32 4]
define i32 @diffdpc(i32 %0) {
%2 = alloca [5 x i32]
%3 = bitcast [5 x i32]* %2 to i8*
%4 = icmp slt i32 %0, 5
br i1 %4, label %5, label %9
5: ; preds = %9, %1
%6 = tail call i64 @imod5(i32 %0)
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %6
%8 = load i32, i32* %7
ret i32 %8
9: ; preds = %1, %9
%10 = phi i32 [ %27, %9 ], [ 5, %1 ]
%11 = add nsw i32 %10, -1
%12 = tail call i64 @imod5(i32 %11)
%13 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %12
%14 = load i32, i32* %13
%15 = add nsw i32 %10, -3
%16 = tail call i64 @imod5(i32 %15)
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = add nsw i32 %18, %14
%20 = add nsw i32 %10, -4
%21 = tail call i64 @imod5(i32 %20)
%22 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = add nsw i32 %19, %23
%25 = tail call i64 @imod5(i32 %10)
%26 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %25
store i32 %24, i32* %26
%27 = add nuw i32 %10, 1
%28 = icmp eq i32 %10, %0
br i1 %28, label %5, label %9
}