#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__ log10(float);
float pow(int, double);
void axis_round(float *min, float *max, float *grid_spacing) {
  int logspace;
  logspace = (int)(log10((*max - *min) / 10.0) + 0.5);
  *grid_spacing = pow(10, (double)logspace);
  *min = (float)((int)(*min / (*grid_spacing))) * (*grid_spacing);
  *max = (float)((int)(*max / (*grid_spacing)) + 1) * (*grid_spacing);
}


x86 assembly (clang, -O0):
<axis_round>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
subss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xeb8(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
call   1040 <log10@plt>
cvtsi2sd %rax,%xmm0
movsd  0xe96(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
mov    -0x18(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
divss  (%rax),%xmm0
cvttss2si %xmm0,%eax
cvtsi2ss %eax,%xmm0
mov    -0x18(%rbp),%rax
mulss  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movss  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
movss  (%rax),%xmm0
mov    -0x18(%rbp),%rax
divss  (%rax),%xmm0
cvttss2si %xmm0,%eax
add    $0x1,%eax
cvtsi2ss %eax,%xmm0
mov    -0x18(%rbp),%rax
mulss  (%rax),%xmm0
mov    -0x10(%rbp),%rax
movss  %xmm0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<axis_round>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
movss  (%rsi),%xmm0
subss  (%rdi),%xmm0
divss  0xec2(%rip),%xmm0
call   1040 <log10@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xeb5(%rip),%xmm0
cvttpd2dq %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
movss  %xmm0,(%r14)
movss  (%rbx),%xmm1
divss  %xmm0,%xmm1
cvttps2dq %xmm1,%xmm1
cvtdq2ps %xmm1,%xmm1
mulss  %xmm0,%xmm1
movss  %xmm1,(%rbx)
movss  (%r15),%xmm0
movss  (%r14),%xmm1
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @axis_round(float* %0, float* %1, float* %2) {
%4 = alloca float*
%5 = alloca float*
%6 = alloca float*
%7 = alloca i32
store float* %0, float** %4
store float* %1, float** %5
store float* %2, float** %6
%8 = load float*, float** %5
%9 = load float, float* %8
%10 = load float*, float** %4
%11 = load float, float* %10
%12 = fsub float %9, %11
%13 = fpext float %12 to double
%14 = fdiv double %13, 1.000000e+01
%15 = fptrunc double %14 to float
%16 = call i64 @log10(float %15)
%17 = sitofp i64 %16 to double
%18 = fadd double %17, 5.000000e-01
%19 = fptosi double %18 to i32
store i32 %19, i32* %7
%20 = load i32, i32* %7
%21 = sitofp i32 %20 to double
%22 = call float @pow(i32 10, double %21)
%23 = load float*, float** %6
store float %22, float* %23
%24 = load float*, float** %4
%25 = load float, float* %24
%26 = load float*, float** %6
%27 = load float, float* %26
%28 = fdiv float %25, %27
%29 = fptosi float %28 to i32
%30 = sitofp i32 %29 to float
%31 = load float*, float** %6
%32 = load float, float* %31
%33 = fmul float %30, %32
%34 = load float*, float** %4
store float %33, float* %34
%35 = load float*, float** %5
%36 = load float, float* %35
%37 = load float*, float** %6
%38 = load float, float* %37
%39 = fdiv float %36, %38
%40 = fptosi float %39 to i32
%41 = add nsw i32 %40, 1
%42 = sitofp i32 %41 to float
%43 = load float*, float** %6
%44 = load float, float* %43
%45 = fmul float %42, %44
%46 = load float*, float** %5
store float %45, float* %46
ret void
}

LLVM IR (-O2):
define void @axis_round(float* nocapture %0, float* nocapture %1, float* nocapture %2) {
%4 = load float, float* %1
%5 = load float, float* %0
%6 = fsub float %4, %5
%7 = fdiv float %6, 1.000000e+01
%8 = tail call i64 @log10(float %7)
%9 = sitofp i64 %8 to double
%10 = fadd double %9, 5.000000e-01
%11 = fptosi double %10 to i32
%12 = sitofp i32 %11 to double
%13 = tail call float @pow(i32 10, double %12)
store float %13, float* %2
%14 = load float, float* %0
%15 = fdiv float %14, %13
%16 = fptosi float %15 to i32
%17 = sitofp i32 %16 to float
%18 = fmul float %13, %17
store float %18, float* %0
%19 = load float, float* %1
%20 = load float, float* %2
%21 = fdiv float %19, %20
%22 = fptosi float %21 to i32
%23 = add nsw i32 %22, 1
%24 = sitofp i32 %23 to float
%25 = fmul float %20, %24
store float %25, float* %1
ret void
}