#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 factorial(int);
int /*<<< orphan*/ printf(char *, int);
int trailingZeros(int a) {
  int f, m, count;
  count = 0;
  f = factorial(a);
  while (f > 0) {
    m = f % 10;
    printf("%d\n", (f % 10));
    if ((f % 10) == 0)
      count++;
    f = f / 10;
  }
  printf("%d\n", count);
  return count;
}


x86 assembly (clang, -O0):
<trailingZeros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    119e <trailingZeros+0x7e>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    118b <trailingZeros+0x6b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    113d <trailingZeros+0x1d>
mov    -0x10(%rbp),%esi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trailingZeros>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
call   1030 <factorial@plt>
test   %eax,%eax
jle    1182 <trailingZeros+0x62>
mov    %eax,%r13d
xor    %r12d,%r12d
lea    0xebf(%rip),%r14
mov    $0xcccccccd,%r15d
nopw   0x0(%rax,%rax,1)
mov    %r13d,%ebx
imul   %r15,%rbx
shr    $0x23,%rbx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
xor    %ebp,%ebp
mov    %r13d,%esi
sub    %eax,%esi
sete   %bpl
mov    %r14,%rdi
call   1040 <printf@plt>
add    %ebp,%r12d
cmp    $0x9,%r13d
mov    %ebx,%r13d
ja     1150 <trailingZeros+0x30>
jmp    1185 <trailingZeros+0x65>
xor    %r12d,%r12d
lea    0xe74(%rip),%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @trailingZeros(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %5
%6 = load i32, i32* %2
%7 = call i32 @factorial(i32 %6)
store i32 %7, i32* %3
br label %8
8: ; preds = %23, %1
%9 = load i32, i32* %3
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %8
%12 = load i32, i32* %3
%13 = srem i32 %12, 10
store i32 %13, i32* %4
%14 = load i32, i32* %3
%15 = srem i32 %14, 10
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %3
%18 = srem i32 %17, 10
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %11
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %23
23: ; preds = %20, %11
%24 = load i32, i32* %3
%25 = sdiv i32 %24, 10
store i32 %25, i32* %3
br label %8
26: ; preds = %8
%27 = load i32, i32* %5
%28 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %5
ret i32 %29
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @trailingZeros(i32 %0) {
%2 = tail call i32 @factorial(i32 %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %14
4: ; preds = %1, %4
%5 = phi i32 [ %11, %4 ], [ 0, %1 ]
%6 = phi i32 [ %12, %4 ], [ %2, %1 ]
%7 = urem i32 %6, 10
%8 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %7, 0
%10 = zext i1 %9 to i32
%11 = add nuw nsw i32 %5, %10
%12 = udiv i32 %6, 10
%13 = icmp ult i32 %6, 10
br i1 %13, label %14, label %4
14: ; preds = %4, %1
%15 = phi i32 [ 0, %1 ], [ %11, %4 ]
%16 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
ret i32 %15
}