#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 */
double ceil(double);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ puts(char *);
int main() {
  int i, j;
  unsigned x;
  double q, r, err, max_err = -1;
  puts("/* This table has been generated by divtab-arc700.c.  */");
  puts(
      "/* 1/512 .. 1/256, normalized.  There is a leading 1 in bit 31.\n   For "
      "powers of two, we list unnormalized numbers instead.  The values\n   "
      "for powers of 2 are loaded, but not used.  The value for 1 is "
      "actually\n   the first instruction after .Lmuldiv.  */\n	.balign 4");
  puts(".Ldivtab:\n");
  for (i = 256; i >= 2; --i) {
    j = i < 0 ? -i : i;
    if (j & (j - 1))
      while (j < 128)
        j += j;
    else
      j *= 128;
    q = 4. * (1 << 30) * 128 / j;
    r = ceil(q);
    printf("\t.long\t0x%X\n", (unsigned)r);
    err = r - q;
    if (err > max_err)
      max_err = err;
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
lea    0xfd8(%rip),%rdi
call   1030 <puts@plt>
movl   $0x100,-0x8(%rbp)
cmpl   $0x2,-0x8(%rbp)
jl     126b <main+0x12b>
cmpl   $0x0,-0x8(%rbp)
jge    11a8 <main+0x68>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
jmp    11ae <main+0x6e>
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     11ed <main+0xad>
jmp    11cd <main+0x8d>
cmpl   $0x80,-0xc(%rbp)
jge    11e8 <main+0xa8>
mov    -0xc(%rbp),%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    11cd <main+0x8d>
jmp    11f6 <main+0xb6>
mov    -0xc(%rbp),%eax
shl    $0x7,%eax
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe05(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <ceil@plt>
movsd  %xmm0,-0x20(%rbp)
cvttsd2si -0x20(%rbp),%rax
mov    %eax,%esi
lea    0xf34(%rip),%rdi
call   1050 <printf@plt>
movsd  -0x20(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1258 <main+0x118>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    125d <main+0x11d>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
jmp    1187 <main+0x47>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
lea    0xeea(%rip),%rdi
call   1030 <puts@plt>
lea    0xfe8(%rip),%rdi
call   1030 <puts@plt>
mov    $0x100,%ebx
lea    0xfe2(%rip),%r14
jmp    11b1 <main+0x71>
cs nopw 0x0(%rax,%rax,1)
mov    %ebx,%eax
shl    $0x7,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xe6c(%rip),%xmm0
divsd  %xmm1,%xmm0
call   1040 <ceil@plt>
cvttsd2si %xmm0,%rsi
mov    %r14,%rdi
call   1050 <printf@plt>
cmp    $0x2,%ebx
mov    %ebp,%ebx
jbe    11ce <main+0x8e>
lea    -0x1(%rbx),%ebp
test   %ebp,%ebx
je     1180 <main+0x40>
mov    %ebx,%ecx
nopw   0x0(%rax,%rax,1)
mov    %ecx,%eax
lea    (%rax,%rax,1),%ecx
cmp    $0x80,%eax
jl     11c0 <main+0x80>
jmp    1185 <main+0x45>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [57 x i8] c"/* This table has been generated by divtab-arc700.c. */\00"
@.str.1 = [266 x i8] c"/* 1/512 .. 1/256, normalized. There is a leading 1 in bit 31.\0A For powers of two, we list unnormalized numbers instead. The values\0A for powers of 2 are loaded, but not used. The value for 1 is actually\0A the first instruction after .Lmuldiv. */\0A\09.balign 4\00"
@.str.2 = [11 x i8] c".Ldivtab:\0A\00"
@.str.3 = [13 x i8] c"\09.long\090x%X\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 0, i32* %1
store double -1.000000e+00, double* %8
%9 = call i32 @puts(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @puts(i8* getelementptr inbounds ([266 x i8], [266 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 256, i32* %2
br label %12
12: ; preds = %60, %0
%13 = load i32, i32* %2
%14 = icmp sge i32 %13, 2
br i1 %14, label %15, label %63
15: ; preds = %12
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* %2
%20 = sub nsw i32 0, %19
br label %23
21: ; preds = %15
%22 = load i32, i32* %2
br label %23
23: ; preds = %21, %18
%24 = phi i32 [ %20, %18 ], [ %22, %21 ]
store i32 %24, i32* %3
%25 = load i32, i32* %3
%26 = load i32, i32* %3
%27 = sub nsw i32 %26, 1
%28 = and i32 %25, %27
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %39
30: ; preds = %23
br label %31
31: ; preds = %34, %30
%32 = load i32, i32* %3
%33 = icmp slt i32 %32, 128
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i32, i32* %3
%36 = load i32, i32* %3
%37 = add nsw i32 %36, %35
store i32 %37, i32* %3
br label %31
38: ; preds = %31
br label %42
39: ; preds = %23
%40 = load i32, i32* %3
%41 = mul nsw i32 %40, 128
store i32 %41, i32* %3
br label %42
42: ; preds = %39, %38
%43 = load i32, i32* %3
%44 = sitofp i32 %43 to double
%45 = fdiv double 0x4260000000000000, %44
store double %45, double* %5
%46 = load double, double* %5
%47 = call double @llvm.ceil.f64(double %46)
store double %47, double* %6
%48 = load double, double* %6
%49 = fptoui double %48 to i32
%50 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = load double, double* %6
%52 = load double, double* %5
%53 = fsub double %51, %52
store double %53, double* %7
%54 = load double, double* %7
%55 = load double, double* %8
%56 = fcmp ogt double %54, %55
br i1 %56, label %57, label %59
57: ; preds = %42
%58 = load double, double* %7
store double %58, double* %8
br label %59
59: ; preds = %57, %42
br label %60
60: ; preds = %59
%61 = load i32, i32* %2
%62 = add nsw i32 %61, -1
store i32 %62, i32* %2
br label %12
63: ; preds = %12
%64 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [57 x i8] c"/* This table has been generated by divtab-arc700.c. */\00"
@.str.1 = [266 x i8] c"/* 1/512 .. 1/256, normalized. There is a leading 1 in bit 31.\0A For powers of two, we list unnormalized numbers instead. The values\0A for powers of 2 are loaded, but not used. The value for 1 is actually\0A the first instruction after .Lmuldiv. */\0A\09.balign 4\00"
@.str.2 = [11 x i8] c".Ldivtab:\0A\00"
@.str.3 = [13 x i8] c"\09.long\090x%X\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([266 x i8], [266 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %4
4: ; preds = %0, %14
%5 = phi i32 [ 256, %0 ], [ %21, %14 ]
%6 = tail call i32 @llvm.ctpop.i32(i32 %5)
%7 = icmp ult i32 %6, 2
br i1 %7, label %12, label %8
8: ; preds = %4, %8
%9 = phi i32 [ %11, %8 ], [ %5, %4 ]
%10 = icmp slt i32 %9, 128
%11 = shl nsw i32 %9, 1
br i1 %10, label %8, label %14
12: ; preds = %4
%13 = shl nsw i32 %5, 7
br label %14
14: ; preds = %8, %12
%15 = phi i32 [ %13, %12 ], [ %9, %8 ]
%16 = sitofp i32 %15 to double
%17 = fdiv double 0x4260000000000000, %16
%18 = tail call double @llvm.ceil.f64(double %17)
%19 = fptoui double %18 to i32
%20 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = add nsw i32 %5, -1
%22 = icmp ugt i32 %5, 2
br i1 %22, label %4, label %23
23: ; preds = %14
%24 = tail call i32 @exit(i32 0)
unreachable
}