#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, int, long long);
scalar_t__ scanf(char *, int *);
int main() {
  long long sum;
  int i, n;
  while (scanf("%d", &n) != EOF) {
    sum = 1;
    for (i = 1; i <= n; i++) {
      sum *= i;
      sum %= 100000000000;
      while (sum % 10 == 0)
        sum /= 10;
    }
    while (sum != 0 && sum % 10 == 0)
      sum /= 10;
    printf("%5d -> %lld\n", n, sum % 10);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%rax
je     1246 <main+0x126>
movq   $0x1,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     11d0 <main+0xb0>
movslq -0x14(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movabs $0x174876e800,%rcx
cqto
idiv   %rcx
mov    %rdx,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11bd <main+0x9d>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    118e <main+0x6e>
jmp    11c2 <main+0xa2>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <main+0x3e>
jmp    11d5 <main+0xb5>
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x19(%rbp)
je     11fd <main+0xdd>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    120d <main+0xed>
jmp    1224 <main+0x104>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    11d5 <main+0xb5>
mov    -0x18(%rbp),%esi
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
lea    0xdc7(%rip),%rdi
call   1030 <printf@plt>
jmp    112f <main+0xf>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xece(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x2ea5(%rip),%rcx
cmp    (%rcx),%rax
jne    1159 <main+0x39>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0xafebff0bcb24ab,%r8
movabs $0x174876e800,%rbp
movabs $0xcccccccccccccccd,%r14
cc cc cc
movabs $0x1999999999999998,%r15
99 99 19
movabs $0x6666666666666667,%r12
66 66 66
movabs $0x1999999999999999,%r13
99 99 19
jmp    11e6 <main+0xc6>
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edx
lea    0xe57(%rip),%rdi
call   1030 <printf@plt>
lea    0xe48(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x2e1f(%rip),%rcx
cmp    (%rcx),%rax
movabs $0xafebff0bcb24ab,%r8
movabs $0x174876e800,%rbp
je     1148 <main+0x28>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11a0 <main+0x80>
lea    0x1(%rsi),%rdi
mov    $0x1,%ebx
mov    $0x1,%ecx
jmp    1209 <main+0xe9>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rdi,%rbx
je     1270 <main+0x150>
imul   %rbx,%rcx
mov    %rcx,%rax
imul   %r8
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x1c,%rdx
add    %rax,%rdx
imul   %rbp,%rdx
sub    %rdx,%rcx
mov    %rcx,%rax
imul   %r14,%rax
add    %r15,%rax
ror    %rax
cmp    %r15,%rax
ja     1200 <main+0xe0>
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rax
imul   %r12
mov    %rdx,%rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rcx
add    %rax,%rcx
mov    %rcx,%rax
imul   %r14,%rax
add    %r15,%rax
ror    %rax
cmp    %r13,%rax
jb     1240 <main+0x120>
jmp    1200 <main+0xe0>
nopl   0x0(%rax,%rax,1)
mov    %rcx,%rax
imul   %r12
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    %rdx,%rdx
lea    (%rdx,%rdx,4),%rax
mov    %rcx,%rdx
sub    %rax,%rdx
test   %rcx,%rcx
je     11a5 <main+0x85>
nopw   0x0(%rax,%rax,1)
test   %rdx,%rdx
jne    11a5 <main+0x85>
mov    %rcx,%rdi
mov    %rcx,%rax
imul   %r12
mov    %rdx,%rcx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rcx
add    %rax,%rcx
mov    %rcx,%rax
imul   %r12
add    $0xfffffffffffffff6,%rdi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    %rdx,%rdx
lea    (%rdx,%rdx,4),%rax
mov    %rcx,%rdx
sub    %rax,%rdx
cmp    $0xffffffffffffffec,%rdi
jbe    12a0 <main+0x180>
jmp    11a5 <main+0x85>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [13 x i8] c"%5d -> %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
br label %5
5: ; preds = %45, %0
%6 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
%7 = load i64, i64* @EOF
%8 = icmp ne i64 %6, %7
br i1 %8, label %9, label %50
9: ; preds = %5
store i64 1, i64* %2
store i32 1, i32* %3
br label %10
10: ; preds = %29, %9
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %32
14: ; preds = %10
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = load i64, i64* %2
%18 = mul nsw i64 %17, %16
store i64 %18, i64* %2
%19 = load i64, i64* %2
%20 = srem i64 %19, 100000000000
store i64 %20, i64* %2
br label %21
21: ; preds = %25, %14
%22 = load i64, i64* %2
%23 = srem i64 %22, 10
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %21
%26 = load i64, i64* %2
%27 = sdiv i64 %26, 10
store i64 %27, i64* %2
br label %21
28: ; preds = %21
br label %29
29: ; preds = %28
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 1
store i32 %31, i32* %3
br label %10
32: ; preds = %10
br label %33
33: ; preds = %42, %32
%34 = load i64, i64* %2
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %33
%37 = load i64, i64* %2
%38 = srem i64 %37, 10
%39 = icmp eq i64 %38, 0
br label %40
40: ; preds = %36, %33
%41 = phi i1 [ false, %33 ], [ %39, %36 ]
br i1 %41, label %42, label %45
42: ; preds = %40
%43 = load i64, i64* %2
%44 = sdiv i64 %43, 10
store i64 %44, i64* %2
br label %33
45: ; preds = %40
%46 = load i32, i32* %4
%47 = load i64, i64* %2
%48 = srem i64 %47, 10
%49 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %46, i64 %48)
br label %5
50: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [13 x i8] c"%5d -> %lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i64, i64* @EOF
%5 = icmp eq i64 %3, %4
br i1 %5, label %47, label %6
6: ; preds = %0, %41
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 1
br i1 %8, label %41, label %9
9: ; preds = %6
%10 = add nuw i32 %7, 1
%11 = zext i32 %10 to i64
br label %17
12: ; preds = %29
%13 = icmp ne i64 %30, 0
%14 = srem i64 %30, 10
%15 = icmp eq i64 %14, 0
%16 = and i1 %13, %15
br i1 %16, label %33, label %41
17: ; preds = %9, %29
%18 = phi i64 [ 1, %9 ], [ %31, %29 ]
%19 = phi i64 [ 1, %9 ], [ %30, %29 ]
%20 = mul nsw i64 %19, %18
%21 = srem i64 %20, 100000000000
%22 = srem i64 %21, 10
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %17, %24
%25 = phi i64 [ %26, %24 ], [ %21, %17 ]
%26 = sdiv i64 %25, 10
%27 = srem i64 %26, 10
%28 = icmp eq i64 %27, 0
br i1 %28, label %24, label %29
29: ; preds = %24, %17
%30 = phi i64 [ %21, %17 ], [ %26, %24 ]
%31 = add nuw nsw i64 %18, 1
%32 = icmp eq i64 %31, %11
br i1 %32, label %12, label %17
33: ; preds = %12, %33
%34 = phi i64 [ %35, %33 ], [ %30, %12 ]
%35 = sdiv i64 %34, 10
%36 = add nsw i64 %34, -10
%37 = icmp ult i64 %36, -19
%38 = srem i64 %35, 10
%39 = icmp eq i64 %38, 0
%40 = and i1 %37, %39
br i1 %40, label %33, label %41
41: ; preds = %33, %6, %12
%42 = phi i64 [ %14, %12 ], [ 1, %6 ], [ %38, %33 ]
%43 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i32 %7, i64 %42)
%44 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%45 = load i64, i64* @EOF
%46 = icmp eq i64 %44, %45
br i1 %46, label %47, label %6
47: ; preds = %41, %0
ret i32 0
}