#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 */
int Int_Power(double, int);
float scaled2flt(int scale_factor, int scale_value) {
  if (scale_factor == 0)
    return (float)scale_value;
  if (scale_factor < 0)
    return scale_value * Int_Power(10.0, -scale_factor);
  return scale_value / Int_Power(10.0, scale_factor);
}


x86 assembly (clang, -O0):
<scaled2flt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1137 <scaled2flt+0x27>
cvtsi2ssl -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1196 <scaled2flt+0x86>
cmpl   $0x0,-0x8(%rbp)
jge    116f <scaled2flt+0x5f>
mov    -0xc(%rbp),%eax
mov    %eax,-0x10(%rbp)
xor    %edi,%edi
sub    -0x8(%rbp),%edi
movsd  0xeac(%rip),%xmm0
call   1030 <Int_Power@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%eax
imul   %ecx,%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    1196 <scaled2flt+0x86>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
movsd  0xe80(%rip),%xmm0
call   1030 <Int_Power@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scaled2flt>:
push   %rbx
mov    %esi,%ebx
test   %edi,%edi
je     1143 <scaled2flt+0x33>
js     1131 <scaled2flt+0x21>
movsd  0xedf(%rip),%xmm0
call   1030 <Int_Power@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %eax,%ebx
jmp    1143 <scaled2flt+0x33>
neg    %edi
movsd  0xec5(%rip),%xmm0
call   1030 <Int_Power@plt>
imul   %eax,%ebx
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
pop    %rbx
ret

LLVM IR (-O0):
define float @scaled2flt(i32 %0, i32 %1) {
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* %5
%10 = sitofp i32 %9 to float
store float %10, float* %3
br label %27
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = sub nsw i32 0, %16
%18 = call i32 @Int_Power(double 1.000000e+01, i32 %17)
%19 = mul nsw i32 %15, %18
%20 = sitofp i32 %19 to float
store float %20, float* %3
br label %27
21: ; preds = %11
%22 = load i32, i32* %5
%23 = load i32, i32* %4
%24 = call i32 @Int_Power(double 1.000000e+01, i32 %23)
%25 = sdiv i32 %22, %24
%26 = sitofp i32 %25 to float
store float %26, float* %3
br label %27
27: ; preds = %21, %14, %8
%28 = load float, float* %3
ret float %28
}

LLVM IR (-O2):
define float @scaled2flt(i32 %0, i32 %1) {
%3 = icmp eq i32 %0, 0
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = icmp slt i32 %0, 0
br i1 %5, label %6, label %10
6: ; preds = %4
%7 = sub nsw i32 0, %0
%8 = tail call i32 @Int_Power(double 1.000000e+01, i32 %7)
%9 = mul nsw i32 %8, %1
br label %13
10: ; preds = %4
%11 = tail call i32 @Int_Power(double 1.000000e+01, i32 %0)
%12 = sdiv i32 %1, %11
br label %13
13: ; preds = %2, %10, %6
%14 = phi i32 [ %9, %6 ], [ %12, %10 ], [ %1, %2 ]
%15 = sitofp i32 %14 to float
ret float %15
}