#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long long *);
void Problem1() {
  int div = 5, zeroes = 0;
  long long int n;
  printf("Problem 1: Given a number n, the program will print the number of "
         "rightmost 0's of n!.\n");
  printf("Please enter input n: ");
  scanf("%lld", &n);
  while (div <= n) {
    zeroes = zeroes + (n / div);
    div = div * 5;
  }
  printf("The output is: %lld! has %d rightmost 0's.\n", n, zeroes);
}


x86 assembly (clang, -O0):
<Problem1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x5,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf16(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
movslq -0x4(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     119e <Problem1+0x7e>
movslq -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
imul   $0x5,-0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1162 <Problem1+0x42>
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%edx
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Problem1>:
push   %rbx
sub    $0x10,%rsp
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb8(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebf(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x8(%rsp),%rsi
cmp    $0x5,%rsi
jge    1183 <Problem1+0x53>
lea    0xea8(%rip),%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret
mov    $0x5,%ecx
mov    $0x5,%edi
mov    %rsi,%r8
shr    $0x20,%r8
jmp    11b4 <Problem1+0x84>
cs nopw 0x0(%rax,%rax,1)
mov    %rsi,%rax
cqto
idiv   %rdi
add    %eax,%ebx
lea    (%rcx,%rcx,4),%edi
mov    %edi,%ecx
cmp    %rdi,%rsi
jl     116d <Problem1+0x3d>
test   %r8,%r8
jne    11a0 <Problem1+0x70>
mov    %esi,%eax
xor    %edx,%edx
div    %edi
jmp    11a8 <Problem1+0x78>

LLVM IR (-O0):
@.str = [88 x i8] c"Problem 1: Given a number n, the program will print the number of rightmost 0's of n!.\0A\00"
@.str.1 = [23 x i8] c"Please enter input n: \00"
@.str.2 = [5 x i8] c"%lld\00"
@.str.3 = [44 x i8] c"The output is: %lld! has %d rightmost 0's.\0A\00"
define void @Problem1() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
store i32 5, i32* %1
store i32 0, i32* %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([88 x i8], [88 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64* %3)
br label %7
7: ; preds = %12, %0
%8 = load i32, i32* %1
%9 = sext i32 %8 to i64
%10 = load i64, i64* %3
%11 = icmp sle i64 %9, %10
br i1 %11, label %12, label %23
12: ; preds = %7
%13 = load i32, i32* %2
%14 = sext i32 %13 to i64
%15 = load i64, i64* %3
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = sdiv i64 %15, %17
%19 = add nsw i64 %14, %18
%20 = trunc i64 %19 to i32
store i32 %20, i32* %2
%21 = load i32, i32* %1
%22 = mul nsw i32 %21, 5
store i32 %22, i32* %1
br label %7
23: ; preds = %7
%24 = load i64, i64* %3
%25 = load i32, i32* %2
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i64 %24, i32 %25)
ret void
}

LLVM IR (-O2):
@.str.1 = [23 x i8] c"Please enter input n: \00"
@.str.2 = [5 x i8] c"%lld\00"
@.str.3 = [44 x i8] c"The output is: %lld! has %d rightmost 0's.\0A\00"
@str = [87 x i8] c"Problem 1: Given a number n, the program will print the number of rightmost 0's of n!.\00"
define void @Problem1() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([87 x i8], [87 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64* %1)
%6 = load i64, i64* %1
%7 = icmp slt i64 %6, 5
br i1 %7, label %18, label %8
8: ; preds = %0, %8
%9 = phi i64 [ %16, %8 ], [ 5, %0 ]
%10 = phi i32 [ %14, %8 ], [ 0, %0 ]
%11 = phi i32 [ %15, %8 ], [ 5, %0 ]
%12 = sdiv i64 %6, %9
%13 = trunc i64 %12 to i32
%14 = add i32 %10, %13
%15 = mul nsw i32 %11, 5
%16 = zext i32 %15 to i64
%17 = icmp slt i64 %6, %16
br i1 %17, label %18, label %8
18: ; preds = %8, %0
%19 = phi i32 [ 0, %0 ], [ %14, %8 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i64 %6, i32 %19)
ret void
}