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


x86 assembly (clang, -O0):
<flt2scaled>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
movss  %xmm0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1137 <flt2scaled+0x27>
cvttss2si -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <flt2scaled+0x92>
cmpl   $0x0,-0x8(%rbp)
jle    1173 <flt2scaled+0x63>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
movsd  0xeaa(%rip),%xmm0
call   1030 <Int_Power@plt>
movaps %xmm0,%xmm1
movss  -0x10(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
jmp    11a2 <flt2scaled+0x92>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
xor    %edi,%edi
sub    -0x8(%rbp),%edi
movsd  0xe76(%rip),%xmm0
call   1030 <Int_Power@plt>
movaps %xmm0,%xmm1
movss  -0x14(%rbp),%xmm0
divss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<flt2scaled>:
push   %rax
test   %edi,%edi
je     1152 <flt2scaled+0x42>
movss  %xmm0,0x4(%rsp)
jle    1136 <flt2scaled+0x26>
movsd  0xedb(%rip),%xmm0
call   1030 <Int_Power@plt>
movss  0x4(%rsp),%xmm1
mulss  %xmm0,%xmm1
jmp    114f <flt2scaled+0x3f>
neg    %edi
movsd  0xec0(%rip),%xmm0
call   1030 <Int_Power@plt>
movss  0x4(%rsp),%xmm1
divss  %xmm0,%xmm1
movaps %xmm1,%xmm0
cvttss2si %xmm0,%eax
pop    %rcx
ret

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

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