#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 /*<<< orphan*/ sprintf(char *, char *, short, ...);
void lingot_config_scale_format_shift(char *char_buffer, double cents,
                                      short int numerator,
                                      short int denominator) {
  if (numerator < 0) {
    sprintf(char_buffer, "%0.4lf", cents);
  } else {
    sprintf(char_buffer, "%hd/%hd", numerator, denominator);
  }
}


x86 assembly (clang, -O0):
<lingot_config_scale_format_shift>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %si,%cx
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
mov    %cx,-0x12(%rbp)
mov    %ax,-0x14(%rbp)
movswl -0x12(%rbp),%eax
cmp    $0x0,%eax
jge    115f <lingot_config_scale_format_shift+0x4f>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
cvttsd2si %xmm0,%eax
lea    0xeb0(%rip),%rsi
movswl %ax,%edx
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    117c <lingot_config_scale_format_shift+0x6c>
mov    -0x8(%rbp),%rdi
mov    -0x12(%rbp),%ax
movswl -0x14(%rbp),%ecx
lea    0xe95(%rip),%rsi
movswl %ax,%edx
mov    $0x0,%al
call   1030 <sprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lingot_config_scale_format_shift>:
test   %si,%si
js     1129 <lingot_config_scale_format_shift+0x19>
movswl %dx,%ecx
movswl %si,%edx
lea    0xee5(%rip),%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>
cvttsd2si %xmm0,%eax
movswl %ax,%edx
lea    0xec9(%rip),%rsi
xor    %eax,%eax
jmp    1030 <sprintf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%0.4lf\00"
@.str.1 = [8 x i8] c"%hd/%hd\00"
define void @lingot_config_scale_format_shift(i8* %0, double %1, i16 signext %2, i16 signext %3) {
%5 = alloca i8*
%6 = alloca double
%7 = alloca i16
%8 = alloca i16
store i8* %0, i8** %5
store double %1, double* %6
store i16 %2, i16* %7
store i16 %3, i16* %8
%9 = load i16, i16* %7
%10 = sext i16 %9 to i32
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %4
%13 = load i8*, i8** %5
%14 = load double, double* %6
%15 = fptosi double %14 to i16
%16 = call i32 (i8*, i8*, i16, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i16 signext %15)
br label %23
17: ; preds = %4
%18 = load i8*, i8** %5
%19 = load i16, i16* %7
%20 = load i16, i16* %8
%21 = sext i16 %20 to i32
%22 = call i32 (i8*, i8*, i16, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i16 signext %19, i32 %21)
br label %23
23: ; preds = %17, %12
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%0.4lf\00"
@.str.1 = [8 x i8] c"%hd/%hd\00"
define void @lingot_config_scale_format_shift(i8* nocapture writeonly %0, double %1, i16 signext %2, i16 signext %3) {
%5 = icmp slt i16 %2, 0
br i1 %5, label %6, label %9
6: ; preds = %4
%7 = fptosi double %1 to i16
%8 = tail call i32 (i8*, i8*, i16, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i16 signext %7)
br label %12
9: ; preds = %4
%10 = sext i16 %3 to i32
%11 = tail call i32 (i8*, i8*, i16, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i16 signext %2, i32 %10)
br label %12
12: ; preds = %9, %6
ret void
}