#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 atof(char *);
int /*<<< orphan*/ exit(int);
double floor(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int);
int printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int sprfrac2(char *li, int n, int d) {
  int i, t, dp;
  double m, r, x0, x1;
  char l[100], *l0, *l1;
  if (li)
    l0 = li;
  else
    l0 = l;
  x0 = n / (d + .49);
  x1 = n / (d - .49);
  l1 = l0;
  for (dp = 0, m = 1; dp < 15; dp++) {
    r = floor(x1 * m);
    if (r > x0 * m) {
      t = (int)(r / m);
      l1 += sprintf(l1, "%d", t);
      r -= t * m;
      if (dp) {
        l1 += sprintf(l1, ".");
        for (i = 0; i < dp; i++) {
          m /= 10;
          t = (int)(r / m);
          l1 += sprintf(l1, "%d", t);
          r -= t * m;
        }
      }
      if ((int)(n / atof(l0) + .5) != d) {
        fprintf(stderr, "Error 2 in prfrac2 n=%d d=%d\n", n, d);
        exit(1);
      }
      if (li)
        return l1 - l0;
      else
        return printf("%s", l);
    }
    m *= 10;
  }
  fprintf(stderr, "Error 1 in prfrac2 n=%d d=%d\n", n, d);
  exit(1);
}


x86 assembly (clang, -O0):
<sprfrac2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1190 <sprfrac2+0x30>
mov    -0x10(%rbp),%rax
mov    %rax,-0xb8(%rbp)
jmp    119e <sprfrac2+0x3e>
lea    -0xb0(%rbp),%rax
mov    %rax,-0xb8(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xe58(%rip),%xmm2
addsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xe39(%rip),%xmm2
subsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0xb8(%rbp),%rax
mov    %rax,-0xc0(%rbp)
movl   $0x0,-0x24(%rbp)
movsd  0xe07(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpl   $0xf,-0x24(%rbp)
jge    144b <sprfrac2+0x2eb>
movsd  -0x48(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
call   1080 <floor@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    142b <sprfrac2+0x2cb>
movsd  -0x38(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc0(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    %eax,%ecx
mov    -0xc0(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0xc0(%rbp)
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     138a <sprfrac2+0x22a>
mov    -0xc0(%rbp),%rdi
lea    0xd64(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    %eax,%ecx
mov    -0xc0(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0xc0(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1385 <sprfrac2+0x225>
movsd  -0x30(%rbp),%xmm0
movsd  0xd14(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x38(%rbp),%xmm0
divsd  -0x30(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc0(%rbp),%rdi
mov    -0x20(%rbp),%edx
lea    0xcf9(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
mov    %eax,%ecx
mov    -0xc0(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0xc0(%rbp)
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    12e3 <sprfrac2+0x183>
jmp    138a <sprfrac2+0x22a>
mov    -0x14(%rbp),%eax
mov    %eax,-0xc4(%rbp)
mov    -0xb8(%rbp),%rdi
call   1030 <atof@plt>
mov    %eax,%ecx
mov    -0xc4(%rbp),%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  0xc62(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cmp    -0x18(%rbp),%eax
je     13ec <sprfrac2+0x28c>
mov    0x2c12(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xc48(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
cmpq   $0x0,-0x10(%rbp)
je     1410 <sprfrac2+0x2b0>
mov    -0xc0(%rbp),%rax
mov    -0xb8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x4(%rbp)
jmp    1470 <sprfrac2+0x310>
lea    -0xb0(%rbp),%rsi
lea    0xc25(%rip),%rdi
call   1040 <printf@plt>
mov    %eax,-0x4(%rbp)
jmp    1470 <sprfrac2+0x310>
movsd  0xbdd(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11fe <sprfrac2+0x9e>
mov    0x2b8e(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xbe5(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sprfrac2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%r12
test   %rdi,%rdi
lea    0x30(%rsp),%r13
cmovne %rdi,%r13
mov    %esi,0x18(%rsp)
cvtsi2sd %esi,%xmm0
mov    %edx,0x1c(%rsp)
cvtsi2sd %edx,%xmm2
movsd  0xe68(%rip),%xmm1
addsd  %xmm2,%xmm1
movapd %xmm0,%xmm3
divsd  %xmm1,%xmm3
movsd  %xmm3,0x8(%rsp)
addsd  0xe56(%rip),%xmm2
divsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
call   1080 <floor@plt>
ucomisd 0x8(%rsp),%xmm0
jbe    11e0 <sprfrac2+0x80>
movapd %xmm0,%xmm2
xor    %r14d,%r14d
mov    $0x1,%r15b
movsd  0xe35(%rip),%xmm1
jmp    150c <sprfrac2+0x3ac>
movsd  0x10(%rsp),%xmm0
mulsd  0xe2a(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xe1d(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    121a <sprfrac2+0xba>
mov    $0x1,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xdf8(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xdeb(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    1254 <sprfrac2+0xf4>
mov    $0x2,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xdc6(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xdb9(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    128e <sprfrac2+0x12e>
mov    $0x3,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xd94(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xd87(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    12c8 <sprfrac2+0x168>
mov    $0x4,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xd62(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xd55(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    1302 <sprfrac2+0x1a2>
mov    $0x5,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xd30(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xd23(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    133c <sprfrac2+0x1dc>
mov    $0x6,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xcfe(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xcf1(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    1376 <sprfrac2+0x216>
mov    $0x7,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xccc(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xcbf(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    13b0 <sprfrac2+0x250>
mov    $0x8,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xc9a(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xc8d(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    13ea <sprfrac2+0x28a>
mov    $0x9,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xc68(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xc5b(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    1424 <sprfrac2+0x2c4>
mov    $0xa,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xc36(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xc29(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    145e <sprfrac2+0x2fe>
mov    $0xb,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xc04(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xbf7(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    1495 <sprfrac2+0x335>
mov    $0xc,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xbd5(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xbc8(%rip),%xmm1
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    14cc <sprfrac2+0x36c>
mov    $0xd,%r14d
jmp    1509 <sprfrac2+0x3a9>
movsd  0x10(%rsp),%xmm0
mulsd  0xba6(%rip),%xmm0
call   1080 <floor@plt>
movsd  0xb99(%rip),%xmm2
movsd  0x8(%rsp),%xmm3
mulsd  %xmm2,%xmm3
ucomisd %xmm3,%xmm0
jbe    1648 <sprfrac2+0x4e8>
movapd %xmm2,%xmm1
movapd %xmm0,%xmm2
mov    $0xe,%r14d
xor    %r15d,%r15d
movsd  %xmm2,0x10(%rsp)
movsd  %xmm1,0x8(%rsp)
divsd  %xmm1,%xmm2
cvttsd2si %xmm2,%ebx
lea    0xb69(%rip),%rsi
mov    %r13,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1060 <sprintf@plt>
movslq %eax,%rbp
add    %r13,%rbp
test   %r15b,%r15b
jne    15c8 <sprfrac2+0x468>
movw   $0x2e,0x0(%rbp)
add    $0x1,%rbp
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0x10(%rsp),%xmm2
subsd  %xmm0,%xmm2
lea    0xb22(%rip),%rbx
xchg   %ax,%ax
movsd  %xmm2,0x10(%rsp)
divsd  0xa9a(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
divsd  %xmm1,%xmm2
movapd %xmm2,0x20(%rsp)
cvttsd2si %xmm2,%edx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <sprintf@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x8(%rsp),%xmm1
cltq
cvttpd2dq 0x20(%rsp),%xmm0
cvtdq2pd %xmm0,%xmm0
add    %rax,%rbp
mulsd  %xmm1,%xmm0
subsd  %xmm0,%xmm2
add    $0xffffffff,%r14d
jne    1570 <sprfrac2+0x410>
mov    %r13,%rdi
call   1030 <atof@plt>
mov    %eax,%ecx
mov    0x18(%rsp),%ebx
mov    %ebx,%eax
cltd
idiv   %ecx
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xa9e(%rip),%xmm0
cvttsd2si %xmm0,%eax
mov    0x1c(%rsp),%ecx
cmp    %ecx,%eax
jne    1627 <sprfrac2+0x4c7>
test   %r12,%r12
je     1600 <sprfrac2+0x4a0>
sub    %r13d,%ebp
jmp    1613 <sprfrac2+0x4b3>
lea    0xaaa(%rip),%rdi
lea    0x30(%rsp),%rsi
call   1040 <printf@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x29b2(%rip),%rax
mov    (%rax),%edi
lea    0xa5c(%rip),%rsi
mov    %ebx,%edx
call   1050 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2991(%rip),%rax
mov    (%rax),%edi
lea    0xa5c(%rip),%rsi
mov    0x18(%rsp),%edx
mov    0x1c(%rsp),%ecx
jmp    1639 <sprfrac2+0x4d9>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c".\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Error 2 in prfrac2 n=%d d=%d\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [30 x i8] c"Error 1 in prfrac2 n=%d d=%d\0A\00"
define i32 @sprfrac2(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca [100 x i8]
%16 = alloca i8*
%17 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%18 = load i8*, i8** %5
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %22
20: ; preds = %3
%21 = load i8*, i8** %5
store i8* %21, i8** %16
br label %24
22: ; preds = %3
%23 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
store i8* %23, i8** %16
br label %24
24: ; preds = %22, %20
%25 = load i32, i32* %6
%26 = sitofp i32 %25 to double
%27 = load i32, i32* %7
%28 = sitofp i32 %27 to double
%29 = fadd double %28, 4.900000e-01
%30 = fdiv double %26, %29
store double %30, double* %13
%31 = load i32, i32* %6
%32 = sitofp i32 %31 to double
%33 = load i32, i32* %7
%34 = sitofp i32 %33 to double
%35 = fsub double %34, 4.900000e-01
%36 = fdiv double %32, %35
store double %36, double* %14
%37 = load i8*, i8** %16
store i8* %37, i8** %17
store i32 0, i32* %10
store double 1.000000e+00, double* %11
br label %38
38: ; preds = %135, %24
%39 = load i32, i32* %10
%40 = icmp slt i32 %39, 15
br i1 %40, label %41, label %138
41: ; preds = %38
%42 = load double, double* %14
%43 = load double, double* %11
%44 = fmul double %42, %43
%45 = call double @llvm.floor.f64(double %44)
store double %45, double* %12
%46 = load double, double* %12
%47 = load double, double* %13
%48 = load double, double* %11
%49 = fmul double %47, %48
%50 = fcmp ogt double %46, %49
br i1 %50, label %51, label %132
51: ; preds = %41
%52 = load double, double* %12
%53 = load double, double* %11
%54 = fdiv double %52, %53
%55 = fptosi double %54 to i32
store i32 %55, i32* %9
%56 = load i8*, i8** %17
%57 = load i32, i32* %9
%58 = call i32 (i8*, i8*, ...) @sprintf(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %57)
%59 = load i8*, i8** %17
%60 = sext i32 %58 to i64
%61 = getelementptr inbounds i8, i8* %59, i64 %60
store i8* %61, i8** %17
%62 = load i32, i32* %9
%63 = sitofp i32 %62 to double
%64 = load double, double* %11
%65 = load double, double* %12
%66 = fneg double %63
%67 = call double @llvm.fmuladd.f64(double %66, double %64, double %65)
store double %67, double* %12
%68 = load i32, i32* %10
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %103
70: ; preds = %51
%71 = load i8*, i8** %17
%72 = call i32 (i8*, i8*, ...) @sprintf(i8* %71, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%73 = load i8*, i8** %17
%74 = sext i32 %72 to i64
%75 = getelementptr inbounds i8, i8* %73, i64 %74
store i8* %75, i8** %17
store i32 0, i32* %8
br label %76
76: ; preds = %99, %70
%77 = load i32, i32* %8
%78 = load i32, i32* %10
%79 = icmp slt i32 %77, %78
br i1 %79, label %80, label %102
80: ; preds = %76
%81 = load double, double* %11
%82 = fdiv double %81, 1.000000e+01
store double %82, double* %11
%83 = load double, double* %12
%84 = load double, double* %11
%85 = fdiv double %83, %84
%86 = fptosi double %85 to i32
store i32 %86, i32* %9
%87 = load i8*, i8** %17
%88 = load i32, i32* %9
%89 = call i32 (i8*, i8*, ...) @sprintf(i8* %87, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %88)
%90 = load i8*, i8** %17
%91 = sext i32 %89 to i64
%92 = getelementptr inbounds i8, i8* %90, i64 %91
store i8* %92, i8** %17
%93 = load i32, i32* %9
%94 = sitofp i32 %93 to double
%95 = load double, double* %11
%96 = load double, double* %12
%97 = fneg double %94
%98 = call double @llvm.fmuladd.f64(double %97, double %95, double %96)
store double %98, double* %12
br label %99
99: ; preds = %80
%100 = load i32, i32* %8
%101 = add nsw i32 %100, 1
store i32 %101, i32* %8
br label %76
102: ; preds = %76
br label %103
103: ; preds = %102, %51
%104 = load i32, i32* %6
%105 = load i8*, i8** %16
%106 = call i32 @atof(i8* %105)
%107 = sdiv i32 %104, %106
%108 = sitofp i32 %107 to double
%109 = fadd double %108, 5.000000e-01
%110 = fptosi double %109 to i32
%111 = load i32, i32* %7
%112 = icmp ne i32 %110, %111
br i1 %112, label %113, label %119
113: ; preds = %103
%114 = load i32, i32* @stderr
%115 = load i32, i32* %6
%116 = load i32, i32* %7
%117 = call i32 @fprintf(i32 %114, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %115, i32 %116)
%118 = call i32 @exit(i32 1)
unreachable
119: ; preds = %103
%120 = load i8*, i8** %5
%121 = icmp ne i8* %120, null
br i1 %121, label %122, label %129
122: ; preds = %119
%123 = load i8*, i8** %17
%124 = load i8*, i8** %16
%125 = ptrtoint i8* %123 to i64
%126 = ptrtoint i8* %124 to i64
%127 = sub i64 %125, %126
%128 = trunc i64 %127 to i32
store i32 %128, i32* %4
br label %144
129: ; preds = %119
%130 = getelementptr inbounds [100 x i8], [100 x i8]* %15, i64 0, i64 0
%131 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %130)
store i32 %131, i32* %4
br label %144
132: ; preds = %41
%133 = load double, double* %11
%134 = fmul double %133, 1.000000e+01
store double %134, double* %11
br label %135
135: ; preds = %132
%136 = load i32, i32* %10
%137 = add nsw i32 %136, 1
store i32 %137, i32* %10
br label %38
138: ; preds = %38
%139 = load i32, i32* @stderr
%140 = load i32, i32* %6
%141 = load i32, i32* %7
%142 = call i32 @fprintf(i32 %139, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %140, i32 %141)
%143 = call i32 @exit(i32 1)
unreachable
144: ; preds = %129, %122
%145 = load i32, i32* %4
ret i32 %145
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@stderr = global i32 0
@.str.2 = [30 x i8] c"Error 2 in prfrac2 n=%d d=%d\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [30 x i8] c"Error 1 in prfrac2 n=%d d=%d\0A\00"
define i32 @sprfrac2(i8* %0, i32 %1, i32 %2) {
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = icmp eq i8* %0, null
%7 = select i1 %6, i8* %5, i8* %0
%8 = sitofp i32 %1 to double
%9 = sitofp i32 %2 to double
%10 = fadd double %9, 4.900000e-01
%11 = fdiv double %8, %10
%12 = fadd double %9, -4.900000e-01
%13 = fdiv double %8, %12
%14 = tail call double @llvm.floor.f64(double %13)
%15 = fcmp ogt double %14, %11
br i1 %15, label %16, label %68
16: ; preds = %133, %128, %123, %118, %113, %108, %103, %98, %93, %88, %83, %78, %73, %68, %3
%17 = phi double [ 1.000000e+00, %3 ], [ 1.000000e+01, %68 ], [ 1.000000e+02, %73 ], [ 1.000000e+03, %78 ], [ 1.000000e+04, %83 ], [ 1.000000e+05, %88 ], [ 1.000000e+06, %93 ], [ 1.000000e+07, %98 ], [ 1.000000e+08, %103 ], [ 1.000000e+09, %108 ], [ 1.000000e+10, %113 ], [ 1.000000e+11, %118 ], [ 1.000000e+12, %123 ], [ 1.000000e+13, %128 ], [ 1.000000e+14, %133 ]
%18 = phi i1 [ true, %3 ], [ false, %68 ], [ false, %73 ], [ false, %78 ], [ false, %83 ], [ false, %88 ], [ false, %93 ], [ false, %98 ], [ false, %103 ], [ false, %108 ], [ false, %113 ], [ false, %118 ], [ false, %123 ], [ false, %128 ], [ false, %133 ]
%19 = phi i32 [ 0, %3 ], [ 1, %68 ], [ 2, %73 ], [ 3, %78 ], [ 4, %83 ], [ 5, %88 ], [ 6, %93 ], [ 7, %98 ], [ 8, %103 ], [ 9, %108 ], [ 10, %113 ], [ 11, %118 ], [ 12, %123 ], [ 13, %128 ], [ 14, %133 ]
%20 = phi double [ %14, %3 ], [ %70, %68 ], [ %75, %73 ], [ %80, %78 ], [ %85, %83 ], [ %90, %88 ], [ %95, %93 ], [ %100, %98 ], [ %105, %103 ], [ %110, %108 ], [ %115, %113 ], [ %120, %118 ], [ %125, %123 ], [ %130, %128 ], [ %135, %133 ]
%21 = fdiv double %20, %17
%22 = fptosi double %21 to i32
%23 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %7, i64 %24
br i1 %18, label %48, label %26
26: ; preds = %16
%27 = bitcast i8* %25 to i16*
store i16 46, i16* %27
%28 = getelementptr inbounds i8, i8* %25, i64 1
%29 = sitofp i32 %22 to double
%30 = fneg double %29
%31 = tail call double @llvm.fmuladd.f64(double %30, double %17, double %20)
br label %32
32: ; preds = %26, %32
%33 = phi i8* [ %42, %32 ], [ %28, %26 ]
%34 = phi i32 [ %46, %32 ], [ 0, %26 ]
%35 = phi double [ %45, %32 ], [ %31, %26 ]
%36 = phi double [ %37, %32 ], [ %17, %26 ]
%37 = fdiv double %36, 1.000000e+01
%38 = fdiv double %35, %37
%39 = fptosi double %38 to i32
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %33, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %33, i64 %41
%43 = sitofp i32 %39 to double
%44 = fneg double %43
%45 = tail call double @llvm.fmuladd.f64(double %44, double %37, double %35)
%46 = add nuw nsw i32 %34, 1
%47 = icmp eq i32 %46, %19
br i1 %47, label %48, label %32
48: ; preds = %32, %16
%49 = phi i8* [ %25, %16 ], [ %42, %32 ]
%50 = call i32 @atof(i8* %7)
%51 = sdiv i32 %1, %50
%52 = sitofp i32 %51 to double
%53 = fadd double %52, 5.000000e-01
%54 = fptosi double %53 to i32
%55 = icmp eq i32 %54, %2
br i1 %55, label %60, label %56
56: ; preds = %48
%57 = load i32, i32* @stderr
%58 = tail call i32 @fprintf(i32 %57, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %1, i32 %2)
%59 = tail call i32 @exit(i32 1)
unreachable
60: ; preds = %48
br i1 %6, label %66, label %61
61: ; preds = %60
%62 = ptrtoint i8* %49 to i64
%63 = ptrtoint i8* %7 to i64
%64 = sub i64 %62, %63
%65 = trunc i64 %64 to i32
br label %142
66: ; preds = %60
%67 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %5)
br label %142
68: ; preds = %3
%69 = fmul double %13, 1.000000e+01
%70 = tail call double @llvm.floor.f64(double %69)
%71 = fmul double %11, 1.000000e+01
%72 = fcmp ogt double %70, %71
br i1 %72, label %16, label %73
73: ; preds = %68
%74 = fmul double %13, 1.000000e+02
%75 = tail call double @llvm.floor.f64(double %74)
%76 = fmul double %11, 1.000000e+02
%77 = fcmp ogt double %75, %76
br i1 %77, label %16, label %78
78: ; preds = %73
%79 = fmul double %13, 1.000000e+03
%80 = tail call double @llvm.floor.f64(double %79)
%81 = fmul double %11, 1.000000e+03
%82 = fcmp ogt double %80, %81
br i1 %82, label %16, label %83
83: ; preds = %78
%84 = fmul double %13, 1.000000e+04
%85 = tail call double @llvm.floor.f64(double %84)
%86 = fmul double %11, 1.000000e+04
%87 = fcmp ogt double %85, %86
br i1 %87, label %16, label %88
88: ; preds = %83
%89 = fmul double %13, 1.000000e+05
%90 = tail call double @llvm.floor.f64(double %89)
%91 = fmul double %11, 1.000000e+05
%92 = fcmp ogt double %90, %91
br i1 %92, label %16, label %93
93: ; preds = %88
%94 = fmul double %13, 1.000000e+06
%95 = tail call double @llvm.floor.f64(double %94)
%96 = fmul double %11, 1.000000e+06
%97 = fcmp ogt double %95, %96
br i1 %97, label %16, label %98
98: ; preds = %93
%99 = fmul double %13, 1.000000e+07
%100 = tail call double @llvm.floor.f64(double %99)
%101 = fmul double %11, 1.000000e+07
%102 = fcmp ogt double %100, %101
br i1 %102, label %16, label %103
103: ; preds = %98
%104 = fmul double %13, 1.000000e+08
%105 = tail call double @llvm.floor.f64(double %104)
%106 = fmul double %11, 1.000000e+08
%107 = fcmp ogt double %105, %106
br i1 %107, label %16, label %108
108: ; preds = %103
%109 = fmul double %13, 1.000000e+09
%110 = tail call double @llvm.floor.f64(double %109)
%111 = fmul double %11, 1.000000e+09
%112 = fcmp ogt double %110, %111
br i1 %112, label %16, label %113
113: ; preds = %108
%114 = fmul double %13, 1.000000e+10
%115 = tail call double @llvm.floor.f64(double %114)
%116 = fmul double %11, 1.000000e+10
%117 = fcmp ogt double %115, %116
br i1 %117, label %16, label %118
118: ; preds = %113
%119 = fmul double %13, 1.000000e+11
%120 = tail call double @llvm.floor.f64(double %119)
%121 = fmul double %11, 1.000000e+11
%122 = fcmp ogt double %120, %121
br i1 %122, label %16, label %123
123: ; preds = %118
%124 = fmul double %13, 1.000000e+12
%125 = tail call double @llvm.floor.f64(double %124)
%126 = fmul double %11, 1.000000e+12
%127 = fcmp ogt double %125, %126
br i1 %127, label %16, label %128
128: ; preds = %123
%129 = fmul double %13, 1.000000e+13
%130 = tail call double @llvm.floor.f64(double %129)
%131 = fmul double %11, 1.000000e+13
%132 = fcmp ogt double %130, %131
br i1 %132, label %16, label %133
133: ; preds = %128
%134 = fmul double %13, 1.000000e+14
%135 = tail call double @llvm.floor.f64(double %134)
%136 = fmul double %11, 1.000000e+14
%137 = fcmp ogt double %135, %136
br i1 %137, label %16, label %138
138: ; preds = %133
%139 = load i32, i32* @stderr
%140 = tail call i32 @fprintf(i32 %139, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0), i32 %1, i32 %2)
%141 = tail call i32 @exit(i32 1)
unreachable
142: ; preds = %66, %61
%143 = phi i32 [ %65, %61 ], [ %67, %66 ]
ret i32 %143
}