#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 */
typedef unsigned int uint64_t;
typedef int uint32_t;

/* Variables and functions */
void _ldiv5(uint64_t *v) {
  uint32_t i, hi;
  uint64_t rem = *v, quot = 0U, q;
  static const char shifts[] = {32, 3, 0};
  rem += 2U;
  for (i = 0U; i < 3; i++) {
    hi = rem >> shifts[i];
    q = (uint64_t)(hi / 5U) << shifts[i];
    rem -= q * 5U;
    quot += q;
  }
  *v = quot;
}


x86 assembly (clang, -O0):
<_ldiv5>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x3,-0xc(%rbp)
jge    118c <_ldiv5+0x8c>
mov    -0x14(%rbp),%eax
movslq -0xc(%rbp),%rdx
lea    0xec0(%rip),%rcx
movsbl (%rcx,%rdx,1),%ecx
shr    %cl,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x5,%ecx
xor    %edx,%edx
div    %ecx
movslq -0xc(%rbp),%rdx
lea    0xea0(%rip),%rcx
movsbl (%rcx,%rdx,1),%ecx
shl    %cl,%eax
mov    %eax,-0x1c(%rbp)
imul   $0x5,-0x1c(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1128 <_ldiv5+0x28>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ldiv5>:
ret

LLVM IR (-O0):
@_ldiv5.shifts = internal constant [3 x i8] c" \03\00"
define void @_ldiv5(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %2
%8 = load i32*, i32** %2
%9 = load i32, i32* %8
store i32 %9, i32* %5
store i32 0, i32* %6
%10 = load i32, i32* %5
%11 = add i32 %10, 2
store i32 %11, i32* %5
store i32 0, i32* %3
br label %12
12: ; preds = %38, %1
%13 = load i32, i32* %3
%14 = icmp slt i32 %13, 3
br i1 %14, label %15, label %41
15: ; preds = %12
%16 = load i32, i32* %5
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [3 x i8], [3 x i8]* @_ldiv5.shifts, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = lshr i32 %16, %21
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = udiv i32 %23, 5
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [3 x i8], [3 x i8]* @_ldiv5.shifts, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = shl i32 %24, %29
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = mul i32 %31, 5
%33 = load i32, i32* %5
%34 = sub i32 %33, %32
store i32 %34, i32* %5
%35 = load i32, i32* %7
%36 = load i32, i32* %6
%37 = add i32 %36, %35
store i32 %37, i32* %6
br label %38
38: ; preds = %15
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 1
store i32 %40, i32* %3
br label %12
41: ; preds = %12
%42 = load i32, i32* %6
%43 = load i32*, i32** %2
store i32 %42, i32* %43
ret void
}

LLVM IR (-O2):
define void @_ldiv5(i32* nocapture %0) {
ret void
}