void grace_get_y_tick_major_minor(double *y_tick_major, int *y_tick_minor,
                                  int *yaxis_ticklabel_precision,
                                  double y_range, int graph_list_length,
                                  double world_max_y) {
  double range_div_twenty_five;
  range_div_twenty_five = y_range / 25.0;
  if (y_range < 1) {
    *y_tick_major = 0.05;
    *y_tick_minor = 1;
    *yaxis_ticklabel_precision = 2;
  } else if (range_div_twenty_five < 0.01) {
    *y_tick_major = 0.02;
    *y_tick_minor = 1;
    *yaxis_ticklabel_precision = 2;
  } else if (range_div_twenty_five < 0.1) {
    *y_tick_major = 0.2;
    *y_tick_minor = 1;
    *yaxis_ticklabel_precision = 1;
  } else if (range_div_twenty_five < 0.5) {
    *y_tick_major = 0.5;
    *y_tick_minor = 1;
  } else if (range_div_twenty_five < 1.0) {
    *y_tick_major = 1.0;
    *y_tick_minor = 1;
  } else if (range_div_twenty_five < 2.0) {
    *y_tick_major = 2.0;
    *y_tick_minor = 1;
  } else if (range_div_twenty_five < 3.0) {
    *y_tick_major = 3.0;
    *y_tick_minor = 1;
  } else if (range_div_twenty_five < 4.0) {
    *y_tick_major = 4.0;
    *y_tick_minor = 1;
  } else {
    *y_tick_major = (double)(int)range_div_twenty_five;
    *y_tick_minor = 1;
  }
  *y_tick_major *= (double)graph_list_length;
  if (*y_tick_major >= world_max_y)
    *y_tick_major = world_max_y / 2.0;
}


x86 assembly (clang, -O0):
<grace_get_y_tick_major_minor>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movsd  %xmm0,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movsd  %xmm1,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xede(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xec5(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    116f <grace_get_y_tick_major_minor+0x6f>
mov    -0x8(%rbp),%rax
movsd  0xefe(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
jmp    131f <grace_get_y_tick_major_minor+0x21f>
movsd  0xe99(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11ab <grace_get_y_tick_major_minor+0xab>
mov    -0x8(%rbp),%rax
movsd  0xeba(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
jmp    131a <grace_get_y_tick_major_minor+0x21a>
movsd  0xe65(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11e7 <grace_get_y_tick_major_minor+0xe7>
mov    -0x8(%rbp),%rax
movsd  0xe76(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1315 <grace_get_y_tick_major_minor+0x215>
movsd  0xe31(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    1219 <grace_get_y_tick_major_minor+0x119>
mov    -0x8(%rbp),%rax
movsd  0xe1a(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1310 <grace_get_y_tick_major_minor+0x210>
movsd  0xddf(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    124b <grace_get_y_tick_major_minor+0x14b>
mov    -0x8(%rbp),%rax
movsd  0xdc8(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    130b <grace_get_y_tick_major_minor+0x20b>
movsd  0xdd5(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    127d <grace_get_y_tick_major_minor+0x17d>
mov    -0x8(%rbp),%rax
movsd  0xdbe(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1306 <grace_get_y_tick_major_minor+0x206>
movsd  0xdab(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    12af <grace_get_y_tick_major_minor+0x1af>
mov    -0x8(%rbp),%rax
movsd  0xd94(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1301 <grace_get_y_tick_major_minor+0x201>
movsd  0xd81(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    12e1 <grace_get_y_tick_major_minor+0x1e1>
mov    -0x8(%rbp),%rax
movsd  0xd6a(%rip),%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    12fc <grace_get_y_tick_major_minor+0x1fc>
cvttsd2si -0x38(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
jmp    1301 <grace_get_y_tick_major_minor+0x201>
jmp    1306 <grace_get_y_tick_major_minor+0x206>
jmp    130b <grace_get_y_tick_major_minor+0x20b>
jmp    1310 <grace_get_y_tick_major_minor+0x210>
jmp    1315 <grace_get_y_tick_major_minor+0x215>
jmp    131a <grace_get_y_tick_major_minor+0x21a>
jmp    131f <grace_get_y_tick_major_minor+0x21f>
cvtsi2sdl -0x24(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mulsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd -0x30(%rbp),%xmm0
jb     135c <grace_get_y_tick_major_minor+0x25c>
movsd  -0x30(%rbp),%xmm0
movsd  0xcd8(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x8(%rbp),%rax
movsd  %xmm0,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<grace_get_y_tick_major_minor>:
movsd  0xf00(%rip),%xmm3
ucomisd %xmm0,%xmm3
jbe    1127 <grace_get_y_tick_major_minor+0x27>
movl   $0x1,(%rsi)
movl   $0x2,(%rdx)
movsd  0xf2e(%rip),%xmm2
jmp    11e5 <grace_get_y_tick_major_minor+0xe5>
divsd  0xed1(%rip),%xmm0
movsd  0xed9(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    1156 <grace_get_y_tick_major_minor+0x56>
movl   $0x1,(%rsi)
movl   $0x2,(%rdx)
movsd  0xef7(%rip),%xmm2
jmp    11e5 <grace_get_y_tick_major_minor+0xe5>
movsd  0xeba(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    117a <grace_get_y_tick_major_minor+0x7a>
movl   $0x1,(%rsi)
movl   $0x1,(%rdx)
movsd  0xec8(%rip),%xmm2
jmp    11e5 <grace_get_y_tick_major_minor+0xe5>
movsd  0xe9e(%rip),%xmm2
ucomisd %xmm0,%xmm2
ja     11df <grace_get_y_tick_major_minor+0xdf>
ucomisd %xmm0,%xmm3
jbe    119a <grace_get_y_tick_major_minor+0x9a>
movl   $0x1,(%rsi)
movapd %xmm3,%xmm2
jmp    11e5 <grace_get_y_tick_major_minor+0xe5>
movsd  0xe86(%rip),%xmm2
ucomisd %xmm0,%xmm2
ja     11df <grace_get_y_tick_major_minor+0xdf>
movsd  0xe80(%rip),%xmm2
ucomisd %xmm0,%xmm2
ja     11df <grace_get_y_tick_major_minor+0xdf>
movsd  0xe7a(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    11d3 <grace_get_y_tick_major_minor+0xd3>
movabs $0x4010000000000000,%rax
mov    %rax,(%rdi)
jmp    11df <grace_get_y_tick_major_minor+0xdf>
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm2
movlpd %xmm2,(%rdi)
movl   $0x1,(%rsi)
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  %xmm2,%xmm0
movsd  0xe28(%rip),%xmm2
mulsd  %xmm1,%xmm2
cmpnlesd %xmm0,%xmm1
andpd  %xmm1,%xmm0
andnpd %xmm2,%xmm1
orpd   %xmm0,%xmm1
movlpd %xmm1,(%rdi)
ret

LLVM IR (-O0):
define void @grace_get_y_tick_major_minor(double* %0, i32* %1, i32* %2, double %3, i32 %4, double %5) {
%7 = alloca double*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca double
%11 = alloca i32
%12 = alloca double
%13 = alloca double
store double* %0, double** %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store double %3, double* %10
store i32 %4, i32* %11
store double %5, double* %12
%14 = load double, double* %10
%15 = fdiv double %14, 2.500000e+01
store double %15, double* %13
%16 = load double, double* %10
%17 = fcmp olt double %16, 1.000000e+00
br i1 %17, label %18, label %22
18: ; preds = %6
%19 = load double*, double** %7
store double 5.000000e-02, double* %19
%20 = load i32*, i32** %8
store i32 1, i32* %20
%21 = load i32*, i32** %9
store i32 2, i32* %21
br label %79
22: ; preds = %6
%23 = load double, double* %13
%24 = fcmp olt double %23, 1.000000e-02
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load double*, double** %7
store double 2.000000e-02, double* %26
%27 = load i32*, i32** %8
store i32 1, i32* %27
%28 = load i32*, i32** %9
store i32 2, i32* %28
br label %78
29: ; preds = %22
%30 = load double, double* %13
%31 = fcmp olt double %30, 1.000000e-01
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = load double*, double** %7
store double 2.000000e-01, double* %33
%34 = load i32*, i32** %8
store i32 1, i32* %34
%35 = load i32*, i32** %9
store i32 1, i32* %35
br label %77
36: ; preds = %29
%37 = load double, double* %13
%38 = fcmp olt double %37, 5.000000e-01
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = load double*, double** %7
store double 5.000000e-01, double* %40
%41 = load i32*, i32** %8
store i32 1, i32* %41
br label %76
42: ; preds = %36
%43 = load double, double* %13
%44 = fcmp olt double %43, 1.000000e+00
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load double*, double** %7
store double 1.000000e+00, double* %46
%47 = load i32*, i32** %8
store i32 1, i32* %47
br label %75
48: ; preds = %42
%49 = load double, double* %13
%50 = fcmp olt double %49, 2.000000e+00
br i1 %50, label %51, label %54
51: ; preds = %48
%52 = load double*, double** %7
store double 2.000000e+00, double* %52
%53 = load i32*, i32** %8
store i32 1, i32* %53
br label %74
54: ; preds = %48
%55 = load double, double* %13
%56 = fcmp olt double %55, 3.000000e+00
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load double*, double** %7
store double 3.000000e+00, double* %58
%59 = load i32*, i32** %8
store i32 1, i32* %59
br label %73
60: ; preds = %54
%61 = load double, double* %13
%62 = fcmp olt double %61, 4.000000e+00
br i1 %62, label %63, label %66
63: ; preds = %60
%64 = load double*, double** %7
store double 4.000000e+00, double* %64
%65 = load i32*, i32** %8
store i32 1, i32* %65
br label %72
66: ; preds = %60
%67 = load double, double* %13
%68 = fptosi double %67 to i32
%69 = sitofp i32 %68 to double
%70 = load double*, double** %7
store double %69, double* %70
%71 = load i32*, i32** %8
store i32 1, i32* %71
br label %72
72: ; preds = %66, %63
br label %73
73: ; preds = %72, %57
br label %74
74: ; preds = %73, %51
br label %75
75: ; preds = %74, %45
br label %76
76: ; preds = %75, %39
br label %77
77: ; preds = %76, %32
br label %78
78: ; preds = %77, %25
br label %79
79: ; preds = %78, %18
%80 = load i32, i32* %11
%81 = sitofp i32 %80 to double
%82 = load double*, double** %7
%83 = load double, double* %82
%84 = fmul double %83, %81
store double %84, double* %82
%85 = load double*, double** %7
%86 = load double, double* %85
%87 = load double, double* %12
%88 = fcmp oge double %86, %87
br i1 %88, label %89, label %93
89: ; preds = %79
%90 = load double, double* %12
%91 = fdiv double %90, 2.000000e+00
%92 = load double*, double** %7
store double %91, double* %92
br label %93
93: ; preds = %89, %79
ret void
}

LLVM IR (-O2):
define void @grace_get_y_tick_major_minor(double* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, double %3, i32 %4, double %5) {
%7 = fdiv double %3, 2.500000e+01
%8 = fcmp olt double %3, 1.000000e+00
br i1 %8, label %9, label %10
9: ; preds = %6
store i32 1, i32* %1
store i32 2, i32* %2
br label %34
10: ; preds = %6
%11 = fcmp olt double %7, 1.000000e-02
br i1 %11, label %12, label %13
12: ; preds = %10
store i32 1, i32* %1
store i32 2, i32* %2
br label %34
13: ; preds = %10
%14 = fcmp olt double %7, 1.000000e-01
br i1 %14, label %15, label %16
15: ; preds = %13
store i32 1, i32* %1
store i32 1, i32* %2
br label %34
16: ; preds = %13
%17 = fcmp olt double %7, 5.000000e-01
br i1 %17, label %18, label %19
18: ; preds = %16
store i32 1, i32* %1
br label %34
19: ; preds = %16
%20 = fcmp olt double %7, 1.000000e+00
br i1 %20, label %21, label %22
21: ; preds = %19
store i32 1, i32* %1
br label %34
22: ; preds = %19
%23 = fcmp olt double %7, 2.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %22
store i32 1, i32* %1
br label %34
25: ; preds = %22
%26 = fcmp olt double %7, 3.000000e+00
br i1 %26, label %27, label %28
27: ; preds = %25
store i32 1, i32* %1
br label %34
28: ; preds = %25
%29 = fcmp olt double %7, 4.000000e+00
br i1 %29, label %30, label %31
30: ; preds = %28
store double 4.000000e+00, double* %0
store i32 1, i32* %1
br label %34
31: ; preds = %28
%32 = fptosi double %7 to i32
%33 = sitofp i32 %32 to double
store double %33, double* %0
store i32 1, i32* %1
br label %34
34: ; preds = %12, %18, %24, %30, %31, %27, %21, %15, %9
%35 = phi double [ 2.000000e-02, %12 ], [ 5.000000e-01, %18 ], [ 2.000000e+00, %24 ], [ 4.000000e+00, %30 ], [ %33, %31 ], [ 3.000000e+00, %27 ], [ 1.000000e+00, %21 ], [ 2.000000e-01, %15 ], [ 5.000000e-02, %9 ]
%36 = sitofp i32 %4 to double
%37 = fmul double %35, %36
%38 = fcmp ult double %37, %5
%39 = fmul double %5, 5.000000e-01
%40 = select i1 %38, double %37, double %39
store double %40, double* %0
ret void
}