#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 int __mulu10(unsigned int);
unsigned int __divu10(unsigned int n) {
  unsigned int q, r;
  q = (n >> 1) + (n >> 2);
  q = q + (q >> 4);
  q = q + (q >> 8);
  q = q + (q >> 16);
  q = q >> 3;
  r = n - __mulu10(q);
  return q + ((r + 6) >> 4);
}


x86 assembly (clang, -O0):
<__divu10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x1,%eax
mov    -0x4(%rbp),%ecx
shr    $0x2,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    $0x4,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
shr    $0x10,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x3,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <__mulu10@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
add    $0x6,%ecx
shr    $0x4,%ecx
add    %ecx,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__divu10>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%eax
shr    %eax
mov    %edi,%ecx
shr    $0x2,%ecx
add    %eax,%ecx
mov    %ecx,%eax
shr    $0x4,%eax
add    %ecx,%eax
mov    %eax,%ecx
shr    $0x8,%ecx
add    %eax,%ecx
mov    %ecx,%ebp
shr    $0x10,%ebp
add    %ecx,%ebp
shr    $0x3,%ebp
mov    %ebp,%edi
call   1030 <__mulu10@plt>
sub    %eax,%ebx
add    $0x6,%ebx
shr    $0x4,%ebx
add    %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @__divu10(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = lshr i32 %5, 1
%7 = load i32, i32* %2
%8 = lshr i32 %7, 2
%9 = add i32 %6, %8
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = lshr i32 %11, 4
%13 = add i32 %10, %12
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = load i32, i32* %3
%16 = lshr i32 %15, 8
%17 = add i32 %14, %16
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = load i32, i32* %3
%20 = lshr i32 %19, 16
%21 = add i32 %18, %20
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = lshr i32 %22, 3
store i32 %23, i32* %3
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @__mulu10(i32 %25)
%27 = sub i32 %24, %26
store i32 %27, i32* %4
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = add i32 %29, 6
%31 = lshr i32 %30, 4
%32 = add i32 %28, %31
ret i32 %32
}

LLVM IR (-O2):
define i32 @__divu10(i32 %0) {
%2 = lshr i32 %0, 1
%3 = lshr i32 %0, 2
%4 = add nuw i32 %2, %3
%5 = lshr i32 %4, 4
%6 = add nuw i32 %5, %4
%7 = lshr i32 %6, 8
%8 = add nuw i32 %7, %6
%9 = lshr i32 %8, 16
%10 = add nuw i32 %9, %8
%11 = lshr i32 %10, 3
%12 = tail call i32 @__mulu10(i32 %11)
%13 = add i32 %0, 6
%14 = sub i32 %13, %12
%15 = lshr i32 %14, 4
%16 = add nuw nsw i32 %15, %11
ret i32 %16
}