#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 ceil(double);
double fabs(double);
double floor(double);
double log10(double);
double pow(int, double);
void scale_line_axis(double min_val, double max_val, double *inter,
                     double *out_min, double *out_max) {
  double divs[] = {0.1, 0.2, 0.25, 0.4, 0.5, 0.75, 1.0};
  double plus, units, len, work;
  double bias, n_len;
  int index, intervals = 3, i, temp, count = 0;
  if (min_val > max_val) {
    double temp = max_val;
    max_val = min_val;
    min_val = temp;
  } else if (min_val == max_val) {
    max_val = max_val + fabs(max_val) + 1.0;
  }
  len = max_val - min_val;
  n_len = 2 * len;
  while (n_len > len * 1.5 && count < 6) {
    count += 1;
    intervals += 1;
    work = (len / intervals) / pow(10, ceil(log10(len / intervals)));
    for (i = 0; i < 7; i++) {
      if (divs[i] >= work)
        break;
    }
    *inter = divs[i] * pow(10, ceil(log10(len / intervals)));
    *out_min = *inter * floor(min_val / (*inter));
    *out_max = *inter * ceil(max_val / (*inter));
    if (fabs(*out_min / units) < .01)
      *out_min = 0.0;
    if (fabs(*out_max / units) < .01)
      *out_max = 0.0;
    n_len = *out_max - *out_min;
  }
  return;
}


x86 assembly (clang, -O0):
<scale_line_axis>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb4(%rip),%rsi
mov    $0x38,%edx
call   1040 <memcpy@plt>
movl   $0x3,-0x98(%rbp)
movl   $0x0,-0xa4(%rbp)
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d3 <scale_line_axis+0x83>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0x8(%rbp)
jmp    1218 <scale_line_axis+0xc8>
movsd  -0x8(%rbp),%xmm0
ucomisd -0x10(%rbp),%xmm0
jne    1213 <scale_line_axis+0xc3>
jp     1213 <scale_line_axis+0xc3>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movaps 0xe26(%rip),%xmm2
pand   %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  0xdf6(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1218 <scale_line_axis+0xc8>
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xdd9(%rip),%xmm0
mulsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
movsd  0xdc4(%rip),%xmm1
mulsd  -0x78(%rbp),%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm0
mov    %al,-0xb1(%rbp)
jbe    1273 <scale_line_axis+0x123>
cmpl   $0x6,-0xa4(%rbp)
setl   %al
mov    %al,-0xb1(%rbp)
mov    -0xb1(%rbp),%al
test   $0x1,%al
jne    1286 <scale_line_axis+0x136>
jmp    148d <scale_line_axis+0x33d>
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa4(%rbp)
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
movsd  -0x78(%rbp),%xmm0
cvtsi2sdl -0x98(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
cvtsi2sdl -0x98(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
call   1060 <log10@plt>
call   1030 <ceil@plt>
mov    $0xa,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0xc0(%rbp),%xmm0
ff
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movl   $0x0,-0x9c(%rbp)
cmpl   $0x7,-0x9c(%rbp)
jge    1343 <scale_line_axis+0x1f3>
movslq -0x9c(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
ucomisd -0x80(%rbp),%xmm0
jb     132a <scale_line_axis+0x1da>
jmp    1343 <scale_line_axis+0x1f3>
jmp    132f <scale_line_axis+0x1df>
mov    -0x9c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x9c(%rbp)
jmp    1300 <scale_line_axis+0x1b0>
movslq -0x9c(%rbp),%rax
movsd  -0x60(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
cvtsi2sdl -0x98(%rbp),%xmm1
ff
divsd  %xmm1,%xmm0
call   1060 <log10@plt>
call   1030 <ceil@plt>
mov    $0xa,%edi
call   1050 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0xd8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xd0(%rbp)
ff
movsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%rax
divsd  (%rax),%xmm0
call   1070 <floor@plt>
movaps %xmm0,%xmm1
movsd  -0xd0(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0xc8(%rbp)
ff
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%rax
divsd  (%rax),%xmm0
call   1030 <ceil@plt>
movaps %xmm0,%xmm1
movsd  -0xc8(%rbp),%xmm0
ff
mulsd  %xmm1,%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm1
divsd  -0x70(%rbp),%xmm1
movaps 0xc06(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xbf2(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    143b <scale_line_axis+0x2eb>
mov    -0x20(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm1
divsd  -0x70(%rbp),%xmm1
movaps 0xbd1(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xbbd(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1470 <scale_line_axis+0x320>
mov    -0x28(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x28(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
subsd  (%rax),%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
jmp    123c <scale_line_axis+0xec>
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale_line_axis>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
ucomisd %xmm1,%xmm0
jbe    1167 <scale_line_axis+0x27>
movapd %xmm0,%xmm2
movapd %xmm1,%xmm0
jmp    1189 <scale_line_axis+0x49>
jne    1185 <scale_line_axis+0x45>
jp     1185 <scale_line_axis+0x45>
movapd 0xe8d(%rip),%xmm2
andpd  %xmm1,%xmm2
addsd  %xmm1,%xmm2
addsd  0xe8d(%rip),%xmm2
jmp    1189 <scale_line_axis+0x49>
movapd %xmm1,%xmm2
movapd %xmm2,0x20(%rsp)
movsd  %xmm0,0x18(%rsp)
subsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
addsd  %xmm2,%xmm0
movsd  0xe6f(%rip),%xmm1
movsd  %xmm2,0x10(%rsp)
mulsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
ucomisd %xmm1,%xmm0
jbe    1328 <scale_line_axis+0x1e8>
xor    %ebx,%ebx
lea    0xe84(%rip),%r13
nopl   0x0(%rax)
lea    0x4(%rbx),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rsp)
call   1050 <log10@plt>
call   1030 <ceil@plt>
mov    $0xa,%edi
call   1040 <pow@plt>
movsd  (%rsp),%xmm2
movapd %xmm2,%xmm1
divsd  %xmm0,%xmm1
movsd  0xe0e(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    12a0 <scale_line_axis+0x160>
mov    $0x1,%ebp
movsd  0xdff(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    12a2 <scale_line_axis+0x162>
mov    $0x2,%ebp
movsd  0xdf4(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    12a2 <scale_line_axis+0x162>
mov    $0x3,%ebp
movsd  0xde9(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    12a2 <scale_line_axis+0x162>
mov    $0x4,%ebp
movsd  0xdde(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    12a2 <scale_line_axis+0x162>
mov    $0x5,%ebp
movsd  0xdd3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    12a2 <scale_line_axis+0x162>
mov    $0x6,%ebp
movsd  0xd88(%rip),%xmm0
ucomisd %xmm1,%xmm0
jae    12a2 <scale_line_axis+0x162>
mov    $0x7,%ebp
jmp    12a2 <scale_line_axis+0x162>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebp,%ebp
movapd %xmm2,%xmm0
call   1050 <log10@plt>
call   1030 <ceil@plt>
mov    $0xa,%edi
call   1040 <pow@plt>
movapd %xmm0,%xmm1
mulsd  0x0(%r13,%rbp,8),%xmm1
movsd  %xmm1,(%rsp)
movsd  %xmm1,(%r12)
movsd  0x18(%rsp),%xmm0
divsd  %xmm1,%xmm0
call   1060 <floor@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r15)
movsd  (%r12),%xmm1
movsd  %xmm1,(%rsp)
movapd 0x20(%rsp),%xmm0
divsd  %xmm1,%xmm0
call   1030 <ceil@plt>
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%r14)
subsd  (%r15),%xmm0
ucomisd 0x8(%rsp),%xmm0
jbe    1328 <scale_line_axis+0x1e8>
lea    0x1(%rbx),%eax
cmp    $0x5,%ebx
mov    %eax,%ebx
jb     11d0 <scale_line_axis+0x90>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.scale_line_axis.divs = [7 x double] [double 1.000000e-01, double 2.000000e-01, double 2.500000e-01, double 4.000000e-01, double 5.000000e-01, double 7.500000e-01, double 1.000000e+00]
define void @scale_line_axis(double %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 [7 x double]
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca double
store double %0, double* %6
store double %1, double* %7
store double* %2, double** %8
store double* %3, double** %9
store double* %4, double** %10
%24 = bitcast [7 x double]* %11 to i8*
store i32 3, i32* %19
store i32 0, i32* %22
%25 = load double, double* %6
%26 = load double, double* %7
%27 = fcmp ogt double %25, %26
br i1 %27, label %28, label %32
28: ; preds = %5
%29 = load double, double* %7
store double %29, double* %23
%30 = load double, double* %6
store double %30, double* %7
%31 = load double, double* %23
store double %31, double* %6
br label %43
32: ; preds = %5
%33 = load double, double* %6
%34 = load double, double* %7
%35 = fcmp oeq double %33, %34
br i1 %35, label %36, label %42
36: ; preds = %32
%37 = load double, double* %7
%38 = load double, double* %7
%39 = call double @llvm.fabs.f64(double %38)
%40 = fadd double %37, %39
%41 = fadd double %40, 1.000000e+00
store double %41, double* %7
br label %42
42: ; preds = %36, %32
br label %43
43: ; preds = %42, %28
%44 = load double, double* %7
%45 = load double, double* %6
%46 = fsub double %44, %45
store double %46, double* %14
%47 = load double, double* %14
%48 = fmul double 2.000000e+00, %47
store double %48, double* %17
br label %49
49: ; preds = %140, %43
%50 = load double, double* %17
%51 = load double, double* %14
%52 = fmul double %51, 1.500000e+00
%53 = fcmp ogt double %50, %52
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i32, i32* %22
%56 = icmp slt i32 %55, 6
br label %57
57: ; preds = %54, %49
%58 = phi i1 [ false, %49 ], [ %56, %54 ]
br i1 %58, label %59, label %146
59: ; preds = %57
%60 = load i32, i32* %22
%61 = add nsw i32 %60, 1
store i32 %61, i32* %22
%62 = load i32, i32* %19
%63 = add nsw i32 %62, 1
store i32 %63, i32* %19
%64 = load double, double* %14
%65 = load i32, i32* %19
%66 = sitofp i32 %65 to double
%67 = fdiv double %64, %66
%68 = load double, double* %14
%69 = load i32, i32* %19
%70 = sitofp i32 %69 to double
%71 = fdiv double %68, %70
%72 = call double @log10(double %71)
%73 = call double @llvm.ceil.f64(double %72)
%74 = call double @pow(i32 10, double %73)
%75 = fdiv double %67, %74
store double %75, double* %15
store i32 0, i32* %20
br label %76
76: ; preds = %88, %59
%77 = load i32, i32* %20
%78 = icmp slt i32 %77, 7
br i1 %78, label %79, label %91
79: ; preds = %76
%80 = load i32, i32* %20
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds [7 x double], [7 x double]* %11, i64 0, i64 %81
%83 = load double, double* %82
%84 = load double, double* %15
%85 = fcmp oge double %83, %84
br i1 %85, label %86, label %87
86: ; preds = %79
br label %91
87: ; preds = %79
br label %88
88: ; preds = %87
%89 = load i32, i32* %20
%90 = add nsw i32 %89, 1
store i32 %90, i32* %20
br label %76
91: ; preds = %86, %76
%92 = load i32, i32* %20
%93 = sext i32 %92 to i64
%94 = getelementptr inbounds [7 x double], [7 x double]* %11, i64 0, i64 %93
%95 = load double, double* %94
%96 = load double, double* %14
%97 = load i32, i32* %19
%98 = sitofp i32 %97 to double
%99 = fdiv double %96, %98
%100 = call double @log10(double %99)
%101 = call double @llvm.ceil.f64(double %100)
%102 = call double @pow(i32 10, double %101)
%103 = fmul double %95, %102
%104 = load double*, double** %8
store double %103, double* %104
%105 = load double*, double** %8
%106 = load double, double* %105
%107 = load double, double* %6
%108 = load double*, double** %8
%109 = load double, double* %108
%110 = fdiv double %107, %109
%111 = call double @llvm.floor.f64(double %110)
%112 = fmul double %106, %111
%113 = load double*, double** %9
store double %112, double* %113
%114 = load double*, double** %8
%115 = load double, double* %114
%116 = load double, double* %7
%117 = load double*, double** %8
%118 = load double, double* %117
%119 = fdiv double %116, %118
%120 = call double @llvm.ceil.f64(double %119)
%121 = fmul double %115, %120
%122 = load double*, double** %10
store double %121, double* %122
%123 = load double*, double** %9
%124 = load double, double* %123
%125 = load double, double* %13
%126 = fdiv double %124, %125
%127 = call double @llvm.fabs.f64(double %126)
%128 = fcmp olt double %127, 1.000000e-02
br i1 %128, label %129, label %131
129: ; preds = %91
%130 = load double*, double** %9
store double 0.000000e+00, double* %130
br label %131
131: ; preds = %129, %91
%132 = load double*, double** %10
%133 = load double, double* %132
%134 = load double, double* %13
%135 = fdiv double %133, %134
%136 = call double @llvm.fabs.f64(double %135)
%137 = fcmp olt double %136, 1.000000e-02
br i1 %137, label %138, label %140
138: ; preds = %131
%139 = load double*, double** %10
store double 0.000000e+00, double* %139
br label %140
140: ; preds = %138, %131
%141 = load double*, double** %10
%142 = load double, double* %141
%143 = load double*, double** %9
%144 = load double, double* %143
%145 = fsub double %142, %144
store double %145, double* %17
br label %49
146: ; preds = %57
ret void
}

LLVM IR (-O2):
@__const.scale_line_axis.divs = [7 x double] [double 1.000000e-01, double 2.000000e-01, double 2.500000e-01, double 4.000000e-01, double 5.000000e-01, double 7.500000e-01, double 1.000000e+00]
define void @scale_line_axis(double %0, double %1, double* nocapture %2, double* nocapture %3, double* nocapture %4) {
%6 = fcmp ogt double %0, %1
br i1 %6, label %13, label %7
7: ; preds = %5
%8 = fcmp oeq double %0, %1
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = tail call double @llvm.fabs.f64(double %1)
%11 = fadd double %10, %1
%12 = fadd double %11, 1.000000e+00
br label %13
13: ; preds = %5, %7, %9
%14 = phi double [ %12, %9 ], [ %1, %7 ], [ %0, %5 ]
%15 = phi double [ %0, %9 ], [ %0, %7 ], [ %1, %5 ]
%16 = fsub double %14, %15
%17 = fmul double %16, 2.000000e+00
%18 = fmul double %16, 1.500000e+00
%19 = fcmp ogt double %17, %18
br i1 %19, label %20, label %65
20: ; preds = %13, %45
%21 = phi i32 [ %23, %45 ], [ 0, %13 ]
%22 = phi i32 [ %24, %45 ], [ 3, %13 ]
%23 = add nuw nsw i32 %21, 1
%24 = add nuw nsw i32 %22, 1
%25 = sitofp i32 %24 to double
%26 = fdiv double %16, %25
%27 = tail call double @log10(double %26)
%28 = tail call double @llvm.ceil.f64(double %27)
%29 = tail call double @pow(i32 10, double %28)
%30 = fdiv double %26, %29
%31 = fcmp ugt double %30, 1.000000e-01
br i1 %31, label %32, label %45
32: ; preds = %20
%33 = fcmp ugt double %30, 2.000000e-01
br i1 %33, label %34, label %45
34: ; preds = %32
%35 = fcmp ugt double %30, 2.500000e-01
br i1 %35, label %36, label %45
36: ; preds = %34
%37 = fcmp ugt double %30, 4.000000e-01
br i1 %37, label %38, label %45
38: ; preds = %36
%39 = fcmp ugt double %30, 5.000000e-01
br i1 %39, label %40, label %45
40: ; preds = %38
%41 = fcmp ugt double %30, 7.500000e-01
br i1 %41, label %42, label %45
42: ; preds = %40
%43 = fcmp ugt double %30, 1.000000e+00
br i1 %43, label %44, label %45
44: ; preds = %42
br label %45
45: ; preds = %44, %42, %40, %38, %36, %34, %32, %20
%46 = phi i64 [ 0, %20 ], [ 1, %32 ], [ 2, %34 ], [ 3, %36 ], [ 4, %38 ], [ 5, %40 ], [ 6, %42 ], [ 7, %44 ]
%47 = getelementptr inbounds [7 x double], [7 x double]* @__const.scale_line_axis.divs, i64 0, i64 %46
%48 = load double, double* %47
%49 = tail call double @log10(double %26)
%50 = tail call double @llvm.ceil.f64(double %49)
%51 = tail call double @pow(i32 10, double %50)
%52 = fmul double %48, %51
store double %52, double* %2
%53 = fdiv double %15, %52
%54 = tail call double @llvm.floor.f64(double %53)
%55 = fmul double %52, %54
store double %55, double* %3
%56 = load double, double* %2
%57 = fdiv double %14, %56
%58 = tail call double @llvm.ceil.f64(double %57)
%59 = fmul double %56, %58
store double %59, double* %4
%60 = load double, double* %3
%61 = fsub double %59, %60
%62 = fcmp ogt double %61, %18
%63 = icmp ult i32 %21, 5
%64 = select i1 %62, i1 %63, i1 false
br i1 %64, label %20, label %65
65: ; preds = %45, %13
ret void
}