#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 *, ...);
int main(void) {
  unsigned int a;
  unsigned int x;
  unsigned int d;
  unsigned int r;
  unsigned int dc = 0U;
  printf("0x0000: -");
  for (a = 1U; a < 0x10000U; a++) {
    r = 0x10000U / a;
    x = 0xFFFFU / a;
    if (((a * x) + a) == 0x10000U) {
      x++;
    }
    d = r - x;
    if ((a & 0x3F) == 0x00) {
      printf("\n0x%04X: ", a);
    }
    if (d != 0U) {
      printf("%i", d);
      dc++;
    } else {
      printf(".");
    }
  }
  printf("\nDiffs: %i\n", dc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xed3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x8(%rbp)
cmpl   $0x10000,-0x8(%rbp)
jae    11f3 <main+0xe3>
mov    $0x10000,%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    %eax,-0x14(%rbp)
mov    $0xffff,%eax
xor    %edx,%edx
divl   -0x8(%rbp)
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
imul   -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
cmp    $0x10000,%eax
jne    1180 <main+0x70>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0x3f,%eax
cmp    $0x0,%eax
jne    11a9 <main+0x99>
mov    -0x8(%rbp),%esi
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
je     11d2 <main+0xc2>
mov    -0x10(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e0 <main+0xd0>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e5 <main+0xd5>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    113b <main+0x2b>
mov    -0x18(%rbp),%esi
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xed1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%ebp
lea    0xec8(%rip),%r14
lea    0xecb(%rip),%r15
xor    %r12d,%r12d
jmp    1165 <main+0x45>
xchg   %ax,%ax
mov    $0x2e,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    $0x10000,%ebp
je     11c2 <main+0xa2>
mov    $0x10000,%eax
xor    %edx,%edx
div    %ebp
mov    %eax,%ebx
mov    $0xffff,%ax
xor    %edx,%edx
div    %bp
movzwl %ax,%eax
mov    %ebp,%ecx
imul   %eax,%ecx
add    %ebp,%ecx
xor    %edx,%edx
cmp    $0x10000,%ecx
sete   %dl
sub    %eax,%ebx
sub    %edx,%ebx
test   $0x3f,%bpl
je     11a0 <main+0x80>
test   %ebx,%ebx
jne    11b0 <main+0x90>
jmp    1150 <main+0x30>
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
test   %ebx,%ebx
je     1150 <main+0x30>
mov    %r15,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
jmp    115a <main+0x3a>
lea    0xe4e(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"0x0000: -\00"
@.str.1 = [10 x i8] c"\0A0x%04X: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [2 x i8] c".\00"
@.str.4 = [12 x i8] c"\0ADiffs: %i\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %2
br label %8
8: ; preds = %46, %0
%9 = load i32, i32* %2
%10 = icmp ult i32 %9, 65536
br i1 %10, label %11, label %49
11: ; preds = %8
%12 = load i32, i32* %2
%13 = udiv i32 65536, %12
store i32 %13, i32* %5
%14 = load i32, i32* %2
%15 = udiv i32 65535, %14
store i32 %15, i32* %3
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = mul i32 %16, %17
%19 = load i32, i32* %2
%20 = add i32 %18, %19
%21 = icmp eq i32 %20, 65536
br i1 %21, label %22, label %25
22: ; preds = %11
%23 = load i32, i32* %3
%24 = add i32 %23, 1
store i32 %24, i32* %3
br label %25
25: ; preds = %22, %11
%26 = load i32, i32* %5
%27 = load i32, i32* %3
%28 = sub i32 %26, %27
store i32 %28, i32* %4
%29 = load i32, i32* %2
%30 = and i32 %29, 63
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %35
32: ; preds = %25
%33 = load i32, i32* %2
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32, %25
%36 = load i32, i32* %4
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i32, i32* %4
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %6
%42 = add i32 %41, 1
store i32 %42, i32* %6
br label %45
43: ; preds = %35
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %45
45: ; preds = %43, %38
br label %46
46: ; preds = %45
%47 = load i32, i32* %2
%48 = add i32 %47, 1
store i32 %48, i32* %2
br label %8
49: ; preds = %8
%50 = load i32, i32* %6
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %50)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"0x0000: -\00"
@.str.1 = [10 x i8] c"\0A0x%04X: \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.4 = [12 x i8] c"\0ADiffs: %i\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %26
%3 = phi i32 [ 0, %0 ], [ %27, %26 ]
%4 = phi i32 [ 1, %0 ], [ %28, %26 ]
%5 = udiv i32 65536, %4
%6 = trunc i32 %4 to i16
%7 = udiv i16 -1, %6
%8 = zext i16 %7 to i32
%9 = mul nuw i32 %4, %8
%10 = add nuw i32 %9, %4
%11 = icmp eq i32 %10, 65536
%12 = sext i1 %11 to i32
%13 = sub nsw i32 %5, %8
%14 = add nsw i32 %13, %12
%15 = and i32 %4, 63
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %4)
br label %19
19: ; preds = %17, %2
%20 = icmp eq i32 %14, 0
br i1 %20, label %24, label %21
21: ; preds = %19
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%23 = add i32 %3, 1
br label %26
24: ; preds = %19
%25 = tail call i32 @putchar(i32 46)
br label %26
26: ; preds = %21, %24
%27 = phi i32 [ %23, %21 ], [ %3, %24 ]
%28 = add nuw nsw i32 %4, 1
%29 = icmp eq i32 %28, 65536
br i1 %29, label %30, label %2
30: ; preds = %26
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i32 %27)
ret i32 0
}