#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__ scaling(unsigned char **, double *, int *, int *, int *);
int /*<<< orphan*/ sprintf(char *, char *, double, int, int, int);
int f_scaling(int mode, unsigned char **sec, float *data, unsigned int ndata,
              char *inv_out, void **local) {
  int dec, bin, nbits;
  double base;
  if (mode < 0)
    return 0;
  if (scaling(sec, &base, &dec, &bin, &nbits) == 0) {
    sprintf(inv_out, "scaling ref=%g dec_scale=%d bin_scale=%d nbits=%d", base,
            dec, bin, nbits);
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_scaling>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1154 <f_scaling+0x34>
movl   $0x0,-0x4(%rbp)
jmp    119d <f_scaling+0x7d>
mov    -0x10(%rbp),%rdi
lea    -0x48(%rbp),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x3c(%rbp),%r8
call   1030 <scaling@plt>
cmp    $0x0,%rax
jne    1196 <f_scaling+0x76>
mov    -0x28(%rbp),%rdi
movsd  -0x48(%rbp),%xmm0
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
lea    0xe6f(%rip),%rsi
call   1040 <sprintf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_scaling>:
push   %rbx
sub    $0x20,%rsp
test   %edi,%edi
js     1172 <f_scaling+0x52>
mov    %r8,%rbx
lea    0x18(%rsp),%rax
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <scaling@plt>
test   %rax,%rax
jne    1172 <f_scaling+0x52>
movsd  0x18(%rsp),%xmm0
mov    0x14(%rsp),%edx
mov    0x10(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0xe96(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [50 x i8] c"scaling ref=%g dec_scale=%d bin_scale=%d nbits=%d\00"
define i32 @f_scaling(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8**
%10 = alloca float*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8**
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
store i32 %0, i32* %8
store i8** %1, i8*** %9
store float* %2, float** %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i8** %5, i8*** %13
%18 = load i32, i32* %8
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %6
store i32 0, i32* %7
br label %33
21: ; preds = %6
%22 = load i8**, i8*** %9
%23 = call i64 @scaling(i8** %22, double* %17, i32* %14, i32* %15, i32* %16)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load i8*, i8** %12
%27 = load double, double* %17
%28 = load i32, i32* %14
%29 = load i32, i32* %15
%30 = load i32, i32* %16
%31 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %27, i32 %28, i32 %29, i32 %30)
br label %32
32: ; preds = %25, %21
store i32 0, i32* %7
br label %33
33: ; preds = %32, %20
%34 = load i32, i32* %7
ret i32 %34
}

LLVM IR (-O2):
@.str = [50 x i8] c"scaling ref=%g dec_scale=%d bin_scale=%d nbits=%d\00"
define i32 @f_scaling(i32 %0, i8** %1, float* nocapture readnone %2, i32 %3, i8* nocapture writeonly %4, i8** nocapture readnone %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = bitcast i32* %7 to i8*
%12 = bitcast i32* %8 to i8*
%13 = bitcast i32* %9 to i8*
%14 = bitcast double* %10 to i8*
%15 = icmp slt i32 %0, 0
br i1 %15, label %25, label %16
16: ; preds = %6
%17 = call i64 @scaling(i8** %1, double* %10, i32* %7, i32* %8, i32* %9)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load double, double* %10
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = load i32, i32* %9
%24 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), double %20, i32 %21, i32 %22, i32 %23)
br label %25
25: ; preds = %16, %19, %6
ret i32 0
}