#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__ powers_of_five(int);
int direct_trailing_zeros(int n) {
  int z = 0;
  for (; n > 4; n--) {
    if (n % 5 == 0)
      z += powers_of_five(n);
  }
  return z;
}


x86 assembly (clang, -O0):
<direct_trailing_zeros>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x4,-0x4(%rbp)
jle    1168 <direct_trailing_zeros+0x58>
mov    -0x4(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1155 <direct_trailing_zeros+0x45>
mov    -0x4(%rbp),%edi
call   1030 <powers_of_five@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
jmp    115a <direct_trailing_zeros+0x4a>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x4(%rbp)
jmp    1122 <direct_trailing_zeros+0x12>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<direct_trailing_zeros>:
push   %rbp
push   %r14
push   %rbx
xor    %ebp,%ebp
cmp    $0x5,%edi
jl     1156 <direct_trailing_zeros+0x46>
mov    %edi,%ebx
xor    %ebp,%ebp
mov    $0xcccccccd,%r14d
jmp    113a <direct_trailing_zeros+0x2a>
nopw   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%eax
cmp    $0x5,%ebx
mov    %eax,%ebx
jle    1156 <direct_trailing_zeros+0x46>
mov    %ebx,%eax
imul   %r14,%rax
shr    $0x22,%rax
lea    (%rax,%rax,4),%eax
cmp    %ebx,%eax
jne    1130 <direct_trailing_zeros+0x20>
mov    %ebx,%edi
call   1030 <powers_of_five@plt>
add    %eax,%ebp
jmp    1130 <direct_trailing_zeros+0x20>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @direct_trailing_zeros(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %19, %1
%5 = load i32, i32* %2
%6 = icmp sgt i32 %5, 4
br i1 %6, label %7, label %22
7: ; preds = %4
%8 = load i32, i32* %2
%9 = srem i32 %8, 5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %7
%12 = load i32, i32* %2
%13 = call i64 @powers_of_five(i32 %12)
%14 = load i32, i32* %3
%15 = sext i32 %14 to i64
%16 = add nsw i64 %15, %13
%17 = trunc i64 %16 to i32
store i32 %17, i32* %3
br label %18
18: ; preds = %11, %7
br label %19
19: ; preds = %18
%20 = load i32, i32* %2
%21 = add nsw i32 %20, -1
store i32 %21, i32* %2
br label %4
22: ; preds = %4
%23 = load i32, i32* %3
ret i32 %23
}

LLVM IR (-O2):
define i32 @direct_trailing_zeros(i32 %0) {
%2 = icmp sgt i32 %0, 4
br i1 %2, label %3, label %16
3: ; preds = %1, %12
%4 = phi i32 [ %13, %12 ], [ 0, %1 ]
%5 = phi i32 [ %14, %12 ], [ %0, %1 ]
%6 = urem i32 %5, 5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = tail call i64 @powers_of_five(i32 %5)
%10 = trunc i64 %9 to i32
%11 = add i32 %4, %10
br label %12
12: ; preds = %3, %8
%13 = phi i32 [ %11, %8 ], [ %4, %3 ]
%14 = add nsw i32 %5, -1
%15 = icmp sgt i32 %5, 5
br i1 %15, label %3, label %16
16: ; preds = %12, %1
%17 = phi i32 [ 0, %1 ], [ %13, %12 ]
ret i32 %17
}