#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 INFINITY;
int /*<<< orphan*/ clearPlot();
int /*<<< orphan*/ plotXY(int, int, char);
int /*<<< orphan*/ printPlot();
double rpn_eval(char *, double);
void createPlot(char *funcFile, double minX, double maxX) {
  int nvals = 80;
  double yy[80];
  clearPlot();
  int i;
  double rangeX = maxX - minX;
  double incX = rangeX / 80;
  double scaleX = 80 / rangeX;
  double rangeY;
  double maxY = -INFINITY;
  double minY = INFINITY;
  for (i = 0; i < 80; i++) {
    yy[i] = rpn_eval(funcFile, minX + (i * incX));
    if (yy[i] > maxY) {
      maxY = yy[i];
    }
    if (yy[i] < minY) {
      minY = yy[i];
    }
  }
  rangeY = maxY - minY;
  double scaleY = 40 / rangeY;
  for (i = 0; i < 40; i++) {
    plotXY((-minX) * scaleX, i, '|');
  }
  for (i = 0; i < 80; i++) {
    plotXY(i, (-minY) * scaleY, '_');
  }
  for (i = 0; i < 80; i++) {
    int y = (int)((yy[i] - minY) * scaleY);
    plotXY(i, y, '*');
  }
  printPlot();
}


x86 assembly (clang, -O0):
<createPlot>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2f0,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movl   $0x50,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <clearPlot@plt>
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x2b0(%rbp)
ff
movsd  -0x2b0(%rbp),%xmm0
ff
movsd  0xe77(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x2b8(%rbp)
ff
movsd  0xe63(%rip),%xmm0
divsd  -0x2b0(%rbp),%xmm0
ff
movsd  %xmm0,-0x2c0(%rbp)
ff
mov    0x2e34(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x2d0(%rbp)
ff
mov    0x2e0a(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x2d8(%rbp)
ff
movl   $0x0,-0x2a4(%rbp)
cmpl   $0x50,-0x2a4(%rbp)
jge    12c0 <createPlot+0x180>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm1
cvtsi2sdl -0x2a4(%rbp),%xmm0
ff
movsd  -0x2b8(%rbp),%xmm2
ff
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1060 <rpn_eval@plt>
movslq -0x2a4(%rbp),%rax
movsd  %xmm0,-0x2a0(%rbp,%rax,8)
ff ff
movslq -0x2a4(%rbp),%rax
movsd  -0x2a0(%rbp,%rax,8),%xmm0
ff ff
ucomisd -0x2d0(%rbp),%xmm0
ff
jbe    126d <createPlot+0x12d>
movslq -0x2a4(%rbp),%rax
movsd  -0x2a0(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x2d0(%rbp)
ff
movslq -0x2a4(%rbp),%rax
movsd  -0x2a0(%rbp,%rax,8),%xmm1
ff ff
movsd  -0x2d8(%rbp),%xmm0
ff
ucomisd %xmm1,%xmm0
jbe    12a7 <createPlot+0x167>
movslq -0x2a4(%rbp),%rax
movsd  -0x2a0(%rbp,%rax,8),%xmm0
ff ff
movsd  %xmm0,-0x2d8(%rbp)
ff
jmp    12ac <createPlot+0x16c>
mov    -0x2a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2a4(%rbp)
jmp    11f4 <createPlot+0xb4>
movsd  -0x2d0(%rbp),%xmm0
ff
subsd  -0x2d8(%rbp),%xmm0
ff
movsd  %xmm0,-0x2c8(%rbp)
ff
movsd  0xd28(%rip),%xmm0
divsd  -0x2c8(%rbp),%xmm0
ff
movsd  %xmm0,-0x2e0(%rbp)
ff
movl   $0x0,-0x2a4(%rbp)
cmpl   $0x28,-0x2a4(%rbp)
jge    1353 <createPlot+0x213>
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x2c0(%rbp),%xmm0
ff
cvttsd2si %xmm0,%edi
mov    -0x2a4(%rbp),%esi
mov    $0x7c,%edx
call   1030 <plotXY@plt>
mov    -0x2a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2a4(%rbp)
jmp    12fa <createPlot+0x1ba>
movl   $0x0,-0x2a4(%rbp)
cmpl   $0x50,-0x2a4(%rbp)
jge    13b9 <createPlot+0x279>
mov    -0x2a4(%rbp),%edi
movsd  -0x2d8(%rbp),%xmm0
ff
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x2e0(%rbp),%xmm0
ff
cvttsd2si %xmm0,%esi
mov    $0x5f,%edx
call   1030 <plotXY@plt>
mov    -0x2a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2a4(%rbp)
jmp    135d <createPlot+0x21d>
movl   $0x0,-0x2a4(%rbp)
cmpl   $0x50,-0x2a4(%rbp)
jge    1424 <createPlot+0x2e4>
movslq -0x2a4(%rbp),%rax
movsd  -0x2a0(%rbp,%rax,8),%xmm0
ff ff
subsd  -0x2d8(%rbp),%xmm0
ff
mulsd  -0x2e0(%rbp),%xmm0
ff
cvttsd2si %xmm0,%eax
mov    %eax,-0x2e4(%rbp)
mov    -0x2a4(%rbp),%edi
mov    -0x2e4(%rbp),%esi
mov    $0x2a,%edx
call   1030 <plotXY@plt>
mov    -0x2a4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2a4(%rbp)
jmp    13c3 <createPlot+0x283>
mov    $0x0,%al
call   1040 <printPlot@plt>
add    $0x2f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createPlot>:
push   %rbp
push   %rbx
sub    $0x2c8,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
mov    %rdi,%rbx
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <clearPlot@plt>
movsd  (%rsp),%xmm0
subsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
divsd  0xe88(%rip),%xmm0
movsd  %xmm0,0x38(%rsp)
mov    0x2e63(%rip),%rax
movsd  (%rax),%xmm0
movapd 0xe8f(%rip),%xmm2
xorpd  %xmm0,%xmm2
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm0,0x20(%rsp)
movsd  %xmm2,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0x38(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
call   1060 <rpn_eval@plt>
movsd  %xmm0,0x40(%rsp,%rbp,8)
movapd %xmm0,%xmm2
maxsd  0x10(%rsp),%xmm2
minsd  0x20(%rsp),%xmm0
add    $0x1,%rbp
cmp    $0x50,%rbp
jne    11a0 <createPlot+0x60>
movsd  0xe19(%rip),%xmm1
divsd  (%rsp),%xmm1
movapd %xmm0,0x20(%rsp)
subsd  %xmm0,%xmm2
movapd %xmm2,0x10(%rsp)
mulsd  0x8(%rsp),%xmm1
cvttsd2si %xmm1,%ebx
xor    %ebp,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
mov    $0x7c,%edx
call   1030 <plotXY@plt>
add    $0x1,%ebp
cmp    $0x28,%ebp
jne    1210 <createPlot+0xd0>
movsd  0xde2(%rip),%xmm1
divsd  0x10(%rsp),%xmm1
movapd 0xde4(%rip),%xmm0
xorpd  0x20(%rsp),%xmm0
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x5f,%edx
call   1030 <plotXY@plt>
add    $0x1,%ebp
cmp    $0x50,%ebp
jne    1260 <createPlot+0x120>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsd  0x40(%rsp,%rbx,8),%xmm0
subsd  0x20(%rsp),%xmm0
mulsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%esi
mov    %ebx,%edi
mov    $0x2a,%edx
call   1030 <plotXY@plt>
add    $0x1,%rbx
cmp    $0x50,%rbx
jne    1280 <createPlot+0x140>
xor    %eax,%eax
add    $0x2c8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printPlot@plt>

LLVM IR (-O0):
@INFINITY = global double 0.000000e+00
define void @createPlot(i8* %0, double %1, double %2) {
%4 = alloca i8*
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca [80 x double]
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca i32
store i8* %0, i8** %4
store double %1, double* %5
store double %2, double* %6
store i32 80, i32* %7
%18 = call i32 (...) @clearPlot()
%19 = load double, double* %6
%20 = load double, double* %5
%21 = fsub double %19, %20
store double %21, double* %10
%22 = load double, double* %10
%23 = fdiv double %22, 8.000000e+01
store double %23, double* %11
%24 = load double, double* %10
%25 = fdiv double 8.000000e+01, %24
store double %25, double* %12
%26 = load double, double* @INFINITY
%27 = fneg double %26
store double %27, double* %14
%28 = load double, double* @INFINITY
store double %28, double* %15
store i32 0, i32* %9
br label %29
29: ; preds = %67, %3
%30 = load i32, i32* %9
%31 = icmp slt i32 %30, 80
br i1 %31, label %32, label %70
32: ; preds = %29
%33 = load i8*, i8** %4
%34 = load double, double* %5
%35 = load i32, i32* %9
%36 = sitofp i32 %35 to double
%37 = load double, double* %11
%38 = call double @llvm.fmuladd.f64(double %36, double %37, double %34)
%39 = call double @rpn_eval(i8* %33, double %38)
%40 = load i32, i32* %9
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [80 x double], [80 x double]* %8, i64 0, i64 %41
store double %39, double* %42
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [80 x double], [80 x double]* %8, i64 0, i64 %44
%46 = load double, double* %45
%47 = load double, double* %14
%48 = fcmp ogt double %46, %47
br i1 %48, label %49, label %54
49: ; preds = %32
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [80 x double], [80 x double]* %8, i64 0, i64 %51
%53 = load double, double* %52
store double %53, double* %14
br label %54
54: ; preds = %49, %32
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [80 x double], [80 x double]* %8, i64 0, i64 %56
%58 = load double, double* %57
%59 = load double, double* %15
%60 = fcmp olt double %58, %59
br i1 %60, label %61, label %66
61: ; preds = %54
%62 = load i32, i32* %9
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [80 x double], [80 x double]* %8, i64 0, i64 %63
%65 = load double, double* %64
store double %65, double* %15
br label %66
66: ; preds = %61, %54
br label %67
67: ; preds = %66
%68 = load i32, i32* %9
%69 = add nsw i32 %68, 1
store i32 %69, i32* %9
br label %29
70: ; preds = %29
%71 = load double, double* %14
%72 = load double, double* %15
%73 = fsub double %71, %72
store double %73, double* %13
%74 = load double, double* %13
%75 = fdiv double 4.000000e+01, %74
store double %75, double* %16
store i32 0, i32* %9
br label %76
76: ; preds = %87, %70
%77 = load i32, i32* %9
%78 = icmp slt i32 %77, 40
br i1 %78, label %79, label %90
79: ; preds = %76
%80 = load double, double* %5
%81 = fneg double %80
%82 = load double, double* %12
%83 = fmul double %81, %82
%84 = fptosi double %83 to i32
%85 = load i32, i32* %9
%86 = call i32 @plotXY(i32 %84, i32 %85, i8 signext 124)
br label %87
87: ; preds = %79
%88 = load i32, i32* %9
%89 = add nsw i32 %88, 1
store i32 %89, i32* %9
br label %76
90: ; preds = %76
store i32 0, i32* %9
br label %91
91: ; preds = %102, %90
%92 = load i32, i32* %9
%93 = icmp slt i32 %92, 80
br i1 %93, label %94, label %105
94: ; preds = %91
%95 = load i32, i32* %9
%96 = load double, double* %15
%97 = fneg double %96
%98 = load double, double* %16
%99 = fmul double %97, %98
%100 = fptosi double %99 to i32
%101 = call i32 @plotXY(i32 %95, i32 %100, i8 signext 95)
br label %102
102: ; preds = %94
%103 = load i32, i32* %9
%104 = add nsw i32 %103, 1
store i32 %104, i32* %9
br label %91
105: ; preds = %91
store i32 0, i32* %9
br label %106
106: ; preds = %122, %105
%107 = load i32, i32* %9
%108 = icmp slt i32 %107, 80
br i1 %108, label %109, label %125
109: ; preds = %106
%110 = load i32, i32* %9
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds [80 x double], [80 x double]* %8, i64 0, i64 %111
%113 = load double, double* %112
%114 = load double, double* %15
%115 = fsub double %113, %114
%116 = load double, double* %16
%117 = fmul double %115, %116
%118 = fptosi double %117 to i32
store i32 %118, i32* %17
%119 = load i32, i32* %9
%120 = load i32, i32* %17
%121 = call i32 @plotXY(i32 %119, i32 %120, i8 signext 42)
br label %122
122: ; preds = %109
%123 = load i32, i32* %9
%124 = add nsw i32 %123, 1
store i32 %124, i32* %9
br label %106
125: ; preds = %106
%126 = call i32 (...) @printPlot()
ret void
}

LLVM IR (-O2):
@INFINITY = global double 0.000000e+00
define void @createPlot(i8* %0, double %1, double %2) {
%4 = alloca [80 x double]
%5 = bitcast [80 x double]* %4 to i8*
%6 = tail call i32 (...) @clearPlot()
%7 = fsub double %2, %1
%8 = fdiv double %7, 8.000000e+01
%9 = load double, double* @INFINITY
%10 = fneg double %9
br label %11
11: ; preds = %3, %11
%12 = phi i64 [ 0, %3 ], [ %24, %11 ]
%13 = phi double [ %10, %3 ], [ %21, %11 ]
%14 = phi double [ %9, %3 ], [ %23, %11 ]
%15 = trunc i64 %12 to i32
%16 = sitofp i32 %15 to double
%17 = tail call double @llvm.fmuladd.f64(double %16, double %8, double %1)
%18 = tail call double @rpn_eval(i8* %0, double %17)
%19 = getelementptr inbounds [80 x double], [80 x double]* %4, i64 0, i64 %12
store double %18, double* %19
%20 = fcmp ogt double %18, %13
%21 = select i1 %20, double %18, double %13
%22 = fcmp olt double %18, %14
%23 = select i1 %22, double %18, double %14
%24 = add nuw nsw i64 %12, 1
%25 = icmp eq i64 %24, 80
br i1 %25, label %26, label %11
26: ; preds = %11
%27 = fdiv double 8.000000e+01, %7
%28 = fsub double %21, %23
%29 = fneg double %1
%30 = fmul double %27, %29
%31 = fptosi double %30 to i32
br label %37
32: ; preds = %37
%33 = fdiv double 4.000000e+01, %28
%34 = fneg double %23
%35 = fmul double %33, %34
%36 = fptosi double %35 to i32
br label %42
37: ; preds = %26, %37
%38 = phi i32 [ 0, %26 ], [ %40, %37 ]
%39 = tail call i32 @plotXY(i32 %31, i32 %38, i8 signext 124)
%40 = add nuw nsw i32 %38, 1
%41 = icmp eq i32 %40, 40
br i1 %41, label %32, label %37
42: ; preds = %32, %42
%43 = phi i32 [ 0, %32 ], [ %45, %42 ]
%44 = tail call i32 @plotXY(i32 %43, i32 %36, i8 signext 95)
%45 = add nuw nsw i32 %43, 1
%46 = icmp eq i32 %45, 80
br i1 %46, label %47, label %42
47: ; preds = %42, %47
%48 = phi i64 [ %56, %47 ], [ 0, %42 ]
%49 = getelementptr inbounds [80 x double], [80 x double]* %4, i64 0, i64 %48
%50 = load double, double* %49
%51 = fsub double %50, %23
%52 = fmul double %33, %51
%53 = fptosi double %52 to i32
%54 = trunc i64 %48 to i32
%55 = tail call i32 @plotXY(i32 %54, i32 %53, i8 signext 42)
%56 = add nuw nsw i64 %48, 1
%57 = icmp eq i64 %56, 80
br i1 %57, label %58, label %47
58: ; preds = %47
%59 = tail call i32 (...) @printPlot()
ret void
}