#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 */
float pow(int, float);
float scale(float value, float range, float offset) {
  if (range != offset) {
    if ((range - offset) > 0) {
      return value * pow(10, range - offset);
    } else {
      return value / pow(10, offset - range);
    }
  }
  return value;
}


x86 assembly (clang, -O0):
<scale>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x8(%rbp)
movss  %xmm1,-0xc(%rbp)
movss  %xmm2,-0x10(%rbp)
movss  -0xc(%rbp),%xmm0
ucomiss -0x10(%rbp),%xmm0
jne    1141 <scale+0x31>
jp     1141 <scale+0x31>
jmp    11bf <scale+0xaf>
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    118b <scale+0x7b>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0xc(%rbp),%xmm0
subss  -0x10(%rbp),%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c9 <scale+0xb9>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x10(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
mov    $0xa,%edi
call   1030 <pow@plt>
movaps %xmm0,%xmm1
movss  -0x18(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11c9 <scale+0xb9>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scale>:
push   %rax
ucomiss %xmm2,%xmm1
jne    1118 <scale+0x8>
jnp    1161 <scale+0x51>
movss  %xmm0,0x4(%rsp)
movaps %xmm1,%xmm0
subss  %xmm2,%xmm0
xorps  %xmm3,%xmm3
ucomiss %xmm3,%xmm0
jbe    1143 <scale+0x33>
mov    $0xa,%edi
call   1030 <pow@plt>
movss  0x4(%rsp),%xmm1
mulss  %xmm0,%xmm1
jmp    115e <scale+0x4e>
subss  %xmm1,%xmm2
mov    $0xa,%edi
movaps %xmm2,%xmm0
call   1030 <pow@plt>
movss  0x4(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @scale(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
store float %0, float* %5
store float %1, float* %6
store float %2, float* %7
%8 = load float, float* %6
%9 = load float, float* %7
%10 = fcmp une float %8, %9
br i1 %10, label %11, label %30
11: ; preds = %3
%12 = load float, float* %6
%13 = load float, float* %7
%14 = fsub float %12, %13
%15 = fcmp ogt float %14, 0.000000e+00
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load float, float* %5
%18 = load float, float* %6
%19 = load float, float* %7
%20 = fsub float %18, %19
%21 = call float @pow(i32 10, float %20)
%22 = fmul float %17, %21
store float %22, float* %4
br label %32
23: ; preds = %11
%24 = load float, float* %5
%25 = load float, float* %7
%26 = load float, float* %6
%27 = fsub float %25, %26
%28 = call float @pow(i32 10, float %27)
%29 = fdiv float %24, %28
store float %29, float* %4
br label %32
30: ; preds = %3
%31 = load float, float* %5
store float %31, float* %4
br label %32
32: ; preds = %30, %23, %16
%33 = load float, float* %4
ret float %33
}

LLVM IR (-O2):
define float @scale(float %0, float %1, float %2) {
%4 = fcmp une float %1, %2
br i1 %4, label %5, label %15
5: ; preds = %3
%6 = fsub float %1, %2
%7 = fcmp ogt float %6, 0.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = tail call float @pow(i32 10, float %6)
%10 = fmul float %9, %0
br label %15
11: ; preds = %5
%12 = fsub float %2, %1
%13 = tail call float @pow(i32 10, float %12)
%14 = fdiv float %0, %13
br label %15
15: ; preds = %3, %11, %8
%16 = phi float [ %10, %8 ], [ %14, %11 ], [ %0, %3 ]
ret float %16
}