#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 */
typedef int /*<<< orphan*/ mpf_t;

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ exit(int);
int fp_cache_get(char *, int /*<<< orphan*/, int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
double log(double);
int /*<<< orphan*/ mpf_init(int /*<<< orphan*/);
int /*<<< orphan*/ mpf_set_default_prec(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  if (argc < 4) {
    fprintf(stderr, "Usage: %s <db> <from> <to>\n", argv[0]);
    exit(1);
  }
  char *db = argv[1];
  int from = atoi(argv[2]);
  int maxidx = atoi(argv[3]);
  int prec = 100;
  double v = ((double)prec) * log(10.0) / log(2.0);
  int bits = (int)(v + 100);
  mpf_set_default_prec(bits);
  printf("printout of %s up to n=%d\n", db, maxidx);
  mpf_t val;
  mpf_init(val);
  int n;
  int lastprec = -1;
  int lastn = 0;
  for (n = from; n <= maxidx; n++) {
    int prec = fp_cache_get(db, val, n, 10);
    if (prec != lastprec) {
      if (-1 != lastprec) {
        if (0 != lastn) {
          printf("range %d : %d is to precision %d\n", lastn, n - 1, lastprec);
        } else {
          printf("range %d : %d is missing\n", lastn, n - 1);
        }
      }
      lastprec = prec;
      lastn = n;
    }
  }
  if ((-1 != lastprec) && (0 != lastn)) {
    printf("range %d : %d is to precision %d\n", lastn, n - 1, lastprec);
  } else {
    printf("range %d : %d is missing\n", lastn, n - 1);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    11c6 <main+0x46>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe61(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x20(%rbp)
movl   $0x64,-0x24(%rbp)
cvtsi2sdl -0x24(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe05(%rip),%xmm0
call   1080 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x58(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  0xddf(%rip),%xmm0
call   1080 <log@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdb9(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
call   1070 <mpf_set_default_prec@plt>
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%edx
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x38(%rbp),%edi
call   1040 <mpf_init@plt>
movl   $0xffffffff,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jg     132e <main+0x1ae>
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    $0xa,%ecx
call   1060 <fp_cache_get@plt>
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x40(%rbp),%eax
je     131b <main+0x19b>
mov    $0xffffffff,%eax
cmp    -0x40(%rbp),%eax
je     130f <main+0x18f>
xor    %eax,%eax
cmp    -0x44(%rbp),%eax
je     12f3 <main+0x173>
mov    -0x44(%rbp),%esi
mov    -0x3c(%rbp),%edx
sub    $0x1,%edx
mov    -0x40(%rbp),%ecx
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    130a <main+0x18a>
mov    -0x44(%rbp),%esi
mov    -0x3c(%rbp),%edx
sub    $0x1,%edx
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    130f <main+0x18f>
mov    -0x48(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    1320 <main+0x1a0>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    128c <main+0x10c>
mov    $0xffffffff,%eax
cmp    -0x40(%rbp),%eax
je     1366 <main+0x1e6>
xor    %eax,%eax
cmp    -0x44(%rbp),%eax
je     1366 <main+0x1e6>
mov    -0x44(%rbp),%esi
mov    -0x3c(%rbp),%edx
sub    $0x1,%edx
mov    -0x40(%rbp),%ecx
lea    0xcf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    137d <main+0x1fd>
mov    -0x44(%rbp),%esi
mov    -0x3c(%rbp),%edx
sub    $0x1,%edx
lea    0xcfb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jle    12a0 <main+0x130>
mov    0x8(%rbx),%r14
mov    0x10(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%ebp
mov    0x18(%rbx),%rdi
call   1080 <atoi@plt>
mov    %eax,%r12d
mov    $0x1b0,%edi
call   1070 <mpf_set_default_prec@plt>
lea    0xe66(%rip),%rdi
xor    %r13d,%r13d
mov    %r14,0x10(%rsp)
mov    %r14,%rsi
mov    %r12d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
call   1040 <mpf_init@plt>
mov    %ebp,%edx
cmp    %r12d,%ebp
jg     127b <main+0x10b>
lea    0x1(%r12),%eax
mov    %eax,0xc(%rsp)
add    $0xffffffff,%ebp
mov    $0xffffffff,%r15d
xor    %r13d,%r13d
jmp    1210 <main+0xa0>
lea    0xe60(%rip),%rdi
xor    %esi,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%r15d
mov    %ebp,%r13d
cmp    %ebp,%r12d
je     1253 <main+0xe3>
mov    %ebp,%r14d
lea    0x1(%r14),%ebp
mov    0x10(%rsp),%rdi
mov    %ebp,%edx
mov    $0xa,%ecx
call   1060 <fp_cache_get@plt>
cmp    %r15d,%eax
je     120b <main+0x9b>
mov    %eax,%ebx
cmp    $0xffffffff,%r15d
je     1205 <main+0x95>
test   %r13d,%r13d
je     11f2 <main+0x82>
lea    0xdf6(%rip),%rdi
mov    %r13d,%esi
mov    %r14d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1205 <main+0x95>
cmp    $0xffffffff,%r15d
je     1277 <main+0x107>
test   %r13d,%r13d
je     1277 <main+0x107>
lea    0xdd2(%rip),%rdi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    128f <main+0x11f>
mov    0xc(%rsp),%edx
add    $0xffffffff,%edx
lea    0xdd4(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xd4d(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Usage: %s <db> <from> <to>\0A\00"
@.str.1 = [27 x i8] c"printout of %s up to n=%d\0A\00"
@.str.2 = [34 x i8] c"range %d : %d is to precision %d\0A\00"
@.str.3 = [26 x i8] c"range %d : %d is missing\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 4
br i1 %18, label %19, label %26
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
store i8* %29, i8** %6
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %7
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 3
%36 = load i8*, i8** %35
%37 = call i32 @atoi(i8* %36)
store i32 %37, i32* %8
store i32 100, i32* %9
%38 = load i32, i32* %9
%39 = sitofp i32 %38 to double
%40 = call double @log(double 1.000000e+01)
%41 = fmul double %39, %40
%42 = call double @log(double 2.000000e+00)
%43 = fdiv double %41, %42
store double %43, double* %10
%44 = load double, double* %10
%45 = fadd double %44, 1.000000e+02
%46 = fptosi double %45 to i32
store i32 %46, i32* %11
%47 = load i32, i32* %11
%48 = call i32 @mpf_set_default_prec(i32 %47)
%49 = load i8*, i8** %6
%50 = load i32, i32* %8
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %49, i32 %50)
%52 = load i32, i32* %12
%53 = call i32 @mpf_init(i32 %52)
store i32 -1, i32* %14
store i32 0, i32* %15
%54 = load i32, i32* %7
store i32 %54, i32* %13
br label %55
55: ; preds = %89, %26
%56 = load i32, i32* %13
%57 = load i32, i32* %8
%58 = icmp sle i32 %56, %57
br i1 %58, label %59, label %92
59: ; preds = %55
%60 = load i8*, i8** %6
%61 = load i32, i32* %12
%62 = load i32, i32* %13
%63 = call i32 @fp_cache_get(i8* %60, i32 %61, i32 %62, i32 10)
store i32 %63, i32* %16
%64 = load i32, i32* %16
%65 = load i32, i32* %14
%66 = icmp ne i32 %64, %65
br i1 %66, label %67, label %88
67: ; preds = %59
%68 = load i32, i32* %14
%69 = icmp ne i32 -1, %68
br i1 %69, label %70, label %85
70: ; preds = %67
%71 = load i32, i32* %15
%72 = icmp ne i32 0, %71
br i1 %72, label %73, label %79
73: ; preds = %70
%74 = load i32, i32* %15
%75 = load i32, i32* %13
%76 = sub nsw i32 %75, 1
%77 = load i32, i32* %14
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %74, i32 %76, i32 %77)
br label %84
79: ; preds = %70
%80 = load i32, i32* %15
%81 = load i32, i32* %13
%82 = sub nsw i32 %81, 1
%83 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %80, i32 %82)
br label %84
84: ; preds = %79, %73
br label %85
85: ; preds = %84, %67
%86 = load i32, i32* %16
store i32 %86, i32* %14
%87 = load i32, i32* %13
store i32 %87, i32* %15
br label %88
88: ; preds = %85, %59
br label %89
89: ; preds = %88
%90 = load i32, i32* %13
%91 = add nsw i32 %90, 1
store i32 %91, i32* %13
br label %55
92: ; preds = %55
%93 = load i32, i32* %14
%94 = icmp ne i32 -1, %93
br i1 %94, label %95, label %104
95: ; preds = %92
%96 = load i32, i32* %15
%97 = icmp ne i32 0, %96
br i1 %97, label %98, label %104
98: ; preds = %95
%99 = load i32, i32* %15
%100 = load i32, i32* %13
%101 = sub nsw i32 %100, 1
%102 = load i32, i32* %14
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %99, i32 %101, i32 %102)
br label %109
104: ; preds = %95, %92
%105 = load i32, i32* %15
%106 = load i32, i32* %13
%107 = sub nsw i32 %106, 1
%108 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %105, i32 %107)
br label %109
109: ; preds = %104, %98
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Usage: %s <db> <from> <to>\0A\00"
@.str.1 = [27 x i8] c"printout of %s up to n=%d\0A\00"
@.str.2 = [34 x i8] c"range %d : %d is to precision %d\0A\00"
@.str.3 = [26 x i8] c"range %d : %d is missing\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 4
br i1 %3, label %4, label %9
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = tail call i32 @mpf_set_default_prec(i32 432)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %17)
%20 = tail call i32 @mpf_init(i32 undef)
%21 = icmp sgt i32 %14, %17
br i1 %21, label %50, label %22
22: ; preds = %9
%23 = add i32 %17, 1
br label %24
24: ; preds = %22, %39
%25 = phi i32 [ %41, %39 ], [ 0, %22 ]
%26 = phi i32 [ %40, %39 ], [ -1, %22 ]
%27 = phi i32 [ %42, %39 ], [ %14, %22 ]
%28 = tail call i32 @fp_cache_get(i8* %11, i32 undef, i32 %27, i32 10)
%29 = icmp eq i32 %28, %26
br i1 %29, label %39, label %30
30: ; preds = %24
%31 = icmp eq i32 %26, -1
br i1 %31, label %39, label %32
32: ; preds = %30
%33 = icmp eq i32 %25, 0
%34 = add nsw i32 %27, -1
br i1 %33, label %37, label %35
35: ; preds = %32
%36 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %34, i32 %26)
br label %39
37: ; preds = %32
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 0, i32 %34)
br label %39
39: ; preds = %30, %37, %35, %24
%40 = phi i32 [ %26, %24 ], [ %28, %35 ], [ %28, %37 ], [ %28, %30 ]
%41 = phi i32 [ %25, %24 ], [ %27, %35 ], [ %27, %37 ], [ %27, %30 ]
%42 = add i32 %27, 1
%43 = icmp eq i32 %27, %17
br i1 %43, label %44, label %24
44: ; preds = %39
%45 = icmp ne i32 %40, -1
%46 = icmp ne i32 %41, 0
%47 = select i1 %45, i1 %46, i1 false
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %41, i32 %17, i32 %40)
br label %55
50: ; preds = %9, %44
%51 = phi i32 [ %41, %44 ], [ 0, %9 ]
%52 = phi i32 [ %23, %44 ], [ %14, %9 ]
%53 = add nsw i32 %52, -1
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %51, i32 %53)
br label %55
55: ; preds = %50, %48
ret i32 0
}