#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 *, int, int);
int f_scale(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, "scale=%d,%d", dec, bin);
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_scale>:
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_scale+0x34>
movl   $0x0,-0x4(%rbp)
jmp    1194 <f_scale+0x74>
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    118d <f_scale+0x6d>
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%ecx
lea    0xe78(%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_scale>:
push   %rbx
sub    $0x20,%rsp
test   %edi,%edi
js     1167 <f_scale+0x47>
mov    %r8,%rbx
lea    0x18(%rsp),%rax
lea    0x10(%rsp),%rdx
lea    0xc(%rsp),%rcx
lea    0x14(%rsp),%r8
mov    %rsi,%rdi
mov    %rax,%rsi
call   1030 <scaling@plt>
test   %rax,%rax
jne    1167 <f_scale+0x47>
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
lea    0xea1(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"scale=%d,%d\00"
define i32 @f_scale(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 %31
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 %30
25: ; preds = %21
%26 = load i8*, i8** %12
%27 = load i32, i32* %14
%28 = load i32, i32* %15
%29 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %28)
br label %30
30: ; preds = %25, %21
store i32 0, i32* %7
br label %31
31: ; preds = %30, %20
%32 = load i32, i32* %7
ret i32 %32
}

LLVM IR (-O2):
@.str = [12 x i8] c"scale=%d,%d\00"
define i32 @f_scale(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 %23, 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 %23
19: ; preds = %16
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %20, i32 %21)
br label %23
23: ; preds = %16, %19, %6
ret i32 0
}