#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 log10(double);
int pow(int, double);
int /*<<< orphan*/ printf(char *, ...);
void print_cb_add_table(void) {
  int i;
  printf("const int32_t cb_to_add[256] = {");
  for (i = 0; i < 256; i++) {
    double add = 1 + pow(10, -0.01 * i);
    add = 100 * log10(add);
    if (i % 8 == 0)
      printf("\n   ");
    printf(" %d,", (int)add);
  }
  printf("\n};\n\n");
}


x86 assembly (clang, -O0):
<print_cb_add_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x100,-0x4(%rbp)
jge    11da <print_cb_add_table+0xaa>
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe99(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    $0xa,%edi
call   1040 <pow@plt>
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <log10@plt>
imul   $0x64,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11b9 <print_cb_add_table+0x89>
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvttsd2si -0x10(%rbp),%esi
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114d <print_cb_add_table+0x1d>
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cb_add_table>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xorpd  %xmm0,%xmm0
lea    0xed1(%rip),%r14
lea    0xecf(%rip),%r15
xor    %ebx,%ebx
jmp    1194 <print_cb_add_table+0x54>
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
addsd  0xe7f(%rip),%xmm0
add    $0x1,%ebx
cmp    $0x100,%ebx
je     11ce <print_cb_add_table+0x8e>
movsd  %xmm0,(%rsp)
mulsd  0xe5f(%rip),%xmm0
mov    $0xa,%edi
call   1050 <pow@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
call   1060 <log10@plt>
imul   $0x64,%eax,%ebp
test   $0x7,%bl
jne    1170 <print_cb_add_table+0x30>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <print_cb_add_table+0x30>
lea    0xe66(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"const int32_t cb_to_add[256] = {\00"
@.str.1 = [5 x i8] c"\0A \00"
@.str.2 = [5 x i8] c" %d,\00"
@.str.3 = [6 x i8] c"\0A};\0A\0A\00"
define void @print_cb_add_table() {
%1 = alloca i32
%2 = alloca double
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %4
4: ; preds = %27, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 256
br i1 %6, label %7, label %30
7: ; preds = %4
%8 = load i32, i32* %1
%9 = sitofp i32 %8 to double
%10 = fmul double -1.000000e-02, %9
%11 = call i32 @pow(i32 10, double %10)
%12 = add nsw i32 1, %11
%13 = sitofp i32 %12 to double
store double %13, double* %2
%14 = load double, double* %2
%15 = call i32 @log10(double %14)
%16 = mul nsw i32 100, %15
%17 = sitofp i32 %16 to double
store double %17, double* %2
%18 = load i32, i32* %1
%19 = srem i32 %18, 8
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %7
%24 = load double, double* %2
%25 = fptosi double %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %23
%28 = load i32, i32* %1
%29 = add nsw i32 %28, 1
store i32 %29, i32* %1
br label %4
30: ; preds = %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"const int32_t cb_to_add[256] = {\00"
@.str.1 = [5 x i8] c"\0A \00"
@.str.2 = [5 x i8] c" %d,\00"
@str = [5 x i8] c"\0A};\0A\00"
define void @print_cb_add_table() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %15
%3 = phi i32 [ 0, %0 ], [ %17, %15 ]
%4 = sitofp i32 %3 to double
%5 = fmul double %4, -1.000000e-02
%6 = tail call i32 @pow(i32 10, double %5)
%7 = add nsw i32 %6, 1
%8 = sitofp i32 %7 to double
%9 = tail call i32 @log10(double %8)
%10 = mul nsw i32 %9, 100
%11 = and i32 %3, 7
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %2
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%17 = add nuw nsw i32 %3, 1
%18 = icmp eq i32 %17, 256
br i1 %18, label %19, label %2
19: ; preds = %15
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
ret void
}