#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 int uint32_t;

/* Variables and functions */
uint32_t div_u32_by_10(uint32_t n) {
  uint32_t q, r;
  q = (n >> 1) + (n >> 2);
  q = q + (q >> 4);
  q = q + (q >> 8);
  q = q + (q >> 16);
  q = q >> 3;
  r = n - (((q << 2) + q) << 1);
  return q + (r > 9);
}


x86 assembly (clang, -O0):
<div_u32_by_10>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x1,%eax
mov    -0x4(%rbp),%ecx
sar    $0x2,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
sar    $0x4,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
sar    $0x8,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
sar    $0x10,%ecx
add    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x3,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
add    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
cmpl   $0x9,-0xc(%rbp)
setg   %cl
and    $0x1,%cl
movzbl %cl,%ecx
add    %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<div_u32_by_10>:
mov    %edi,%eax
sar    %eax
mov    %edi,%ecx
sar    $0x2,%ecx
add    %eax,%ecx
mov    %ecx,%eax
sar    $0x4,%eax
add    %ecx,%eax
mov    %eax,%ecx
sar    $0x8,%ecx
add    %eax,%ecx
mov    %ecx,%edx
sar    $0x10,%edx
add    %ecx,%edx
sar    $0x3,%edx
lea    (%rdx,%rdx,1),%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%edi
xor    %eax,%eax
cmp    $0xa,%edi
setge  %al
add    %edx,%eax
ret

LLVM IR (-O0):
define i32 @div_u32_by_10(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = ashr i32 %5, 1
%7 = load i32, i32* %2
%8 = ashr i32 %7, 2
%9 = add nsw i32 %6, %8
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = load i32, i32* %3
%12 = ashr i32 %11, 4
%13 = add nsw i32 %10, %12
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = load i32, i32* %3
%16 = ashr i32 %15, 8
%17 = add nsw i32 %14, %16
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = load i32, i32* %3
%20 = ashr i32 %19, 16
%21 = add nsw i32 %18, %20
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = ashr i32 %22, 3
store i32 %23, i32* %3
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = shl i32 %25, 2
%27 = load i32, i32* %3
%28 = add nsw i32 %26, %27
%29 = shl i32 %28, 1
%30 = sub nsw i32 %24, %29
store i32 %30, i32* %4
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 9
%34 = zext i1 %33 to i32
%35 = add nsw i32 %31, %34
ret i32 %35
}

LLVM IR (-O2):
define i32 @div_u32_by_10(i32 %0) {
%2 = ashr i32 %0, 1
%3 = ashr i32 %0, 2
%4 = add nsw i32 %2, %3
%5 = ashr i32 %4, 4
%6 = add nsw i32 %5, %4
%7 = ashr i32 %6, 8
%8 = add nsw i32 %7, %6
%9 = ashr i32 %8, 16
%10 = add nsw i32 %9, %8
%11 = ashr i32 %10, 3
%12 = mul i32 %11, -10
%13 = add i32 %12, %0
%14 = icmp sgt i32 %13, 9
%15 = zext i1 %14 to i32
%16 = add nsw i32 %11, %15
ret i32 %16
}