#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int atoi(char *);
double log(int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  if (argc != 2) {
    printf("usage: %s <max>\n", argv[0]);
    return EXIT_FAILURE;
  } else {
    int max;
    int d;
    max = atoi(argv[1]);
    printf("ogg_uint32_t OD_DIVU_SMALL_CONSTS[OD_DIVU_DMAX][2]={\n ");
    for (d = 1; d <= max; d++) {
      if ((d & (d - 1)) == 0) {
        printf(" {0xFFFFFFFF,0xFFFFFFFF},");
      } else {
        unsigned long long t;
        unsigned long long r;
        int m;
        m = ((1.4426950408889634073599246810019) * log(d));
        t = (1UL << (m + (32))) / d;
        r = (t * d + d) & ((1UL << (32)) - 1);
        if (r <= 1UL << m) {
          printf(" {0x%llX,         0},", t + 1);
        } else {
          printf(" {0x%llX,0x%llX},", t, t);
        }
        if (d % 3 == 0) {
          printf("\n ");
        }
      }
    }
    printf("\n};\n");
    return EXIT_SUCCESS;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1176 <main+0x46>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12cf <main+0x19f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     12b5 <main+0x185>
mov    -0x18(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
jne    11ce <main+0x9e>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a2 <main+0x172>
mov    -0x18(%rbp),%edi
call   1040 <log@plt>
movaps %xmm0,%xmm1
movsd  0xe1f(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x20,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0x1,%eax
shl    %cl,%rax
movslq -0x18(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
imul   %rcx,%rax
movslq -0x18(%rbp),%rcx
add    %rcx,%rax
movabs $0xffffffff,%rcx
and    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%rdx
mov    %rdx,%rcx
cmp    %rcx,%rax
ja     1265 <main+0x135>
mov    -0x20(%rbp),%rsi
add    $0x1,%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127b <main+0x14b>
mov    -0x20(%rbp),%rsi
mov    -0x20(%rbp),%rdx
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    129d <main+0x16d>
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a2 <main+0x172>
jmp    12a7 <main+0x177>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119b <main+0x6b>
lea    0xdd6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2d0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    1266 <main+0x126>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r14d,%r14d
jle    1280 <main+0x140>
add    $0x1,%r14d
mov    $0x1,%ebx
mov    $0xffffffff,%ebp
lea    0xec4(%rip),%r15
lea    0xeba(%rip),%r12
jmp    11b7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
add    $0xffffffff,%ebp
cmp    %rbx,%r14
je     1280 <main+0x140>
lea    -0x1(%rbx),%eax
mov    %r15,%rdi
test   %eax,%ebx
je     11a0 <main+0x60>
mov    %ebx,%r13d
mov    $0xaaaaaaab,%eax
imul   %rax,%r13
shr    $0x21,%r13
mov    %ebx,%edi
call   1050 <log@plt>
mulsd  0xe20(%rip),%xmm0
cvttsd2si %xmm0,%esi
lea    0x20(%rsi),%ecx
mov    $0x1,%eax
shl    %cl,%rax
mov    %rbx,%rdx
bts    %rcx,%rdx
shr    $0x20,%rdx
je     1203 <main+0xc3>
xor    %edx,%edx
div    %rbx
jmp    1207 <main+0xc7>
xor    %edx,%edx
div    %ebx
lea    0x0(%r13,%r13,2),%r13d
add    %ebp,%r13d
mov    %eax,%edx
imul   %ebx,%edx
add    %ebx,%edx
mov    $0x1,%edi
mov    %esi,%ecx
shl    %cl,%rdi
cmp    %rdi,%rdx
jbe    1240 <main+0x100>
lea    0xe54(%rip),%rdi
mov    %rax,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1255 <main+0x115>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rax
lea    0xe1f(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
test   %r13d,%r13d
jne    11a7 <main+0x67>
jmp    11a0 <main+0x60>
mov    (%rsi),%rsi
lea    0xd98(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2d62(%rip),%rax
jmp    1293 <main+0x153>
lea    0xe0b(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d45(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"usage: %s <max>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [55 x i8] c"ogg_uint32_t OD_DIVU_SMALL_CONSTS[OD_DIVU_DMAX][2]={\0A \00"
@.str.2 = [26 x i8] c" {0xFFFFFFFF,0xFFFFFFFF},\00"
@.str.3 = [22 x i8] c" {0x%llX, 0},\00"
@.str.4 = [18 x i8] c" {0x%llX,0x%llX},\00"
@.str.5 = [3 x i8] c"\0A \00"
@.str.6 = [5 x i8] c"\0A};\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %19
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
store i32 %18, i32* %3
br label %84
19: ; preds = %2
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i32 @atoi(i8* %22)
store i32 %23, i32* %6
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %7
br label %25
25: ; preds = %78, %19
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %81
29: ; preds = %25
%30 = load i32, i32* %7
%31 = load i32, i32* %7
%32 = sub nsw i32 %31, 1
%33 = and i32 %30, %32
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %29
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
br label %77
37: ; preds = %29
%38 = load i32, i32* %7
%39 = call double @log(i32 %38)
%40 = fmul double 0x3FF71547652B82FE, %39
%41 = fptosi double %40 to i32
store i32 %41, i32* %10
%42 = load i32, i32* %10
%43 = add nsw i32 %42, 32
%44 = zext i32 %43 to i64
%45 = shl i64 1, %44
%46 = load i32, i32* %7
%47 = sext i32 %46 to i64
%48 = udiv i64 %45, %47
store i64 %48, i64* %8
%49 = load i64, i64* %8
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = mul i64 %49, %51
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = add i64 %52, %54
%56 = and i64 %55, 4294967295
store i64 %56, i64* %9
%57 = load i64, i64* %9
%58 = load i32, i32* %10
%59 = zext i32 %58 to i64
%60 = shl i64 1, %59
%61 = icmp ule i64 %57, %60
br i1 %61, label %62, label %66
62: ; preds = %37
%63 = load i64, i64* %8
%64 = add i64 %63, 1
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 %64)
br label %70
66: ; preds = %37
%67 = load i64, i64* %8
%68 = load i64, i64* %8
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i64 %67, i64 %68)
br label %70
70: ; preds = %66, %62
%71 = load i32, i32* %7
%72 = srem i32 %71, 3
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %76
74: ; preds = %70
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %76
76: ; preds = %74, %70
br label %77
77: ; preds = %76, %35
br label %78
78: ; preds = %77
%79 = load i32, i32* %7
%80 = add nsw i32 %79, 1
store i32 %80, i32* %7
br label %25
81: ; preds = %25
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%83 = load i32, i32* @EXIT_SUCCESS
store i32 %83, i32* %3
br label %84
84: ; preds = %81, %13
%85 = load i32, i32* %3
ret i32 %85
}

LLVM IR (-O2):
@.str = [17 x i8] c"usage: %s <max>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [55 x i8] c"ogg_uint32_t OD_DIVU_SMALL_CONSTS[OD_DIVU_DMAX][2]={\0A \00"
@.str.2 = [26 x i8] c" {0xFFFFFFFF,0xFFFFFFFF},\00"
@.str.3 = [22 x i8] c" {0x%llX, 0},\00"
@.str.4 = [18 x i8] c" {0x%llX,0x%llX},\00"
@.str.5 = [3 x i8] c"\0A \00"
@EXIT_SUCCESS = global i32 0
@str = [4 x i8] c"\0A};\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %51
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp slt i32 %10, 1
br i1 %12, label %49, label %13
13: ; preds = %7
%14 = add nuw i32 %10, 1
%15 = zext i32 %14 to i64
br label %16
16: ; preds = %13, %46
%17 = phi i64 [ 1, %13 ], [ %47, %46 ]
%18 = trunc i64 %17 to i32
%19 = tail call i32 @llvm.ctpop.i32(i32 %18)
%20 = icmp ult i32 %19, 2
br i1 %20, label %43, label %21
21: ; preds = %16
%22 = tail call double @log(i32 %18)
%23 = fmul double %22, 0x3FF71547652B82FE
%24 = fptosi double %23 to i32
%25 = add nsw i32 %24, 32
%26 = zext i32 %25 to i64
%27 = shl nuw i64 1, %26
%28 = udiv i64 %27, %17
%29 = mul nuw i64 %28, %17
%30 = add i64 %29, %17
%31 = and i64 %30, 4294967295
%32 = zext i32 %24 to i64
%33 = shl nuw i64 1, %32
%34 = icmp ugt i64 %31, %33
br i1 %34, label %38, label %35
35: ; preds = %21
%36 = add i64 %28, 1
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i64 %36)
br label %40
38: ; preds = %21
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i64 %28, i64 %28)
br label %40
40: ; preds = %38, %35
%41 = urem i32 %18, 3
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %40, %16
%44 = phi i8* [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), %16 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %40 ]
%45 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %44)
br label %46
46: ; preds = %43, %40
%47 = add nuw nsw i64 %17, 1
%48 = icmp eq i64 %47, %15
br i1 %48, label %49, label %16
49: ; preds = %46, %7
%50 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %51
51: ; preds = %49, %4
%52 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_SUCCESS, %49 ]
%53 = load i32, i32* %52
ret i32 %53
}