void step_compute(int max, int *step, int *scale) {
  int j;
  double s;
  const int steps[] = {5,     10,    25,     50,     100,  200,
                       250,   500,   1000,   2000,   5000, 10000,
                       20000, 50000, 100000, 200000, 0};
  *step = steps[0];
  j = 1;
  if (20000 > max + 225) {
    *scale = 20000 / (max + 225);
    s = *scale;
  } else {
    *scale = -(max + 225) / 20000;
    s = 20000 / (double)(max + 225);
  }
  while ((*step * s < 225) && steps[j] != 0) {
    *step = steps[j++];
  }
}


x86 assembly (clang, -O0):
<step_compute>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xedf(%rip),%rsi
mov    $0x44,%edx
call   1030 <memcpy@plt>
mov    -0x70(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x1c(%rbp)
mov    -0x4(%rbp),%ecx
add    $0xe1,%ecx
mov    $0x4e20,%eax
cmp    %ecx,%eax
jle    118c <step_compute+0x7c>
mov    -0x4(%rbp),%ecx
add    $0xe1,%ecx
mov    $0x4e20,%eax
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11c6 <step_compute+0xb6>
mov    -0x4(%rbp),%ecx
add    $0xe1,%ecx
xor    %eax,%eax
sub    %ecx,%eax
mov    $0x4e20,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0xe1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe43(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11cb <step_compute+0xbb>
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm1
mulsd  -0x28(%rbp),%xmm1
xor    %eax,%eax
movsd  0xe26(%rip),%xmm0
ucomisd %xmm1,%xmm0
mov    %al,-0x71(%rbp)
jbe    11fe <step_compute+0xee>
movslq -0x1c(%rbp),%rax
cmpl   $0x0,-0x70(%rbp,%rax,4)
setne  %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    120e <step_compute+0xfe>
jmp    122a <step_compute+0x11a>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
mov    -0x70(%rbp,%rax,4),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    11cb <step_compute+0xbb>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<step_compute>:
mov    %rdx,%r8
movl   $0x5,(%rsi)
lea    0xe1(%rdi),%ecx
cmp    $0x4d3e,%edi
jg     1129 <step_compute+0x29>
mov    $0x4e20,%eax
xor    %edx,%edx
idiv   %ecx
mov    %eax,(%r8)
cvtsi2sd %eax,%xmm0
jmp    1159 <step_compute+0x59>
mov    $0xffffff1f,%eax
sub    %edi,%eax
cltq
imul   $0x68db8bad,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x2d,%rax
add    %edx,%eax
mov    %eax,(%r8)
cvtsi2sd %ecx,%xmm1
movsd  0xeab(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsi2sdl (%rsi),%xmm2
mulsd  %xmm0,%xmm2
movsd  0xe9f(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    11a3 <step_compute+0xa3>
mov    $0x1,%ecx
lea    0xe95(%rip),%rax
nopl   0x0(%rax,%rax,1)
mov    (%rax,%rcx,4),%edx
xorps  %xmm2,%xmm2
cvtsi2sd %edx,%xmm2
mulsd  %xmm0,%xmm2
ucomisd %xmm2,%xmm1
jbe    11a1 <step_compute+0xa1>
lea    0x1(%rcx),%rdi
cmp    $0xf,%rcx
mov    %rdi,%rcx
jne    1180 <step_compute+0x80>
mov    %edx,(%rsi)
ret

LLVM IR (-O0):
@__const.step_compute.steps = [17 x i32] [i32 5, i32 10, i32 25, i32 50, i32 100, i32 200, i32 250, i32 500, i32 1000, i32 2000, i32 5000, i32 10000, i32 20000, i32 50000, i32 100000, i32 200000, i32 0]
define void @step_compute(i32 %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca double
%9 = alloca [17 x i32]
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%10 = bitcast [17 x i32]* %9 to i8*
%11 = getelementptr inbounds [17 x i32], [17 x i32]* %9, i64 0, i64 0
%12 = load i32, i32* %11
%13 = load i32*, i32** %5
store i32 %12, i32* %13
store i32 1, i32* %7
%14 = load i32, i32* %4
%15 = add nsw i32 %14, 225
%16 = icmp sgt i32 20000, %15
br i1 %16, label %17, label %25
17: ; preds = %3
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 225
%20 = sdiv i32 20000, %19
%21 = load i32*, i32** %6
store i32 %20, i32* %21
%22 = load i32*, i32** %6
%23 = load i32, i32* %22
%24 = sitofp i32 %23 to double
store double %24, double* %8
br label %35
25: ; preds = %3
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 225
%28 = sub nsw i32 0, %27
%29 = sdiv i32 %28, 20000
%30 = load i32*, i32** %6
store i32 %29, i32* %30
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 225
%33 = sitofp i32 %32 to double
%34 = fdiv double 2.000000e+04, %33
store double %34, double* %8
br label %35
35: ; preds = %25, %17
br label %36
36: ; preds = %51, %35
%37 = load i32*, i32** %5
%38 = load i32, i32* %37
%39 = sitofp i32 %38 to double
%40 = load double, double* %8
%41 = fmul double %39, %40
%42 = fcmp olt double %41, 2.250000e+02
br i1 %42, label %43, label %49
43: ; preds = %36
%44 = load i32, i32* %7
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [17 x i32], [17 x i32]* %9, i64 0, i64 %45
%47 = load i32, i32* %46
%48 = icmp ne i32 %47, 0
br label %49
49: ; preds = %43, %36
%50 = phi i1 [ false, %36 ], [ %48, %43 ]
br i1 %50, label %51, label %58
51: ; preds = %49
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
store i32 %53, i32* %7
%54 = sext i32 %52 to i64
%55 = getelementptr inbounds [17 x i32], [17 x i32]* %9, i64 0, i64 %54
%56 = load i32, i32* %55
%57 = load i32*, i32** %5
store i32 %56, i32* %57
br label %36
58: ; preds = %49
ret void
}

LLVM IR (-O2):
@__const.step_compute.steps = [17 x i32] [i32 5, i32 10, i32 25, i32 50, i32 100, i32 200, i32 250, i32 500, i32 1000, i32 2000, i32 5000, i32 10000, i32 20000, i32 50000, i32 100000, i32 200000, i32 0]
define void @step_compute(i32 %0, i32* nocapture %1, i32* nocapture writeonly %2) {
store i32 5, i32* %1
%4 = add nsw i32 %0, 225
%5 = icmp slt i32 %0, 19775
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = sdiv i32 20000, %4
store i32 %7, i32* %2
%8 = sitofp i32 %7 to double
br label %14
9: ; preds = %3
%10 = sub nuw i32 -225, %0
%11 = sdiv i32 %10, 20000
store i32 %11, i32* %2
%12 = sitofp i32 %4 to double
%13 = fdiv double 2.000000e+04, %12
br label %14
14: ; preds = %9, %6
%15 = phi double [ %8, %6 ], [ %13, %9 ]
%16 = load i32, i32* %1
%17 = sitofp i32 %16 to double
%18 = fmul double %15, %17
%19 = fcmp uge double %18, 2.250000e+02
br i1 %19, label %31, label %20
20: ; preds = %14, %20
%21 = phi i64 [ %24, %20 ], [ 1, %14 ]
%22 = getelementptr inbounds [17 x i32], [17 x i32]* @__const.step_compute.steps, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = add nuw nsw i64 %21, 1
%25 = sitofp i32 %23 to double
%26 = fmul double %15, %25
%27 = fcmp uge double %26, 2.250000e+02
%28 = icmp eq i64 %24, 16
%29 = select i1 %27, i1 true, i1 %28
br i1 %29, label %30, label %20
30: ; preds = %20
store i32 %23, i32* %1
br label %31
31: ; preds = %30, %14
ret void
}