#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 */
unsigned long long div10(unsigned int);
unsigned long long int div10l(unsigned long long int v) {
  static unsigned long long int rest_add[] = {
      0x00000000, 0x1999999a, 0x33333334, 0x4ccccccd, 0x66666667,
      0x80000001, 0x9999999a, 0xb3333334, 0xcccccccd, 0xe6666667};
  unsigned long long int a = div10((unsigned int)(v >> 32));
  unsigned long long int b = div10((unsigned int)(v & 0xffffffff));
  int ri = (v >> 32) - a * 10;
  unsigned long long int ret = (a << 32) + b + rest_add[ri];
  if (ret * 10L > v) {
    --ret;
  }
  return ret;
}


x86 assembly (clang, -O0):
<div10l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x20,%rax
mov    %eax,%edi
call   1030 <div10@plt>
mov    %rax,-0x10(%rbp)
movabs $0xffffffff,%rax
and    -0x8(%rbp),%rax
mov    %eax,%edi
call   1030 <div10@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
shr    $0x20,%rax
imul   $0xa,-0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x20,%rax
add    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rdx
lea    0x2ebe(%rip),%rcx
add    (%rcx,%rdx,8),%rax
mov    %rax,-0x28(%rbp)
imul   $0xa,-0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jbe    1195 <div10l+0x85>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<div10l>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    %rdi,%rbx
shr    $0x20,%rbx
mov    %ebx,%edi
call   1030 <div10@plt>
mov    %rax,%r15
mov    %r14d,%edi
call   1030 <div10@plt>
lea    (%r15,%r15,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%ebx
shl    $0x20,%r15
add    %r15,%rax
movslq %ebx,%rcx
lea    0xeb5(%rip),%rdx
add    (%rdx,%rcx,8),%rax
lea    (%rax,%rax,1),%rcx
lea    (%rcx,%rcx,4),%rcx
cmp    %rcx,%r14
sbb    $0x0,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@div10l.rest_add = internal global [10 x i64] [i64 0, i64 429496730, i64 858993460, i64 1288490189, i64 1717986919, i64 2147483649, i64 2576980378, i64 3006477108, i64 3435973837, i64 3865470567]
define i64 @div10l(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
%6 = alloca i64
store i64 %0, i64* %2
%7 = load i64, i64* %2
%8 = lshr i64 %7, 32
%9 = trunc i64 %8 to i32
%10 = call i64 @div10(i32 %9)
store i64 %10, i64* %3
%11 = load i64, i64* %2
%12 = and i64 %11, 4294967295
%13 = trunc i64 %12 to i32
%14 = call i64 @div10(i32 %13)
store i64 %14, i64* %4
%15 = load i64, i64* %2
%16 = lshr i64 %15, 32
%17 = load i64, i64* %3
%18 = mul i64 %17, 10
%19 = sub i64 %16, %18
%20 = trunc i64 %19 to i32
store i32 %20, i32* %5
%21 = load i64, i64* %3
%22 = shl i64 %21, 32
%23 = load i64, i64* %4
%24 = add i64 %22, %23
%25 = load i32, i32* %5
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [10 x i64], [10 x i64]* @div10l.rest_add, i64 0, i64 %26
%28 = load i64, i64* %27
%29 = add i64 %24, %28
store i64 %29, i64* %6
%30 = load i64, i64* %6
%31 = mul i64 %30, 10
%32 = load i64, i64* %2
%33 = icmp ugt i64 %31, %32
br i1 %33, label %34, label %37
34: ; preds = %1
%35 = load i64, i64* %6
%36 = add i64 %35, -1
store i64 %36, i64* %6
br label %37
37: ; preds = %34, %1
%38 = load i64, i64* %6
ret i64 %38
}

LLVM IR (-O2):
@div10l.rest_add = internal unnamed_addr constant [10 x i64] [i64 0, i64 429496730, i64 858993460, i64 1288490189, i64 1717986919, i64 2147483649, i64 2576980378, i64 3006477108, i64 3435973837, i64 3865470567]
define i64 @div10l(i64 %0) {
%2 = lshr i64 %0, 32
%3 = trunc i64 %2 to i32
%4 = tail call i64 @div10(i32 %3)
%5 = trunc i64 %0 to i32
%6 = tail call i64 @div10(i32 %5)
%7 = mul i64 %4, -10
%8 = add i64 %7, %2
%9 = shl i64 %4, 32
%10 = add i64 %9, %6
%11 = shl i64 %8, 32
%12 = ashr exact i64 %11, 32
%13 = getelementptr inbounds [10 x i64], [10 x i64]* @div10l.rest_add, i64 0, i64 %12
%14 = load i64, i64* %13
%15 = add i64 %10, %14
%16 = mul i64 %15, 10
%17 = icmp ugt i64 %16, %0
%18 = sext i1 %17 to i64
%19 = add i64 %15, %18
ret i64 %19
}