#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 ceil(float);
float fabs(float);
int floor(float);
int /*<<< orphan*/ g_lineto(float, int);
int /*<<< orphan*/ g_moveto(float, int);
int /*<<< orphan*/ g_set_world(int, float, float, float, float);
float get_long_ticks(float);
void psnd_paperplot_grid(int vp, int autoscalex, int autoscaley, float xminp,
                         float xmaxp, float yminp, float ymaxp,
                         float xlines_ppm, float ylines_ppm) {
  float xtmp1, xtmp2, ytmp1, ytmp2;
  int n, start, stop;
  if (autoscalex) {
    float len = fabs(xminp - xmaxp);
    xlines_ppm = get_long_ticks(len);
  }
  if (autoscaley) {
    float len = fabs(yminp - ymaxp);
    ylines_ppm = get_long_ticks(len);
  }
  xtmp1 = xminp * xlines_ppm;
  xtmp2 = xmaxp * xlines_ppm;
  ytmp1 = yminp * ylines_ppm;
  ytmp2 = ymaxp * ylines_ppm;
  start = ceil((((xtmp1) > (xtmp2)) ? (xtmp1) : (xtmp2)));
  stop = floor((((xtmp1) < (xtmp2)) ? (xtmp1) : (xtmp2)));
  g_set_world(vp, xtmp1, ytmp1, xtmp2, ytmp2);
  for (n = start; n >= stop; n--) {
    g_moveto(n, ytmp1);
    g_lineto(n, ytmp2);
  }
  start = ceil((((ytmp1) > (ytmp2)) ? (ytmp1) : (ytmp2)));
  stop = floor((((ytmp1) < (ytmp2)) ? (ytmp1) : (ytmp2)));
  for (n = start; n >= stop; n--) {
    g_moveto(xtmp1, n);
    g_lineto(xtmp2, n);
  }
}


x86 assembly (clang, -O0):
<psnd_paperplot_grid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movss  %xmm0,-0x10(%rbp)
movss  %xmm1,-0x14(%rbp)
movss  %xmm2,-0x18(%rbp)
movss  %xmm3,-0x1c(%rbp)
movss  %xmm4,-0x20(%rbp)
movss  %xmm5,-0x24(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11cc <psnd_paperplot_grid+0x5c>
movss  -0x10(%rbp),%xmm0
subss  -0x14(%rbp),%xmm0
call   1050 <fabs@plt>
movss  %xmm0,-0x44(%rbp)
movss  -0x44(%rbp),%xmm0
call   1060 <get_long_ticks@plt>
movss  %xmm0,-0x20(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11f9 <psnd_paperplot_grid+0x89>
movss  -0x18(%rbp),%xmm0
subss  -0x1c(%rbp),%xmm0
call   1050 <fabs@plt>
movss  %xmm0,-0x48(%rbp)
movss  -0x48(%rbp),%xmm0
call   1060 <get_long_ticks@plt>
movss  %xmm0,-0x24(%rbp)
movss  -0x10(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x1c(%rbp),%xmm0
mulss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  -0x28(%rbp),%xmm0
ucomiss -0x2c(%rbp),%xmm0
jbe    1253 <psnd_paperplot_grid+0xe3>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
jmp    125d <psnd_paperplot_grid+0xed>
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x4c(%rbp)
movss  -0x4c(%rbp),%xmm0
call   1030 <ceil@plt>
mov    %eax,-0x3c(%rbp)
movss  -0x28(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    128c <psnd_paperplot_grid+0x11c>
movss  -0x28(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
jmp    1296 <psnd_paperplot_grid+0x126>
movss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
movss  -0x50(%rbp),%xmm0
call   1080 <floor@plt>
mov    %eax,-0x40(%rbp)
mov    -0x4(%rbp),%edi
movss  -0x28(%rbp),%xmm0
movss  -0x30(%rbp),%xmm1
movss  -0x2c(%rbp),%xmm2
movss  -0x34(%rbp),%xmm3
call   1070 <g_set_world@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x40(%rbp),%eax
jl     12fd <psnd_paperplot_grid+0x18d>
cvtsi2ssl -0x38(%rbp),%xmm0
cvttss2si -0x30(%rbp),%edi
call   1040 <g_moveto@plt>
cvtsi2ssl -0x38(%rbp),%xmm0
cvttss2si -0x34(%rbp),%edi
call   1090 <g_lineto@plt>
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
jmp    12c5 <psnd_paperplot_grid+0x155>
movss  -0x30(%rbp),%xmm0
ucomiss -0x34(%rbp),%xmm0
jbe    131b <psnd_paperplot_grid+0x1ab>
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
jmp    1325 <psnd_paperplot_grid+0x1b5>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x54(%rbp)
movss  -0x54(%rbp),%xmm0
call   1030 <ceil@plt>
mov    %eax,-0x3c(%rbp)
movss  -0x30(%rbp),%xmm1
movss  -0x34(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1354 <psnd_paperplot_grid+0x1e4>
movss  -0x30(%rbp),%xmm0
movss  %xmm0,-0x58(%rbp)
jmp    135e <psnd_paperplot_grid+0x1ee>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x58(%rbp)
movss  -0x58(%rbp),%xmm0
call   1080 <floor@plt>
mov    %eax,-0x40(%rbp)
mov    -0x3c(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x40(%rbp),%eax
jl     13a5 <psnd_paperplot_grid+0x235>
movss  -0x28(%rbp),%xmm0
mov    -0x38(%rbp),%edi
call   1040 <g_moveto@plt>
movss  -0x2c(%rbp),%xmm0
mov    -0x38(%rbp),%edi
call   1090 <g_lineto@plt>
mov    -0x38(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x38(%rbp)
jmp    1371 <psnd_paperplot_grid+0x201>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<psnd_paperplot_grid>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %edi,%r14d
test   %esi,%esi
movss  %xmm1,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
movss  %xmm2,0x8(%rsp)
movss  %xmm3,0x4(%rsp)
je     11c8 <psnd_paperplot_grid+0x68>
movss  0xc(%rsp),%xmm0
subss  %xmm1,%xmm0
andps  0xe64(%rip),%xmm0
movss  %xmm5,0x14(%rsp)
call   1050 <get_long_ticks@plt>
movss  0x14(%rsp),%xmm5
movss  0x4(%rsp),%xmm3
movss  0x8(%rsp),%xmm2
movss  0x10(%rsp),%xmm1
movaps %xmm0,%xmm4
movss  0xc(%rsp),%xmm0
test   %ebx,%ebx
je     1206 <psnd_paperplot_grid+0xa6>
movaps %xmm2,%xmm0
subss  %xmm3,%xmm0
andps  0xe26(%rip),%xmm0
movss  %xmm4,0x14(%rsp)
call   1050 <get_long_ticks@plt>
movss  0x14(%rsp),%xmm4
movss  0x4(%rsp),%xmm3
movss  0x8(%rsp),%xmm2
movss  0x10(%rsp),%xmm1
movaps %xmm0,%xmm5
movss  0xc(%rsp),%xmm0
mulss  %xmm4,%xmm0
mulss  %xmm4,%xmm1
movss  %xmm1,0x10(%rsp)
mulss  %xmm5,%xmm2
movss  %xmm2,0x8(%rsp)
mulss  %xmm5,%xmm3
movss  %xmm3,0x4(%rsp)
movss  %xmm0,0xc(%rsp)
maxss  %xmm1,%xmm0
call   1030 <ceil@plt>
mov    %eax,%ebx
movss  0xc(%rsp),%xmm0
minss  0x10(%rsp),%xmm0
call   1070 <floor@plt>
mov    %eax,%r15d
mov    %r14d,%edi
movss  0xc(%rsp),%xmm0
movss  0x8(%rsp),%xmm1
movss  0x10(%rsp),%xmm2
movss  0x4(%rsp),%xmm3
call   1060 <g_set_world@plt>
cmp    %r15d,%ebx
jl     12ac <psnd_paperplot_grid+0x14c>
cvttss2si 0x8(%rsp),%r14d
cvttss2si 0x4(%rsp),%ebp
nop
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  %xmm0,0x14(%rsp)
mov    %r14d,%edi
call   1040 <g_moveto@plt>
movss  0x14(%rsp),%xmm0
mov    %ebp,%edi
call   1080 <g_lineto@plt>
lea    -0x1(%rbx),%eax
cmp    %r15d,%ebx
mov    %eax,%ebx
jg     1280 <psnd_paperplot_grid+0x120>
movss  0x8(%rsp),%xmm0
maxss  0x4(%rsp),%xmm0
call   1030 <ceil@plt>
mov    %eax,%ebx
movss  0x8(%rsp),%xmm0
minss  0x4(%rsp),%xmm0
call   1070 <floor@plt>
cmp    %eax,%ebx
jl     1303 <psnd_paperplot_grid+0x1a3>
mov    %eax,%ebp
cs nopw 0x0(%rax,%rax,1)
movss  0xc(%rsp),%xmm0
mov    %ebx,%edi
call   1040 <g_moveto@plt>
movss  0x10(%rsp),%xmm0
mov    %ebx,%edi
call   1080 <g_lineto@plt>
lea    -0x1(%rbx),%eax
cmp    %ebp,%ebx
mov    %eax,%ebx
jg     12e0 <psnd_paperplot_grid+0x180>
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @psnd_paperplot_grid(i32 %0, i32 %1, i32 %2, float %3, float %4, float %5, float %6, float %7, float %8) {
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca float
%18 = alloca float
%19 = alloca float
%20 = alloca float
%21 = alloca float
%22 = alloca float
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca float
%27 = alloca float
store i32 %0, i32* %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store float %3, float* %13
store float %4, float* %14
store float %5, float* %15
store float %6, float* %16
store float %7, float* %17
store float %8, float* %18
%28 = load i32, i32* %11
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %37
30: ; preds = %9
%31 = load float, float* %13
%32 = load float, float* %14
%33 = fsub float %31, %32
%34 = call float @fabs(float %33)
store float %34, float* %26
%35 = load float, float* %26
%36 = call float @get_long_ticks(float %35)
store float %36, float* %17
br label %37
37: ; preds = %30, %9
%38 = load i32, i32* %12
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load float, float* %15
%42 = load float, float* %16
%43 = fsub float %41, %42
%44 = call float @fabs(float %43)
store float %44, float* %27
%45 = load float, float* %27
%46 = call float @get_long_ticks(float %45)
store float %46, float* %18
br label %47
47: ; preds = %40, %37
%48 = load float, float* %13
%49 = load float, float* %17
%50 = fmul float %48, %49
store float %50, float* %19
%51 = load float, float* %14
%52 = load float, float* %17
%53 = fmul float %51, %52
store float %53, float* %20
%54 = load float, float* %15
%55 = load float, float* %18
%56 = fmul float %54, %55
store float %56, float* %21
%57 = load float, float* %16
%58 = load float, float* %18
%59 = fmul float %57, %58
store float %59, float* %22
%60 = load float, float* %19
%61 = load float, float* %20
%62 = fcmp ogt float %60, %61
br i1 %62, label %63, label %65
63: ; preds = %47
%64 = load float, float* %19
br label %67
65: ; preds = %47
%66 = load float, float* %20
br label %67
67: ; preds = %65, %63
%68 = phi float [ %64, %63 ], [ %66, %65 ]
%69 = call i32 @ceil(float %68)
store i32 %69, i32* %24
%70 = load float, float* %19
%71 = load float, float* %20
%72 = fcmp olt float %70, %71
br i1 %72, label %73, label %75
73: ; preds = %67
%74 = load float, float* %19
br label %77
75: ; preds = %67
%76 = load float, float* %20
br label %77
77: ; preds = %75, %73
%78 = phi float [ %74, %73 ], [ %76, %75 ]
%79 = call i32 @floor(float %78)
store i32 %79, i32* %25
%80 = load i32, i32* %10
%81 = load float, float* %19
%82 = load float, float* %21
%83 = load float, float* %20
%84 = load float, float* %22
%85 = call i32 @g_set_world(i32 %80, float %81, float %82, float %83, float %84)
%86 = load i32, i32* %24
store i32 %86, i32* %23
br label %87
87: ; preds = %102, %77
%88 = load i32, i32* %23
%89 = load i32, i32* %25
%90 = icmp sge i32 %88, %89
br i1 %90, label %91, label %105
91: ; preds = %87
%92 = load i32, i32* %23
%93 = sitofp i32 %92 to float
%94 = load float, float* %21
%95 = fptosi float %94 to i32
%96 = call i32 @g_moveto(float %93, i32 %95)
%97 = load i32, i32* %23
%98 = sitofp i32 %97 to float
%99 = load float, float* %22
%100 = fptosi float %99 to i32
%101 = call i32 @g_lineto(float %98, i32 %100)
br label %102
102: ; preds = %91
%103 = load i32, i32* %23
%104 = add nsw i32 %103, -1
store i32 %104, i32* %23
br label %87
105: ; preds = %87
%106 = load float, float* %21
%107 = load float, float* %22
%108 = fcmp ogt float %106, %107
br i1 %108, label %109, label %111
109: ; preds = %105
%110 = load float, float* %21
br label %113
111: ; preds = %105
%112 = load float, float* %22
br label %113
113: ; preds = %111, %109
%114 = phi float [ %110, %109 ], [ %112, %111 ]
%115 = call i32 @ceil(float %114)
store i32 %115, i32* %24
%116 = load float, float* %21
%117 = load float, float* %22
%118 = fcmp olt float %116, %117
br i1 %118, label %119, label %121
119: ; preds = %113
%120 = load float, float* %21
br label %123
121: ; preds = %113
%122 = load float, float* %22
br label %123
123: ; preds = %121, %119
%124 = phi float [ %120, %119 ], [ %122, %121 ]
%125 = call i32 @floor(float %124)
store i32 %125, i32* %25
%126 = load i32, i32* %24
store i32 %126, i32* %23
br label %127
127: ; preds = %138, %123
%128 = load i32, i32* %23
%129 = load i32, i32* %25
%130 = icmp sge i32 %128, %129
br i1 %130, label %131, label %141
131: ; preds = %127
%132 = load float, float* %19
%133 = load i32, i32* %23
%134 = call i32 @g_moveto(float %132, i32 %133)
%135 = load float, float* %20
%136 = load i32, i32* %23
%137 = call i32 @g_lineto(float %135, i32 %136)
br label %138
138: ; preds = %131
%139 = load i32, i32* %23
%140 = add nsw i32 %139, -1
store i32 %140, i32* %23
br label %127
141: ; preds = %127
ret void
}

LLVM IR (-O2):
define void @psnd_paperplot_grid(i32 %0, i32 %1, i32 %2, float %3, float %4, float %5, float %6, float %7, float %8) {
%10 = icmp eq i32 %1, 0
br i1 %10, label %15, label %11
11: ; preds = %9
%12 = fsub float %3, %4
%13 = tail call float @llvm.fabs.f32(float %12)
%14 = tail call float @get_long_ticks(float %13)
br label %15
15: ; preds = %11, %9
%16 = phi float [ %14, %11 ], [ %7, %9 ]
%17 = icmp eq i32 %2, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = fsub float %5, %6
%20 = tail call float @llvm.fabs.f32(float %19)
%21 = tail call float @get_long_ticks(float %20)
br label %22
22: ; preds = %18, %15
%23 = phi float [ %21, %18 ], [ %8, %15 ]
%24 = fmul float %16, %3
%25 = fmul float %16, %4
%26 = fmul float %23, %5
%27 = fmul float %23, %6
%28 = fcmp ogt float %24, %25
%29 = select i1 %28, float %24, float %25
%30 = tail call i32 @ceil(float %29)
%31 = fcmp olt float %24, %25
%32 = select i1 %31, float %24, float %25
%33 = tail call i32 @floor(float %32)
%34 = tail call i32 @g_set_world(i32 %0, float %24, float %26, float %25, float %27)
%35 = icmp slt i32 %30, %33
br i1 %35, label %46, label %36
36: ; preds = %22
%37 = fptosi float %26 to i32
%38 = fptosi float %27 to i32
br label %39
39: ; preds = %36, %39
%40 = phi i32 [ %30, %36 ], [ %44, %39 ]
%41 = sitofp i32 %40 to float
%42 = tail call i32 @g_moveto(float %41, i32 %37)
%43 = tail call i32 @g_lineto(float %41, i32 %38)
%44 = add nsw i32 %40, -1
%45 = icmp sgt i32 %40, %33
br i1 %45, label %39, label %46
46: ; preds = %39, %22
%47 = fcmp ogt float %26, %27
%48 = select i1 %47, float %26, float %27
%49 = tail call i32 @ceil(float %48)
%50 = fcmp olt float %26, %27
%51 = select i1 %50, float %26, float %27
%52 = tail call i32 @floor(float %51)
%53 = icmp slt i32 %49, %52
br i1 %53, label %60, label %54
54: ; preds = %46, %54
%55 = phi i32 [ %58, %54 ], [ %49, %46 ]
%56 = tail call i32 @g_moveto(float %24, i32 %55)
%57 = tail call i32 @g_lineto(float %25, i32 %55)
%58 = add nsw i32 %55, -1
%59 = icmp sgt i32 %55, %52
br i1 %59, label %54, label %60
60: ; preds = %54, %46
ret void
}