#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 double uint32_t;
typedef double uint16_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AdjustScaling(double, double, double, double, double,
                                 double *, double *);
int /*<<< orphan*/ GetPngSize(char *, double *, double *, double *, double *,
                              int *);
int /*<<< orphan*/ PutHexFile(int /*<<< orphan*/ *);
int /*<<< orphan*/ diagnostics(int, char *, ...);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintRTF(char *, ...);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
void PutPngFile(char *png, double height_goal, double width_goal, double scale,
                double baseline) {
  FILE *fp;
  double xres, yres;
  char *s;
  uint32_t w_pixels, h_pixels, b;
  uint32_t w_twips, h_twips;
  uint16_t sx, sy;
  int bad_res;
  diagnostics(1, "Encoding  '%s'", png);
  GetPngSize(png, &w_pixels, &h_pixels, &xres, &yres, &bad_res);
  if (w_pixels == 0 || h_pixels == 0)
    return;
  fp = fopen(png, "rb");
  if (fp == NULL)
    return;
  w_twips = (int)(w_pixels / xres * 2834.65 * 20.0 + 0.5);
  h_twips = (int)(h_pixels / yres * 2834.65 * 20.0 + 0.5);
  b = (uint32_t)baseline * 2;
  AdjustScaling(h_twips, w_twips, height_goal, width_goal, scale, &sx, &sy);
  if (bad_res) {
    sx = (uint16_t)(sx * 2834.65 / xres);
    sy = (uint16_t)(sy * 2834.65 / yres);
  }
  diagnostics(4, "picw       = %8lu pixels,     pich        = %8lu pixels",
              w_pixels, h_pixels);
  diagnostics(4, "picwgoal   = %8lu twips,      pichgoal    = %8lu twips",
              w_twips, h_twips);
  diagnostics(4, "xres       = %8.2f pix/meter, yres        = %8.2f pix/meter",
              xres, yres);
  diagnostics(4, "xres       = %8.2f pix/inch,   yres        = %8.2f pix/inch",
              xres * 72.0 / 2834.65, yres * 72.0 / 2834.65);
  diagnostics(4, "scale      = %8.3f", scale);
  diagnostics(4, "width_goal = %8d twips,      height_goal = %8d twips",
              (int)width_goal, (int)height_goal);
  diagnostics(4, "baseline   = %8.3g twips", baseline);
  diagnostics(4, "sx         = %8lu percent,    sy          = %8lu percent", sx,
              sy);
  fprintRTF("\n{");
  if (b)
    fprintRTF("\\dn%lu", b + 1);
  fprintRTF("\\pict");
  if (sx != 100 && sy != 100)
    fprintRTF("\\picscalex%u\\picscaley%u", sx, sy);
  fprintRTF("\\picw%lu\\pich%lu", w_pixels, h_pixels);
  fprintRTF("\\picwgoal%lu\\pichgoal%lu", w_twips, h_twips);
  fprintRTF("\\pngblip\n");
  rewind(fp);
  PutHexFile(fp);
  fprintRTF("}\n");
  fclose(fp);
}


x86 assembly (clang, -O0):
<PutPngFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
movsd  %xmm3,-0x28(%rbp)
mov    -0x8(%rbp),%rdx
mov    $0x1,%edi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1060 <diagnostics@plt>
mov    -0x8(%rbp),%rdi
lea    -0x50(%rbp),%rsi
lea    -0x58(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x40(%rbp),%r8
lea    -0x84(%rbp),%r9
call   1070 <GetPngSize@plt>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11f7 <PutPngFile+0x77>
jp     11f7 <PutPngFile+0x77>
jmp    120f <PutPngFile+0x8f>
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1214 <PutPngFile+0x94>
jp     1214 <PutPngFile+0x94>
jmp    153e <PutPngFile+0x3be>
mov    -0x8(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1238 <PutPngFile+0xb8>
jmp    153e <PutPngFile+0x3be>
movsd  -0x50(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  0xdce(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdb2(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xdae(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x58(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  0xd93(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd77(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd73(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xd4a(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x70(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
lea    -0x78(%rbp),%rdi
lea    -0x80(%rbp),%rsi
call   1080 <AdjustScaling@plt>
cmpl   $0x0,-0x84(%rbp)
je     1321 <PutPngFile+0x1a1>
movsd  0xd1d(%rip),%xmm0
mulsd  -0x78(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xd06(%rip),%xmm0
mulsd  -0x80(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
mov    $0x4,%edi
lea    0xd13(%rip),%rsi
mov    $0x2,%al
call   1060 <diagnostics@plt>
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
mov    $0x4,%edi
lea    0xd2e(%rip),%rsi
mov    $0x2,%al
call   1060 <diagnostics@plt>
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
mov    $0x4,%edi
lea    0xd48(%rip),%rsi
mov    $0x2,%al
call   1060 <diagnostics@plt>
movsd  0xca0(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xc8b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xc87(%rip),%xmm1
mulsd  -0x40(%rbp),%xmm1
movsd  0xc72(%rip),%xmm2
divsd  %xmm2,%xmm1
mov    $0x4,%edi
lea    0xd3f(%rip),%rsi
mov    $0x2,%al
call   1060 <diagnostics@plt>
movsd  -0x20(%rbp),%xmm0
mov    $0x4,%edi
lea    0xd63(%rip),%rsi
mov    $0x1,%al
call   1060 <diagnostics@plt>
cvttsd2si -0x18(%rbp),%edx
cvttsd2si -0x10(%rbp),%ecx
mov    $0x4,%edi
lea    0xd59(%rip),%rsi
mov    $0x0,%al
call   1060 <diagnostics@plt>
movsd  -0x28(%rbp),%xmm0
mov    $0x4,%edi
lea    0xd76(%rip),%rsi
mov    $0x1,%al
call   1060 <diagnostics@plt>
movsd  -0x78(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
mov    $0x4,%edi
lea    0xd72(%rip),%rsi
mov    $0x2,%al
call   1060 <diagnostics@plt>
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   10a0 <fprintRTF@plt>
movsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1452 <PutPngFile+0x2d2>
jp     1452 <PutPngFile+0x2d2>
jmp    146d <PutPngFile+0x2ed>
movsd  0xbce(%rip),%xmm0
addsd  -0x60(%rbp),%xmm0
lea    0xd68(%rip),%rdi
mov    $0x1,%al
call   10a0 <fprintRTF@plt>
lea    0xd61(%rip),%rdi
mov    $0x0,%al
call   10a0 <fprintRTF@plt>
movsd  -0x78(%rbp),%xmm0
movsd  0xba8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    149d <PutPngFile+0x31d>
jp     149d <PutPngFile+0x31d>
jmp    14d7 <PutPngFile+0x357>
movsd  -0x80(%rbp),%xmm0
movsd  0xb86(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    14bf <PutPngFile+0x33f>
jp     14bf <PutPngFile+0x33f>
jmp    14d7 <PutPngFile+0x357>
movsd  -0x78(%rbp),%xmm0
movsd  -0x80(%rbp),%xmm1
lea    0xd0b(%rip),%rdi
mov    $0x2,%al
call   10a0 <fprintRTF@plt>
movsd  -0x50(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
lea    0xd0c(%rip),%rdi
mov    $0x2,%al
call   10a0 <fprintRTF@plt>
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
lea    0xd05(%rip),%rdi
mov    $0x2,%al
call   10a0 <fprintRTF@plt>
lea    0xd10(%rip),%rdi
mov    $0x0,%al
call   10a0 <fprintRTF@plt>
mov    -0x30(%rbp),%rdi
call   1050 <rewind@plt>
mov    -0x30(%rbp),%rdi
call   1040 <PutHexFile@plt>
lea    0xcfa(%rip),%rdi
mov    $0x0,%al
call   10a0 <fprintRTF@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PutPngFile>:
push   %rbx
sub    $0x80,%rsp
movsd  %xmm3,0x50(%rsp)
movsd  %xmm2,0x38(%rsp)
movsd  %xmm1,0x40(%rsp)
movsd  %xmm0,0x48(%rsp)
mov    %rdi,%rbx
lea    0xe86(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <diagnostics@plt>
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x28(%rsp),%rcx
lea    0x20(%rsp),%r8
lea    0x34(%rsp),%r9
mov    %rbx,%rdi
call   1070 <GetPngSize@plt>
movsd  0x18(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    11f0 <PutPngFile+0x70>
jnp    14cf <PutPngFile+0x34f>
movsd  0x10(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    1202 <PutPngFile+0x82>
jnp    14cf <PutPngFile+0x34f>
lea    0xe36(%rip),%rsi
mov    %rbx,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     14cf <PutPngFile+0x34f>
mov    %rax,%rbx
movsd  0x18(%rsp),%xmm0
divsd  0x28(%rsp),%xmm0
movsd  0xdcf(%rip),%xmm4
mulsd  %xmm4,%xmm0
movsd  0xdcb(%rip),%xmm3
mulsd  %xmm3,%xmm0
movsd  0xdc7(%rip),%xmm2
addsd  %xmm2,%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm1
movsd  0x10(%rsp),%xmm0
divsd  0x20(%rsp),%xmm0
mulsd  %xmm4,%xmm0
mulsd  %xmm3,%xmm0
addsd  %xmm2,%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
movsd  0x50(%rsp),%xmm2
addsd  %xmm2,%xmm2
movsd  %xmm2,0x58(%rsp)
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
movapd %xmm0,0x60(%rsp)
movapd %xmm1,0x70(%rsp)
movsd  0x48(%rsp),%xmm2
movsd  0x40(%rsp),%xmm3
movsd  0x38(%rsp),%xmm4
call   1080 <AdjustScaling@plt>
cmpl   $0x0,0x34(%rsp)
je     12e9 <PutPngFile+0x169>
movsd  0x8(%rsp),%xmm0
movsd  0xd3b(%rip),%xmm1
mulsd  %xmm1,%xmm0
divsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
mulsd  %xmm1,%xmm0
divsd  0x20(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
lea    0xd46(%rip),%rsi
mov    $0x4,%edi
mov    $0x2,%al
call   1060 <diagnostics@plt>
lea    0xd6b(%rip),%rsi
mov    $0x4,%edi
movaps 0x70(%rsp),%xmm0
movaps 0x60(%rsp),%xmm1
mov    $0x2,%al
call   1060 <diagnostics@plt>
movsd  0x28(%rsp),%xmm0
movsd  0x20(%rsp),%xmm1
lea    0xd79(%rip),%rsi
mov    $0x4,%edi
mov    $0x2,%al
call   1060 <diagnostics@plt>
movsd  0xccc(%rip),%xmm1
movsd  0x28(%rsp),%xmm0
mulsd  %xmm1,%xmm0
movsd  0xca2(%rip),%xmm2
divsd  %xmm2,%xmm0
mulsd  0x20(%rsp),%xmm1
divsd  %xmm2,%xmm1
lea    0xd7a(%rip),%rsi
mov    $0x4,%edi
mov    $0x2,%al
call   1060 <diagnostics@plt>
lea    0xda3(%rip),%rsi
mov    $0x4,%edi
movsd  0x38(%rsp),%xmm0
mov    $0x1,%al
call   1060 <diagnostics@plt>
cvttsd2si 0x40(%rsp),%edx
cvttsd2si 0x48(%rsp),%ecx
lea    0xd91(%rip),%rsi
mov    $0x4,%edi
xor    %eax,%eax
call   1060 <diagnostics@plt>
lea    0xdb3(%rip),%rsi
mov    $0x4,%edi
movsd  0x50(%rsp),%xmm0
mov    $0x1,%al
call   1060 <diagnostics@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
lea    0xda8(%rip),%rsi
mov    $0x4,%edi
mov    $0x2,%al
call   1060 <diagnostics@plt>
lea    0xdce(%rip),%rdi
xor    %eax,%eax
call   10a0 <fprintRTF@plt>
xorpd  %xmm0,%xmm0
movsd  0x58(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jne    140e <PutPngFile+0x28e>
jnp    1428 <PutPngFile+0x2a8>
movapd %xmm1,%xmm0
addsd  0xc06(%rip),%xmm0
lea    0xda5(%rip),%rdi
mov    $0x1,%al
call   10a0 <fprintRTF@plt>
lea    0xd9e(%rip),%rdi
xor    %eax,%eax
call   10a0 <fprintRTF@plt>
movsd  0x8(%rsp),%xmm0
ucomisd 0xbe4(%rip),%xmm0
jne    1448 <PutPngFile+0x2c8>
jnp    1467 <PutPngFile+0x2e7>
movsd  (%rsp),%xmm1
ucomisd 0xbd3(%rip),%xmm1
jne    1459 <PutPngFile+0x2d9>
jnp    1467 <PutPngFile+0x2e7>
lea    0xd73(%rip),%rdi
mov    $0x2,%al
call   10a0 <fprintRTF@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
lea    0xd72(%rip),%rdi
mov    $0x2,%al
call   10a0 <fprintRTF@plt>
lea    0xd75(%rip),%rdi
movapd 0x70(%rsp),%xmm0
movapd 0x60(%rsp),%xmm1
mov    $0x2,%al
call   10a0 <fprintRTF@plt>
lea    0xd74(%rip),%rdi
xor    %eax,%eax
call   10a0 <fprintRTF@plt>
mov    %rbx,%rdi
call   1050 <rewind@plt>
mov    %rbx,%rdi
call   1040 <PutHexFile@plt>
lea    0xd60(%rip),%rdi
xor    %eax,%eax
call   10a0 <fprintRTF@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Encoding '%s'\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [56 x i8] c"picw = %8lu pixels, pich = %8lu pixels\00"
@.str.3 = [55 x i8] c"picwgoal = %8lu twips, pichgoal = %8lu twips\00"
@.str.4 = [60 x i8] c"xres = %8.2f pix/meter, yres = %8.2f pix/meter\00"
@.str.5 = [60 x i8] c"xres = %8.2f pix/inch, yres = %8.2f pix/inch\00"
@.str.6 = [19 x i8] c"scale = %8.3f\00"
@.str.7 = [53 x i8] c"width_goal = %8d twips, height_goal = %8d twips\00"
@.str.8 = [25 x i8] c"baseline = %8.3g twips\00"
@.str.9 = [57 x i8] c"sx = %8lu percent, sy = %8lu percent\00"
@.str.10 = [3 x i8] c"\0A{\00"
@.str.11 = [7 x i8] c"\\dn%lu\00"
@.str.12 = [6 x i8] c"\\pict\00"
@.str.13 = [25 x i8] c"\\picscalex%u\\picscaley%u\00"
@.str.14 = [17 x i8] c"\\picw%lu\\pich%lu\00"
@.str.15 = [25 x i8] c"\\picwgoal%lu\\pichgoal%lu\00"
@.str.16 = [10 x i8] c"\\pngblip\0A\00"
@.str.17 = [3 x i8] c"}\0A\00"
define void @PutPngFile(i8* %0, double %1, double %2, double %3, double %4) {
%6 = alloca i8*
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32*
%12 = alloca double
%13 = alloca double
%14 = alloca i8*
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
%21 = alloca double
%22 = alloca i32
store i8* %0, i8** %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
%23 = load i8*, i8** %6
%24 = call i32 (i32, i8*, ...) @diagnostics(i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %6
%26 = call i32 @GetPngSize(i8* %25, double* %15, double* %16, double* %12, double* %13, i32* %22)
%27 = load double, double* %15
%28 = fcmp oeq double %27, 0.000000e+00
br i1 %28, label %32, label %29
29: ; preds = %5
%30 = load double, double* %16
%31 = fcmp oeq double %30, 0.000000e+00
br i1 %31, label %32, label %33
32: ; preds = %29, %5
br label %135
33: ; preds = %29
%34 = load i8*, i8** %6
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %35, i32** %11
%36 = load i32*, i32** %11
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %39
38: ; preds = %33
br label %135
39: ; preds = %33
%40 = load double, double* %15
%41 = load double, double* %12
%42 = fdiv double %40, %41
%43 = fmul double %42, 2.834650e+03
%44 = call double @llvm.fmuladd.f64(double %43, double 2.000000e+01, double 5.000000e-01)
%45 = fptosi double %44 to i32
%46 = sitofp i32 %45 to double
store double %46, double* %18
%47 = load double, double* %16
%48 = load double, double* %13
%49 = fdiv double %47, %48
%50 = fmul double %49, 2.834650e+03
%51 = call double @llvm.fmuladd.f64(double %50, double 2.000000e+01, double 5.000000e-01)
%52 = fptosi double %51 to i32
%53 = sitofp i32 %52 to double
store double %53, double* %19
%54 = load double, double* %10
%55 = fmul double %54, 2.000000e+00
store double %55, double* %17
%56 = load double, double* %19
%57 = load double, double* %18
%58 = load double, double* %7
%59 = load double, double* %8
%60 = load double, double* %9
%61 = call i32 @AdjustScaling(double %56, double %57, double %58, double %59, double %60, double* %20, double* %21)
%62 = load i32, i32* %22
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %73
64: ; preds = %39
%65 = load double, double* %20
%66 = fmul double %65, 2.834650e+03
%67 = load double, double* %12
%68 = fdiv double %66, %67
store double %68, double* %20
%69 = load double, double* %21
%70 = fmul double %69, 2.834650e+03
%71 = load double, double* %13
%72 = fdiv double %70, %71
store double %72, double* %21
br label %73
73: ; preds = %64, %39
%74 = load double, double* %15
%75 = load double, double* %16
%76 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), double %74, double %75)
%77 = load double, double* %18
%78 = load double, double* %19
%79 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), double %77, double %78)
%80 = load double, double* %12
%81 = load double, double* %13
%82 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), double %80, double %81)
%83 = load double, double* %12
%84 = fmul double %83, 7.200000e+01
%85 = fdiv double %84, 2.834650e+03
%86 = load double, double* %13
%87 = fmul double %86, 7.200000e+01
%88 = fdiv double %87, 2.834650e+03
%89 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0), double %85, double %88)
%90 = load double, double* %9
%91 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %90)
%92 = load double, double* %8
%93 = fptosi double %92 to i32
%94 = load double, double* %7
%95 = fptosi double %94 to i32
%96 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i32 %93, i32 %95)
%97 = load double, double* %10
%98 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), double %97)
%99 = load double, double* %20
%100 = load double, double* %21
%101 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.9, i64 0, i64 0), double %99, double %100)
%102 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%103 = load double, double* %17
%104 = fcmp une double %103, 0.000000e+00
br i1 %104, label %105, label %109
105: ; preds = %73
%106 = load double, double* %17
%107 = fadd double %106, 1.000000e+00
%108 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), double %107)
br label %109
109: ; preds = %105, %73
%110 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%111 = load double, double* %20
%112 = fcmp une double %111, 1.000000e+02
br i1 %112, label %113, label %120
113: ; preds = %109
%114 = load double, double* %21
%115 = fcmp une double %114, 1.000000e+02
br i1 %115, label %116, label %120
116: ; preds = %113
%117 = load double, double* %20
%118 = load double, double* %21
%119 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), double %117, double %118)
br label %120
120: ; preds = %116, %113, %109
%121 = load double, double* %15
%122 = load double, double* %16
%123 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0), double %121, double %122)
%124 = load double, double* %18
%125 = load double, double* %19
%126 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0), double %124, double %125)
%127 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0))
%128 = load i32*, i32** %11
%129 = call i32 @rewind(i32* %128)
%130 = load i32*, i32** %11
%131 = call i32 @PutHexFile(i32* %130)
%132 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%133 = load i32*, i32** %11
%134 = call i32 @fclose(i32* %133)
br label %135
135: ; preds = %120, %38, %32
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Encoding '%s'\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [56 x i8] c"picw = %8lu pixels, pich = %8lu pixels\00"
@.str.3 = [55 x i8] c"picwgoal = %8lu twips, pichgoal = %8lu twips\00"
@.str.4 = [60 x i8] c"xres = %8.2f pix/meter, yres = %8.2f pix/meter\00"
@.str.5 = [60 x i8] c"xres = %8.2f pix/inch, yres = %8.2f pix/inch\00"
@.str.6 = [19 x i8] c"scale = %8.3f\00"
@.str.7 = [53 x i8] c"width_goal = %8d twips, height_goal = %8d twips\00"
@.str.8 = [25 x i8] c"baseline = %8.3g twips\00"
@.str.9 = [57 x i8] c"sx = %8lu percent, sy = %8lu percent\00"
@.str.10 = [3 x i8] c"\0A{\00"
@.str.11 = [7 x i8] c"\\dn%lu\00"
@.str.12 = [6 x i8] c"\\pict\00"
@.str.13 = [25 x i8] c"\\picscalex%u\\picscaley%u\00"
@.str.14 = [17 x i8] c"\\picw%lu\\pich%lu\00"
@.str.15 = [25 x i8] c"\\picwgoal%lu\\pichgoal%lu\00"
@.str.16 = [10 x i8] c"\\pngblip\0A\00"
@.str.17 = [3 x i8] c"}\0A\00"
define void @PutPngFile(i8* %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = bitcast double* %6 to i8*
%14 = bitcast double* %7 to i8*
%15 = bitcast double* %8 to i8*
%16 = bitcast double* %9 to i8*
%17 = bitcast double* %10 to i8*
%18 = bitcast double* %11 to i8*
%19 = bitcast i32* %12 to i8*
%20 = tail call i32 (i32, i8*, ...) @diagnostics(i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* %0)
%21 = call i32 @GetPngSize(i8* %0, double* %8, double* %9, double* %6, double* %7, i32* %12)
%22 = load double, double* %8
%23 = fcmp oeq double %22, 0.000000e+00
%24 = load double, double* %9
%25 = fcmp oeq double %24, 0.000000e+00
%26 = select i1 %23, i1 true, i1 %25
br i1 %26, label %105, label %27
27: ; preds = %5
%28 = call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %105, label %30
30: ; preds = %27
%31 = load double, double* %8
%32 = load double, double* %6
%33 = fdiv double %31, %32
%34 = fmul double %33, 2.834650e+03
%35 = call double @llvm.fmuladd.f64(double %34, double 2.000000e+01, double 5.000000e-01)
%36 = fptosi double %35 to i32
%37 = sitofp i32 %36 to double
%38 = load double, double* %9
%39 = load double, double* %7
%40 = fdiv double %38, %39
%41 = fmul double %40, 2.834650e+03
%42 = call double @llvm.fmuladd.f64(double %41, double 2.000000e+01, double 5.000000e-01)
%43 = fptosi double %42 to i32
%44 = sitofp i32 %43 to double
%45 = fmul double %4, 2.000000e+00
%46 = call i32 @AdjustScaling(double %44, double %37, double %1, double %2, double %3, double* %10, double* %11)
%47 = load i32, i32* %12
%48 = icmp eq i32 %47, 0
br i1 %48, label %58, label %49
49: ; preds = %30
%50 = load double, double* %10
%51 = fmul double %50, 2.834650e+03
%52 = load double, double* %6
%53 = fdiv double %51, %52
store double %53, double* %10
%54 = load double, double* %11
%55 = fmul double %54, 2.834650e+03
%56 = load double, double* %7
%57 = fdiv double %55, %56
store double %57, double* %11
br label %58
58: ; preds = %49, %30
%59 = load double, double* %8
%60 = load double, double* %9
%61 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0), double %59, double %60)
%62 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0), double %37, double %44)
%63 = load double, double* %6
%64 = load double, double* %7
%65 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.4, i64 0, i64 0), double %63, double %64)
%66 = load double, double* %6
%67 = fmul double %66, 7.200000e+01
%68 = fdiv double %67, 2.834650e+03
%69 = load double, double* %7
%70 = fmul double %69, 7.200000e+01
%71 = fdiv double %70, 2.834650e+03
%72 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.5, i64 0, i64 0), double %68, double %71)
%73 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %3)
%74 = fptosi double %2 to i32
%75 = fptosi double %1 to i32
%76 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.7, i64 0, i64 0), i32 %74, i32 %75)
%77 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.8, i64 0, i64 0), double %4)
%78 = load double, double* %10
%79 = load double, double* %11
%80 = call i32 (i32, i8*, ...) @diagnostics(i32 4, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.9, i64 0, i64 0), double %78, double %79)
%81 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%82 = fcmp une double %45, 0.000000e+00
br i1 %82, label %83, label %86
83: ; preds = %58
%84 = fadd double %45, 1.000000e+00
%85 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), double %84)
br label %86
86: ; preds = %83, %58
%87 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
%88 = load double, double* %10
%89 = fcmp une double %88, 1.000000e+02
%90 = load double, double* %11
%91 = fcmp une double %90, 1.000000e+02
%92 = select i1 %89, i1 %91, i1 false
br i1 %92, label %93, label %95
93: ; preds = %86
%94 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.13, i64 0, i64 0), double %88, double %90)
br label %95
95: ; preds = %93, %86
%96 = load double, double* %8
%97 = load double, double* %9
%98 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.14, i64 0, i64 0), double %96, double %97)
%99 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0), double %37, double %44)
%100 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.16, i64 0, i64 0))
%101 = call i32 @rewind(i32* %28)
%102 = call i32 @PutHexFile(i32* %28)
%103 = call i32 (i8*, ...) @fprintRTF(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.17, i64 0, i64 0))
%104 = call i32 @fclose(i32* %28)
br label %105
105: ; preds = %27, %5, %95
ret void
}