#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 */
scalar_t__ fmod(float, double);
float calc_steps(float longt, float mediumt, float shortt, float labels) {
  float steps, ticks[4], maxsteps = 10000.0, small_number = 1e-02;
  int i, j, significant_digits = 2;
  ticks[0] = longt;
  ticks[1] = mediumt;
  ticks[2] = shortt;
  ticks[3] = labels;
  steps = 1.0;
  for (i = 0; i < 4; i++) {
    if (ticks[i] > small_number) {
      for (j = 0; j < significant_digits; j++)
        if (fmod(ticks[i], 1.0))
          ticks[i] *= 10;
      steps *= ticks[i];
    }
  }
  while (steps > maxsteps)
    steps /= 10;
  return steps;
}


x86 assembly (clang, -O0):
<calc_steps>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  %xmm3,-0x10(%rbp)
movss  0xed4(%rip),%xmm0
movss  %xmm0,-0x34(%rbp)
movss  0xec3(%rip),%xmm0
movss  %xmm0,-0x38(%rbp)
movl   $0x2,-0x44(%rbp)
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x30(%rbp)
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  0xe83(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x4,-0x3c(%rbp)
jge    122d <calc_steps+0x11d>
movslq -0x3c(%rbp),%rax
movss  -0x30(%rbp,%rax,4),%xmm0
ucomiss -0x38(%rbp),%xmm0
jbe    121a <calc_steps+0x10a>
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x44(%rbp),%eax
jge    1206 <calc_steps+0xf6>
movslq -0x3c(%rbp),%rax
movss  -0x30(%rbp,%rax,4),%xmm0
movsd  0xe44(%rip),%xmm1
call   1030 <fmod@plt>
cmp    $0x0,%rax
je     11f3 <calc_steps+0xe3>
movslq -0x3c(%rbp),%rax
movss  0xe25(%rip),%xmm0
mulss  -0x30(%rbp,%rax,4),%xmm0
movss  %xmm0,-0x30(%rbp,%rax,4)
jmp    11f8 <calc_steps+0xe8>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    11ae <calc_steps+0x9e>
movslq -0x3c(%rbp),%rax
movss  -0x30(%rbp,%rax,4),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    121f <calc_steps+0x10f>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1189 <calc_steps+0x79>
jmp    1232 <calc_steps+0x122>
movss  -0x14(%rbp),%xmm0
ucomiss -0x34(%rbp),%xmm0
jbe    125c <calc_steps+0x14c>
movss  -0x14(%rbp),%xmm0
movss  0xdbe(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
jmp    1232 <calc_steps+0x122>
movss  -0x14(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calc_steps>:
sub    $0x18,%rsp
ucomiss 0xee9(%rip),%xmm0
movss  %xmm3,0xc(%rsp)
movss  %xmm2,0x10(%rsp)
movss  %xmm1,0x14(%rsp)
jbe    11be <calc_steps+0xae>
movsd  0xed5(%rip),%xmm1
movss  %xmm0,0x8(%rsp)
call   1030 <fmod@plt>
movss  0x8(%rsp),%xmm0
test   %rax,%rax
je     1159 <calc_steps+0x49>
mulss  0xeaf(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
movsd  0xea9(%rip),%xmm1
call   1030 <fmod@plt>
movss  0x8(%rsp),%xmm0
test   %rax,%rax
movss  0xc(%rsp),%xmm3
movss  0x10(%rsp),%xmm2
movss  0x14(%rsp),%xmm1
jne    11d1 <calc_steps+0xc1>
ucomiss 0xe74(%rip),%xmm1
ja     11e2 <calc_steps+0xd2>
ucomiss 0xe6b(%rip),%xmm2
ja     1257 <calc_steps+0x147>
ucomiss 0xe5e(%rip),%xmm3
ja     12c3 <calc_steps+0x1b3>
ucomiss 0xe59(%rip),%xmm0
ja     1325 <calc_steps+0x215>
jmp    1349 <calc_steps+0x239>
movss  0xe3a(%rip),%xmm0
ucomiss 0xe37(%rip),%xmm1
jbe    1192 <calc_steps+0x82>
jmp    11e2 <calc_steps+0xd2>
mulss  0xe2f(%rip),%xmm0
ucomiss 0xe24(%rip),%xmm1
jbe    1192 <calc_steps+0x82>
movss  %xmm0,0x8(%rsp)
movsd  0xe20(%rip),%xmm2
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
call   1030 <fmod@plt>
movss  0x14(%rsp),%xmm0
test   %rax,%rax
je     120e <calc_steps+0xfe>
mulss  0xdfa(%rip),%xmm0
movss  %xmm0,0x14(%rsp)
movsd  0xdf4(%rip),%xmm1
call   1030 <fmod@plt>
movss  0x14(%rsp),%xmm1
test   %rax,%rax
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm3
movss  0x10(%rsp),%xmm2
je     1246 <calc_steps+0x136>
mulss  0xdc2(%rip),%xmm1
mulss  %xmm1,%xmm0
ucomiss 0xdb3(%rip),%xmm2
jbe    119f <calc_steps+0x8f>
movss  %xmm0,0x8(%rsp)
movsd  0xdab(%rip),%xmm1
movaps %xmm2,%xmm0
call   1030 <fmod@plt>
movss  0x10(%rsp),%xmm0
test   %rax,%rax
je     1280 <calc_steps+0x170>
mulss  0xd88(%rip),%xmm0
movss  %xmm0,0x10(%rsp)
movsd  0xd82(%rip),%xmm1
call   1030 <fmod@plt>
movss  0x10(%rsp),%xmm1
test   %rax,%rax
movss  0x8(%rsp),%xmm0
movss  0xc(%rsp),%xmm3
je     12b2 <calc_steps+0x1a2>
mulss  0xd56(%rip),%xmm1
mulss  %xmm1,%xmm0
ucomiss 0xd47(%rip),%xmm3
jbe    11ac <calc_steps+0x9c>
movss  %xmm0,0x8(%rsp)
movsd  0xd3f(%rip),%xmm1
movaps %xmm3,%xmm0
call   1030 <fmod@plt>
movss  0xc(%rsp),%xmm0
test   %rax,%rax
je     12ec <calc_steps+0x1dc>
mulss  0xd1c(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
movsd  0xd16(%rip),%xmm1
call   1030 <fmod@plt>
movss  0xc(%rsp),%xmm1
test   %rax,%rax
movss  0x8(%rsp),%xmm0
je     1318 <calc_steps+0x208>
mulss  0xcf0(%rip),%xmm1
mulss  %xmm1,%xmm0
ucomiss 0xce9(%rip),%xmm0
jbe    1349 <calc_steps+0x239>
movss  0xcdb(%rip),%xmm2
movss  0xcd7(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
nop
divss  %xmm2,%xmm0
ucomiss %xmm1,%xmm0
ja     1340 <calc_steps+0x230>
add    $0x18,%rsp
ret

LLVM IR (-O0):
define float @calc_steps(float %0, float %1, float %2, float %3) {
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca [4 x float]
%11 = alloca float
%12 = alloca float
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
store float %3, float* %8
store float 1.000000e+04, float* %11
store float 0x3F847AE140000000, float* %12
store i32 2, i32* %15
%16 = load float, float* %5
%17 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 0
store float %16, float* %17
%18 = load float, float* %6
%19 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 1
store float %18, float* %19
%20 = load float, float* %7
%21 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 2
store float %20, float* %21
%22 = load float, float* %8
%23 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 3
store float %22, float* %23
store float 1.000000e+00, float* %9
store i32 0, i32* %13
br label %24
24: ; preds = %64, %4
%25 = load i32, i32* %13
%26 = icmp slt i32 %25, 4
br i1 %26, label %27, label %67
27: ; preds = %24
%28 = load i32, i32* %13
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 %29
%31 = load float, float* %30
%32 = load float, float* %12
%33 = fcmp ogt float %31, %32
br i1 %33, label %34, label %63
34: ; preds = %27
store i32 0, i32* %14
br label %35
35: ; preds = %53, %34
%36 = load i32, i32* %14
%37 = load i32, i32* %15
%38 = icmp slt i32 %36, %37
br i1 %38, label %39, label %56
39: ; preds = %35
%40 = load i32, i32* %13
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 %41
%43 = load float, float* %42
%44 = call i64 @fmod(float %43, double 1.000000e+00)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %39
%47 = load i32, i32* %13
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 %48
%50 = load float, float* %49
%51 = fmul float %50, 1.000000e+01
store float %51, float* %49
br label %52
52: ; preds = %46, %39
br label %53
53: ; preds = %52
%54 = load i32, i32* %14
%55 = add nsw i32 %54, 1
store i32 %55, i32* %14
br label %35
56: ; preds = %35
%57 = load i32, i32* %13
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [4 x float], [4 x float]* %10, i64 0, i64 %58
%60 = load float, float* %59
%61 = load float, float* %9
%62 = fmul float %61, %60
store float %62, float* %9
br label %63
63: ; preds = %56, %27
br label %64
64: ; preds = %63
%65 = load i32, i32* %13
%66 = add nsw i32 %65, 1
store i32 %66, i32* %13
br label %24
67: ; preds = %24
br label %68
68: ; preds = %72, %67
%69 = load float, float* %9
%70 = load float, float* %11
%71 = fcmp ogt float %69, %70
br i1 %71, label %72, label %75
72: ; preds = %68
%73 = load float, float* %9
%74 = fdiv float %73, 1.000000e+01
store float %74, float* %9
br label %68
75: ; preds = %68
%76 = load float, float* %9
ret float %76
}

LLVM IR (-O2):
define float @calc_steps(float %0, float %1, float %2, float %3) {
%5 = fcmp ogt float %0, 0x3F847AE140000000
br i1 %5, label %6, label %15
6: ; preds = %4
%7 = tail call i64 @fmod(float %0, double 1.000000e+00)
%8 = icmp eq i64 %7, 0
%9 = fmul float %0, 1.000000e+01
%10 = select i1 %8, float %0, float %9
%11 = tail call i64 @fmod(float %10, double 1.000000e+00)
%12 = icmp eq i64 %11, 0
%13 = fmul float %10, 1.000000e+01
%14 = select i1 %12, float %10, float %13
br label %15
15: ; preds = %4, %6
%16 = phi float [ %14, %6 ], [ 1.000000e+00, %4 ]
%17 = fcmp ogt float %1, 0x3F847AE140000000
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = tail call i64 @fmod(float %1, double 1.000000e+00)
%20 = icmp eq i64 %19, 0
%21 = fmul float %1, 1.000000e+01
%22 = select i1 %20, float %1, float %21
%23 = tail call i64 @fmod(float %22, double 1.000000e+00)
%24 = icmp eq i64 %23, 0
%25 = fmul float %22, 1.000000e+01
%26 = select i1 %24, float %22, float %25
%27 = fmul float %16, %26
br label %28
28: ; preds = %18, %15
%29 = phi float [ %27, %18 ], [ %16, %15 ]
%30 = fcmp ogt float %2, 0x3F847AE140000000
br i1 %30, label %31, label %41
31: ; preds = %28
%32 = tail call i64 @fmod(float %2, double 1.000000e+00)
%33 = icmp eq i64 %32, 0
%34 = fmul float %2, 1.000000e+01
%35 = select i1 %33, float %2, float %34
%36 = tail call i64 @fmod(float %35, double 1.000000e+00)
%37 = icmp eq i64 %36, 0
%38 = fmul float %35, 1.000000e+01
%39 = select i1 %37, float %35, float %38
%40 = fmul float %29, %39
br label %41
41: ; preds = %31, %28
%42 = phi float [ %40, %31 ], [ %29, %28 ]
%43 = fcmp ogt float %3, 0x3F847AE140000000
br i1 %43, label %44, label %54
44: ; preds = %41
%45 = tail call i64 @fmod(float %3, double 1.000000e+00)
%46 = icmp eq i64 %45, 0
%47 = fmul float %3, 1.000000e+01
%48 = select i1 %46, float %3, float %47
%49 = tail call i64 @fmod(float %48, double 1.000000e+00)
%50 = icmp eq i64 %49, 0
%51 = fmul float %48, 1.000000e+01
%52 = select i1 %50, float %48, float %51
%53 = fmul float %42, %52
br label %54
54: ; preds = %44, %41
%55 = phi float [ %53, %44 ], [ %42, %41 ]
%56 = fcmp ogt float %55, 1.000000e+04
br i1 %56, label %57, label %61
57: ; preds = %54, %57
%58 = phi float [ %59, %57 ], [ %55, %54 ]
%59 = fdiv float %58, 1.000000e+01
%60 = fcmp ogt float %59, 1.000000e+04
br i1 %60, label %57, label %61
61: ; preds = %57, %54
%62 = phi float [ %55, %54 ], [ %59, %57 ]
ret float %62
}