#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 */
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int, unsigned int);
unsigned int udiv32(unsigned int);
int main(void) {
  unsigned int i;
  for (i = 0x6000; i < 0x6010; i++) {
    unsigned int exact_answer = i / 10;
    unsigned int xxx = udiv32(i);
    if (xxx != exact_answer) {
      printf("W %d %d %d\n", i, exact_answer, xxx);
    }
    printf("%d %d %d\n", i, exact_answer, xxx);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x6000,-0x8(%rbp)
cmpl   $0x6010,-0x8(%rbp)
jae    11a1 <main+0x81>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <udiv32@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     117e <main+0x5e>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe87(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe74(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <main+0x16>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x6000,%ebx
lea    0xece(%rip),%r14
lea    0xec5(%rip),%r15
jmp    115a <main+0x3a>
nopl   (%rax)
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x6010,%ebx
je     1185 <main+0x65>
movzwl %bx,%eax
imul   $0xcccd,%eax,%ebp
shr    $0x13,%ebp
mov    %ebx,%edi
call   1040 <udiv32@plt>
mov    %eax,%r12d
cmp    %ebp,%eax
je     1140 <main+0x20>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1030 <printf@plt>
jmp    1140 <main+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"W %d %d %d\0A\00"
@.str.1 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 24576, i32* %2
br label %5
5: ; preds = %26, %0
%6 = load i32, i32* %2
%7 = icmp ult i32 %6, 24592
br i1 %7, label %8, label %29
8: ; preds = %5
%9 = load i32, i32* %2
%10 = udiv i32 %9, 10
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = call i32 @udiv32(i32 %11)
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = icmp ne i32 %13, %14
br i1 %15, label %16, label %21
16: ; preds = %8
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = load i32, i32* %4
%20 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %17, i32 %18, i32 %19)
br label %21
21: ; preds = %16, %8
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = load i32, i32* %4
%25 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23, i32 %24)
br label %26
26: ; preds = %21
%27 = load i32, i32* %2
%28 = add i32 %27, 1
store i32 %28, i32* %2
br label %5
29: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"W %d %d %d\0A\00"
@.str.1 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %10
%2 = phi i32 [ 24576, %0 ], [ %12, %10 ]
%3 = trunc i32 %2 to i16
%4 = udiv i16 %3, 10
%5 = zext i16 %4 to i32
%6 = tail call i32 @udiv32(i32 %2)
%7 = icmp eq i32 %6, %5
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %2, i32 %5, i32 %6)
br label %10
10: ; preds = %8, %1
%11 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %2, i32 %5, i32 %6)
%12 = add nuw nsw i32 %2, 1
%13 = icmp eq i32 %12, 24592
br i1 %13, label %14, label %1
14: ; preds = %10
ret i32 0
}