#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 P(long long);
long long int L(long long int n) {
  long long int arr[] = {1, 1, 2, 6, 4};
  if (n < 5)
    return arr[n];
  else {
    return (P(n / 5) * L(n / 5) * L(n % 5)) % 10;
  }
}


x86 assembly (clang, -O0):
<L>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movq   $0x1,-0x40(%rbp)
movq   $0x1,-0x38(%rbp)
movq   $0x2,-0x30(%rbp)
movq   $0x6,-0x28(%rbp)
movq   $0x4,-0x20(%rbp)
cmpq   $0x5,-0x10(%rbp)
jge    1191 <L+0x61>
mov    -0x10(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rax
mov    %rax,-0x8(%rbp)
jmp    1201 <L+0xd1>
mov    -0x10(%rbp),%rax
mov    $0x5,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
call   1030 <P@plt>
cltq
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x5,%ecx
cqto
idiv   %rcx
mov    %rax,%rdi
call   1040 <L@plt>
mov    %rax,%rcx
mov    -0x50(%rbp),%rax
imul   %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x5,%ecx
cqto
idiv   %rcx
mov    %rdx,%rdi
call   1040 <L@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
imul   %rcx,%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<L>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
movaps 0xecb(%rip),%xmm0
movaps %xmm0,(%rsp)
movaps 0xed0(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x4,0x20(%rsp)
cmp    $0x4,%rdi
jg     115a <L+0x3a>
mov    (%rsp,%rbx,8),%rcx
jmp    11c9 <L+0xa9>
movabs $0xcccccccccccccccd,%rcx
cc cc cc
mov    %rbx,%rax
mul    %rcx
mov    %rdx,%r14
shr    $0x2,%r14
mov    %r14,%rdi
call   1030 <P@plt>
movslq %eax,%r12
mov    %r14,%rdi
call   1040 <L@plt>
mov    %rax,%r15
imul   %r12,%r15
lea    (%r14,%r14,4),%rax
sub    %rax,%rbx
mov    %rbx,%rdi
call   1040 <L@plt>
mov    %rax,%rcx
imul   %r15,%rcx
movabs $0x6666666666666667,%rdx
66 66 66
mov    %rcx,%rax
imul   %rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    %rdx,%rdx
lea    (%rdx,%rdx,4),%rax
sub    %rax,%rcx
mov    %rcx,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i64 @L(i64 %0) {
%2 = alloca [5 x i64]
%3 = bitcast [5 x i64]* %2 to i8*
%4 = bitcast [5 x i64]* %2 to <2 x i64>*
store <2 x i64> <i64 1, i64 1>, <2 x i64>* %4
%5 = getelementptr inbounds [5 x i64], [5 x i64]* %2, i64 0, i64 2
%6 = bitcast i64* %5 to <2 x i64>*
store <2 x i64> <i64 2, i64 6>, <2 x i64>* %6
%7 = getelementptr inbounds [5 x i64], [5 x i64]* %2, i64 0, i64 4
store i64 4, i64* %7
%8 = icmp slt i64 %0, 5
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = getelementptr inbounds [5 x i64], [5 x i64]* %2, i64 0, i64 %0
%11 = load i64, i64* %10
br label %22
12: ; preds = %1
%13 = udiv i64 %0, 5
%14 = tail call i32 @P(i64 %13)
%15 = sext i32 %14 to i64
%16 = tail call i64 @L(i64 %13)
%17 = mul nsw i64 %16, %15
%18 = urem i64 %0, 5
%19 = tail call i64 @L(i64 %18)
%20 = mul nsw i64 %17, %19
%21 = srem i64 %20, 10
br label %22
22: ; preds = %12, %9
%23 = phi i64 [ %11, %9 ], [ %21, %12 ]
ret i64 %23
}