#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 */
typedef float price;
typedef float numr;

/* Variables and functions */
scalar_t__ pow(double, float);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
char *price_to_str(float price, int *numorator, int *demoninator, int *decimal,
                   char *fltfmt) {
  static char rtn[64];
  int whole = (int)price;
  float dec = ((price) - (float)(int)(price)), numr;
  if (fltfmt) {
    sprintf(rtn, fltfmt, price);
    *numorator = *demoninator = *decimal = 0;
    return rtn;
  }
  numr = dec * 256;
  {
    float rdec = ((numr) - (float)(int)(numr));
    if (rdec < ((1.0 / 256.0) / 2.0))
      ;
    else if ((1 - rdec) < ((1.0 / 256.0) / 2.0))
      ++numr;
    else {
      sprintf(rtn, "%f", price);
      *numorator = *demoninator = *decimal = 0;
      return rtn;
    }
  }
  if (numr != 0) {
    int cnt = 8;
    while ((float)(numr) / 2.0 == (float)(int)(numr / 2)) {
      numr /= 2;
      --cnt;
    }
    if (whole < 0 && numr < 0.0)
      numr = -numr;
    *numorator = (int)numr;
    *demoninator = (int)pow(2.0, (float)cnt);
    *decimal = whole;
    sprintf(rtn, "%d %d/%d", whole, (int)numr, *demoninator);
  } else {
    *numorator = *demoninator = 0;
    *decimal = whole;
    sprintf(rtn, "%d", whole);
  }
  return rtn;
}


x86 assembly (clang, -O0):
<price_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movss  %xmm0,-0xc(%rbp)
mov    %rdi,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    %rdx,-0x28(%rbp)
mov    %rcx,-0x30(%rbp)
cvttss2si -0xc(%rbp),%eax
mov    %eax,-0x34(%rbp)
movss  -0xc(%rbp),%xmm0
cvttss2si -0xc(%rbp),%eax
cvtsi2ss %eax,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11ac <price_to_str+0x8c>
mov    -0x30(%rbp),%rsi
cvttss2si -0xc(%rbp),%edx
lea    0x2ec9(%rip),%rdi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
lea    0x2e9d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    13d3 <price_to_str+0x2b3>
movss  0xe5c(%rip),%xmm0
mulss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
movss  -0x3c(%rbp),%xmm0
cvttss2si -0x3c(%rbp),%eax
cvtsi2ss %eax,%xmm1
subss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
movss  -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe1a(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f5 <price_to_str+0xd5>
jmp    127c <price_to_str+0x15c>
movss  0xe17(%rip),%xmm0
subss  -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdf2(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    122f <price_to_str+0x10f>
movss  0xdf4(%rip),%xmm0
addss  -0x3c(%rbp),%xmm0
movss  %xmm0,-0x3c(%rbp)
jmp    1277 <price_to_str+0x157>
cvttss2si -0xc(%rbp),%edx
lea    0x2e05(%rip),%rdi
lea    0xdda(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
lea    0x2dd2(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    13d3 <price_to_str+0x2b3>
jmp    127c <price_to_str+0x15c>
movss  -0x3c(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    1298 <price_to_str+0x178>
jp     1298 <price_to_str+0x178>
jmp    1393 <price_to_str+0x273>
movl   $0x8,-0x44(%rbp)
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xd58(%rip),%xmm1
divsd  %xmm1,%xmm0
movss  -0x3c(%rbp),%xmm1
movss  0xd57(%rip),%xmm2
divss  %xmm2,%xmm1
cvttss2si %xmm1,%eax
cvtsi2ss %eax,%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1305 <price_to_str+0x1e5>
jp     1305 <price_to_str+0x1e5>
movss  -0x3c(%rbp),%xmm0
movss  0xd2a(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    129f <price_to_str+0x17f>
cmpl   $0x0,-0x34(%rbp)
jge    133c <price_to_str+0x21c>
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
xorps  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    133c <price_to_str+0x21c>
movss  -0x3c(%rbp),%xmm0
movd   %xmm0,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm0
movss  %xmm0,-0x3c(%rbp)
cvttss2si -0x3c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
cvtsi2ssl -0x44(%rbp),%xmm1
movsd  0xcb4(%rip),%xmm0
call   1030 <pow@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%edx
cvttss2si -0x3c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    (%rax),%r8d
lea    0x2cc0(%rip),%rdi
lea    0xc98(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
jmp    13c8 <price_to_str+0x2a8>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%edx
lea    0x2c86(%rip),%rdi
lea    0xc64(%rip),%rsi
mov    $0x0,%al
call   1040 <sprintf@plt>
lea    0x2c71(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<price_to_str>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
cvttss2si %xmm0,%ebx
test   %rcx,%rcx
je     1173 <price_to_str+0x53>
lea    0x2eff(%rip),%rdi
mov    %rcx,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <sprintf@plt>
movl   $0x0,(%r15)
movl   $0x0,(%r14)
movl   $0x0,(%r12)
lea    0x2ed6(%rip),%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
cvtsi2ss %ebx,%xmm1
subss  %xmm1,%xmm0
mulss  0xe7d(%rip),%xmm0
cvttps2dq %xmm0,%xmm1
cvtdq2ps %xmm1,%xmm2
movaps %xmm0,%xmm1
subss  %xmm2,%xmm1
movss  0xe6b(%rip),%xmm2
ucomiss %xmm1,%xmm2
ja     11bb <price_to_str+0x9b>
movss  0xe62(%rip),%xmm3
subss  %xmm1,%xmm3
ucomiss %xmm3,%xmm2
jbe    129c <price_to_str+0x17c>
addss  0xe4d(%rip),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jne    11c9 <price_to_str+0xa9>
jnp    126e <price_to_str+0x14e>
mov    $0x9,%eax
movsd  0xe3a(%rip),%xmm2
movss  0xe2e(%rip),%xmm3
xchg   %ax,%ax
movaps %xmm0,%xmm1
xorps  %xmm4,%xmm4
cvtss2sd %xmm0,%xmm4
mulss  %xmm3,%xmm0
cvttps2dq %xmm0,%xmm5
cvtdq2pd %xmm5,%xmm5
mulsd  %xmm2,%xmm4
add    $0xffffffff,%eax
ucomisd %xmm5,%xmm4
jne    1205 <price_to_str+0xe5>
jnp    11e0 <price_to_str+0xc0>
test   %ebx,%ebx
jns    122b <price_to_str+0x10b>
movaps 0xe10(%rip),%xmm0
xorps  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
movaps %xmm1,%xmm3
cmpltss %xmm2,%xmm3
andps  %xmm3,%xmm0
andnps %xmm1,%xmm3
orps   %xmm0,%xmm3
movaps %xmm3,%xmm1
cvttss2si %xmm1,%ebp
mov    %ebp,(%r12)
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
movsd  0xdd6(%rip),%xmm0
call   1030 <pow@plt>
mov    %eax,(%r14)
mov    %ebx,(%r15)
mov    (%r14),%r8d
lea    0x2de9(%rip),%rdi
lea    0xdd5(%rip),%rsi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    1163 <price_to_str+0x43>
movl   $0x0,(%r14)
movl   $0x0,(%r12)
mov    %ebx,(%r15)
lea    0x2db9(%rip),%rdi
lea    0xdab(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <sprintf@plt>
jmp    1163 <price_to_str+0x43>
lea    0x2d9d(%rip),%rdi
lea    0xd86(%rip),%rsi
jmp    1144 <price_to_str+0x24>

LLVM IR (-O0):
@price_to_str.rtn = internal global [64 x i8] zeroinitializer
@.str = [3 x i8] c"%f\00"
@.str.1 = [9 x i8] c"%d %d/%d\00"
@.str.2 = [3 x i8] c"%d\00"
define i8* @price_to_str(float %0, i32* %1, i32* %2, i32* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca float
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca float
%14 = alloca float
%15 = alloca float
%16 = alloca i32
store float %0, float* %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32* %3, i32** %10
store i8* %4, i8** %11
%17 = load float, float* %7
%18 = fptosi float %17 to i32
store i32 %18, i32* %12
%19 = load float, float* %7
%20 = load float, float* %7
%21 = fptosi float %20 to i32
%22 = sitofp i32 %21 to float
%23 = fsub float %19, %22
store float %23, float* %13
%24 = load i8*, i8** %11
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %34
26: ; preds = %5
%27 = load i8*, i8** %11
%28 = load float, float* %7
%29 = fptosi float %28 to i32
%30 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8* %27, i32 %29)
%31 = load i32*, i32** %10
store i32 0, i32* %31
%32 = load i32*, i32** %9
store i32 0, i32* %32
%33 = load i32*, i32** %8
store i32 0, i32* %33
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8** %6
br label %116
34: ; preds = %5
%35 = load float, float* %13
%36 = fmul float %35, 2.560000e+02
store float %36, float* %14
%37 = load float, float* %14
%38 = load float, float* %14
%39 = fptosi float %38 to i32
%40 = sitofp i32 %39 to float
%41 = fsub float %37, %40
store float %41, float* %15
%42 = load float, float* %15
%43 = fpext float %42 to double
%44 = fcmp olt double %43, 0x3F60000000000000
br i1 %44, label %45, label %46
45: ; preds = %34
br label %62
46: ; preds = %34
%47 = load float, float* %15
%48 = fsub float 1.000000e+00, %47
%49 = fpext float %48 to double
%50 = fcmp olt double %49, 0x3F60000000000000
br i1 %50, label %51, label %54
51: ; preds = %46
%52 = load float, float* %14
%53 = fadd float %52, 1.000000e+00
store float %53, float* %14
br label %61
54: ; preds = %46
%55 = load float, float* %7
%56 = fptosi float %55 to i32
%57 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = load i32*, i32** %10
store i32 0, i32* %58
%59 = load i32*, i32** %9
store i32 0, i32* %59
%60 = load i32*, i32** %8
store i32 0, i32* %60
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8** %6
br label %116
61: ; preds = %51
br label %62
62: ; preds = %61, %45
%63 = load float, float* %14
%64 = fcmp une float %63, 0.000000e+00
br i1 %64, label %65, label %108
65: ; preds = %62
store i32 8, i32* %16
br label %66
66: ; preds = %76, %65
%67 = load float, float* %14
%68 = fpext float %67 to double
%69 = fdiv double %68, 2.000000e+00
%70 = load float, float* %14
%71 = fdiv float %70, 2.000000e+00
%72 = fptosi float %71 to i32
%73 = sitofp i32 %72 to float
%74 = fpext float %73 to double
%75 = fcmp oeq double %69, %74
br i1 %75, label %76, label %81
76: ; preds = %66
%77 = load float, float* %14
%78 = fdiv float %77, 2.000000e+00
store float %78, float* %14
%79 = load i32, i32* %16
%80 = add nsw i32 %79, -1
store i32 %80, i32* %16
br label %66
81: ; preds = %66
%82 = load i32, i32* %12
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %91
84: ; preds = %81
%85 = load float, float* %14
%86 = fpext float %85 to double
%87 = fcmp olt double %86, 0.000000e+00
br i1 %87, label %88, label %91
88: ; preds = %84
%89 = load float, float* %14
%90 = fneg float %89
store float %90, float* %14
br label %91
91: ; preds = %88, %84, %81
%92 = load float, float* %14
%93 = fptosi float %92 to i32
%94 = load i32*, i32** %8
store i32 %93, i32* %94
%95 = load i32, i32* %16
%96 = sitofp i32 %95 to float
%97 = call i64 @pow(double 2.000000e+00, float %96)
%98 = trunc i64 %97 to i32
%99 = load i32*, i32** %9
store i32 %98, i32* %99
%100 = load i32, i32* %12
%101 = load i32*, i32** %10
store i32 %100, i32* %101
%102 = load i32, i32* %12
%103 = load float, float* %14
%104 = fptosi float %103 to i32
%105 = load i32*, i32** %9
%106 = load i32, i32* %105
%107 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %102, i32 %104, i32 %106)
br label %115
108: ; preds = %62
%109 = load i32*, i32** %9
store i32 0, i32* %109
%110 = load i32*, i32** %8
store i32 0, i32* %110
%111 = load i32, i32* %12
%112 = load i32*, i32** %10
store i32 %111, i32* %112
%113 = load i32, i32* %12
%114 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %113)
br label %115
115: ; preds = %108, %91
store i8* getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8** %6
br label %116
116: ; preds = %115, %54, %26
%117 = load i8*, i8** %6
ret i8* %117
}

LLVM IR (-O2):
@price_to_str.rtn = internal global [64 x i8] zeroinitializer
@.str = [3 x i8] c"%f\00"
@.str.1 = [9 x i8] c"%d %d/%d\00"
@.str.2 = [3 x i8] c"%d\00"
define i8* @price_to_str(float %0, i32* nocapture writeonly %1, i32* nocapture %2, i32* nocapture writeonly %3, i8* %4) {
%6 = fptosi float %0 to i32
%7 = icmp eq i8* %4, null
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8* %4, i32 %6)
store i32 0, i32* %3
store i32 0, i32* %2
store i32 0, i32* %1
br label %52
10: ; preds = %5
%11 = sitofp i32 %6 to float
%12 = fsub float %0, %11
%13 = fmul float %12, 2.560000e+02
%14 = fptosi float %13 to i32
%15 = sitofp i32 %14 to float
%16 = fsub float %13, %15
%17 = fcmp olt float %16, 0x3F60000000000000
br i1 %17, label %25, label %18
18: ; preds = %10
%19 = fsub float 1.000000e+00, %16
%20 = fcmp olt float %19, 0x3F60000000000000
br i1 %20, label %21, label %23
21: ; preds = %18
%22 = fadd float %13, 1.000000e+00
br label %25
23: ; preds = %18
%24 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 0, i32* %3
store i32 0, i32* %2
store i32 0, i32* %1
br label %52
25: ; preds = %10, %21
%26 = phi float [ %22, %21 ], [ %13, %10 ]
%27 = fcmp une float %26, 0.000000e+00
br i1 %27, label %28, label %50
28: ; preds = %25, %28
%29 = phi float [ %33, %28 ], [ %26, %25 ]
%30 = phi i32 [ %37, %28 ], [ 8, %25 ]
%31 = fpext float %29 to double
%32 = fmul double %31, 5.000000e-01
%33 = fmul float %29, 5.000000e-01
%34 = fptosi float %33 to i32
%35 = sitofp i32 %34 to double
%36 = fcmp oeq double %32, %35
%37 = add nsw i32 %30, -1
br i1 %36, label %28, label %38
38: ; preds = %28
%39 = icmp slt i32 %6, 0
%40 = fcmp olt float %29, 0.000000e+00
%41 = select i1 %39, i1 %40, i1 false
%42 = fneg float %29
%43 = select i1 %41, float %42, float %29
%44 = fptosi float %43 to i32
store i32 %44, i32* %1
%45 = sitofp i32 %30 to float
%46 = tail call i64 @pow(double 2.000000e+00, float %45)
%47 = trunc i64 %46 to i32
store i32 %47, i32* %2
store i32 %6, i32* %3
%48 = load i32, i32* %2
%49 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %44, i32 %48)
br label %52
50: ; preds = %25
store i32 0, i32* %2
store i32 0, i32* %1
store i32 %6, i32* %3
%51 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 %6)
br label %52
52: ; preds = %23, %38, %50, %8
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @price_to_str.rtn, i64 0, i64 0)
}