#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 *, int);
int /*<<< orphan*/ strcpy(char *, char *);
char *m_to_RR(char *target, double m) {
  int ix;
  ix = (int)(m * 1000.0 + 0.5);
  if (m > 0.4) {
    strcpy(target, "98");
  }
  if (m > 0.0 && m < 0.00065) {
    sprintf(target, "%02d", (int)(m * 10000.0 + 0.5));
  } else if (ix <= 55) {
    sprintf(target, "%02d", ix);
  } else if (ix <= 400) {
    sprintf(target, "%02d", (ix / 10) + 50);
  } else {
    strcpy(target, "99");
  }
  return target;
}


x86 assembly (clang, -O0):
<m_to_RR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeca(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xec6(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe9e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    117c <m_to_RR+0x5c>
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <strcpy@plt>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11d7 <m_to_RR+0xb7>
movsd  0xe82(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d7 <m_to_RR+0xb7>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  0xe6e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe52(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
lea    0xe5e(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1245 <m_to_RR+0x125>
cmpl   $0x37,-0x14(%rbp)
jg     11f9 <m_to_RR+0xd9>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe3c(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1240 <m_to_RR+0x120>
cmpl   $0x190,-0x14(%rbp)
jg     122b <m_to_RR+0x10b>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
add    $0x32,%edx
lea    0xe0a(%rip),%rsi
call   1040 <sprintf@plt>
jmp    123b <m_to_RR+0x11b>
mov    -0x8(%rbp),%rdi
lea    0xdfa(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1240 <m_to_RR+0x120>
jmp    1245 <m_to_RR+0x125>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_to_RR>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
ucomisd 0xee0(%rip),%xmm0
jbe    114d <m_to_RR+0x2d>
lea    0xeef(%rip),%rsi
mov    %rbx,%rdi
movsd  %xmm0,0x8(%rsp)
call   1030 <strcpy@plt>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    117b <m_to_RR+0x5b>
movsd  0xeb9(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    117b <m_to_RR+0x5b>
mulsd  0xeb3(%rip),%xmm0
addsd  0xe93(%rip),%xmm0
cvttsd2si %xmm0,%edx
jmp    11ab <m_to_RR+0x8b>
mulsd  0xe7d(%rip),%xmm0
addsd  0xe7d(%rip),%xmm0
cvttsd2si %xmm0,%edx
cmp    $0x37,%edx
jle    11ab <m_to_RR+0x8b>
cmp    $0x190,%edx
ja     11c3 <m_to_RR+0xa3>
movzwl %dx,%eax
imul   $0xcccd,%eax,%edx
shr    $0x13,%edx
add    $0x32,%edx
lea    0xe79(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
jmp    11ba <m_to_RR+0x9a>

LLVM IR (-O0):
@.str = [3 x i8] c"98\00"
@.str.1 = [5 x i8] c"%02d\00"
@.str.2 = [3 x i8] c"99\00"
define i8* @m_to_RR(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca i32
store i8* %0, i8** %3
store double %1, double* %4
%6 = load double, double* %4
%7 = call double @llvm.fmuladd.f64(double %6, double 1.000000e+03, double 5.000000e-01)
%8 = fptosi double %7 to i32
store i32 %8, i32* %5
%9 = load double, double* %4
%10 = fcmp ogt double %9, 4.000000e-01
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i32 @strcpy(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %11, %2
%15 = load double, double* %4
%16 = fcmp ogt double %15, 0.000000e+00
br i1 %16, label %17, label %26
17: ; preds = %14
%18 = load double, double* %4
%19 = fcmp olt double %18, 0x3F454C985F06F694
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i8*, i8** %3
%22 = load double, double* %4
%23 = call double @llvm.fmuladd.f64(double %22, double 1.000000e+04, double 5.000000e-01)
%24 = fptosi double %23 to i32
%25 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %24)
br label %47
26: ; preds = %17, %14
%27 = load i32, i32* %5
%28 = icmp sle i32 %27, 55
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load i8*, i8** %3
%31 = load i32, i32* %5
%32 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %31)
br label %46
33: ; preds = %26
%34 = load i32, i32* %5
%35 = icmp sle i32 %34, 400
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load i8*, i8** %3
%38 = load i32, i32* %5
%39 = sdiv i32 %38, 10
%40 = add nsw i32 %39, 50
%41 = call i32 @sprintf(i8* %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %40)
br label %45
42: ; preds = %33
%43 = load i8*, i8** %3
%44 = call i32 @strcpy(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %45
45: ; preds = %42, %36
br label %46
46: ; preds = %45, %29
br label %47
47: ; preds = %46, %20
%48 = load i8*, i8** %3
ret i8* %48
}

LLVM IR (-O2):
@.str = [3 x i8] c"98\00"
@.str.1 = [5 x i8] c"%02d\00"
@.str.2 = [3 x i8] c"99\00"
define i8* @m_to_RR(i8* returned %0, double %1) {
%3 = tail call double @llvm.fmuladd.f64(double %1, double 1.000000e+03, double 5.000000e-01)
%4 = fptosi double %3 to i32
%5 = fcmp ogt double %1, 4.000000e-01
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %6, %2
%9 = fcmp ogt double %1, 0.000000e+00
%10 = fcmp olt double %1, 0x3F454C985F06F694
%11 = and i1 %9, %10
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = tail call double @llvm.fmuladd.f64(double %1, double 1.000000e+04, double 5.000000e-01)
%14 = fptosi double %13 to i32
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %14)
br label %30
16: ; preds = %8
%17 = icmp slt i32 %4, 56
br i1 %17, label %18, label %20
18: ; preds = %16
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %4)
br label %30
20: ; preds = %16
%21 = icmp ult i32 %4, 401
br i1 %21, label %22, label %28
22: ; preds = %20
%23 = trunc i32 %4 to i16
%24 = udiv i16 %23, 10
%25 = add nuw nsw i16 %24, 50
%26 = zext i16 %25 to i32
%27 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %30
28: ; preds = %20
%29 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %18, %28, %22, %12
ret i8* %0
}