#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 *, ...);
char *recent_snow_to_ss(char *target, double r) {
  int i;
  i = (int)(r * 1000.0 + 0.5);
  if (i == 0) {
    sprintf(target, "00");
  } else if (i < 0) {
    sprintf(target, "97");
  } else if (i < 7) {
    sprintf(target, "%02d", i + 90);
  } else if (i < 600) {
    sprintf(target, "%02d", i / 10);
  } else if (i <= 4000) {
    sprintf(target, "%02d", 50 + i / 100);
  } else if (i > 4000) {
    sprintf(target, "98");
  } else {
    sprintf(target, "99");
  }
  return target;
}


x86 assembly (clang, -O0):
<recent_snow_to_ss>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xed2(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xece(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1166 <recent_snow_to_ss+0x56>
mov    -0x8(%rbp),%rdi
lea    0xeb6(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1262 <recent_snow_to_ss+0x152>
cmpl   $0x0,-0x14(%rbp)
jge    1187 <recent_snow_to_ss+0x77>
mov    -0x8(%rbp),%rdi
lea    0xe98(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    125d <recent_snow_to_ss+0x14d>
cmpl   $0x7,-0x14(%rbp)
jge    11ae <recent_snow_to_ss+0x9e>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
add    $0x5a,%edx
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1258 <recent_snow_to_ss+0x148>
cmpl   $0x258,-0x14(%rbp)
jge    11df <recent_snow_to_ss+0xcf>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1253 <recent_snow_to_ss+0x143>
cmpl   $0xfa0,-0x14(%rbp)
jg     1213 <recent_snow_to_ss+0x103>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
add    $0x32,%edx
lea    0xe0f(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    124e <recent_snow_to_ss+0x13e>
cmpl   $0xfa0,-0x14(%rbp)
jle    1237 <recent_snow_to_ss+0x127>
mov    -0x8(%rbp),%rdi
lea    0xdf0(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1249 <recent_snow_to_ss+0x139>
mov    -0x8(%rbp),%rdi
lea    0xddc(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    124e <recent_snow_to_ss+0x13e>
jmp    1253 <recent_snow_to_ss+0x143>
jmp    1258 <recent_snow_to_ss+0x148>
jmp    125d <recent_snow_to_ss+0x14d>
jmp    1262 <recent_snow_to_ss+0x152>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recent_snow_to_ss>:
push   %rbx
mulsd  0xee7(%rip),%xmm0
addsd  0xee7(%rip),%xmm0
mov    %rdi,%rbx
cvttsd2si %xmm0,%edx
test   %edx,%edx
je     1138 <recent_snow_to_ss+0x28>
js     1143 <recent_snow_to_ss+0x33>
cmp    $0x6,%edx
ja     114e <recent_snow_to_ss+0x3e>
add    $0x5a,%edx
jmp    117e <recent_snow_to_ss+0x6e>
movb   $0x0,0x2(%rbx)
movw   $0x3030,(%rbx)
jmp    118f <recent_snow_to_ss+0x7f>
movb   $0x0,0x2(%rbx)
movw   $0x3739,(%rbx)
jmp    118f <recent_snow_to_ss+0x7f>
cmp    $0x257,%edx
ja     1164 <recent_snow_to_ss+0x54>
movzwl %dx,%eax
imul   $0xcccd,%eax,%edx
shr    $0x13,%edx
jmp    117e <recent_snow_to_ss+0x6e>
cmp    $0xfa0,%edx
ja     1194 <recent_snow_to_ss+0x84>
movzwl %dx,%eax
shr    $0x2,%eax
imul   $0x147b,%eax,%edx
shr    $0x11,%edx
add    $0x32,%edx
lea    0xe91(%rip),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <sprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret
movb   $0x0,0x2(%rbx)
movw   $0x3839,(%rbx)
jmp    118f <recent_snow_to_ss+0x7f>

LLVM IR (-O0):
@.str = [3 x i8] c"00\00"
@.str.1 = [3 x i8] c"97\00"
@.str.2 = [5 x i8] c"%02d\00"
@.str.3 = [3 x i8] c"98\00"
@.str.4 = [3 x i8] c"99\00"
define i8* @recent_snow_to_ss(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 i32, i32* %5
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %59
14: ; preds = %2
%15 = load i32, i32* %5
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = call i32 (i8*, i8*, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %58
20: ; preds = %14
%21 = load i32, i32* %5
%22 = icmp slt i32 %21, 7
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i8*, i8** %3
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 90
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %26)
br label %57
28: ; preds = %20
%29 = load i32, i32* %5
%30 = icmp slt i32 %29, 600
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i8*, i8** %3
%33 = load i32, i32* %5
%34 = sdiv i32 %33, 10
%35 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %34)
br label %56
36: ; preds = %28
%37 = load i32, i32* %5
%38 = icmp sle i32 %37, 4000
br i1 %38, label %39, label %45
39: ; preds = %36
%40 = load i8*, i8** %3
%41 = load i32, i32* %5
%42 = sdiv i32 %41, 100
%43 = add nsw i32 50, %42
%44 = call i32 (i8*, i8*, ...) @sprintf(i8* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %43)
br label %55
45: ; preds = %36
%46 = load i32, i32* %5
%47 = icmp sgt i32 %46, 4000
br i1 %47, label %48, label %51
48: ; preds = %45
%49 = load i8*, i8** %3
%50 = call i32 (i8*, i8*, ...) @sprintf(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %54
51: ; preds = %45
%52 = load i8*, i8** %3
%53 = call i32 (i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %51, %48
br label %55
55: ; preds = %54, %39
br label %56
56: ; preds = %55, %31
br label %57
57: ; preds = %56, %23
br label %58
58: ; preds = %57, %17
br label %59
59: ; preds = %58, %11
%60 = load i8*, i8** %3
ret i8* %60
}

LLVM IR (-O2):
@.str = [3 x i8] c"00\00"
@.str.1 = [3 x i8] c"97\00"
@.str.2 = [5 x i8] c"%02d\00"
@.str.3 = [3 x i8] c"98\00"
define i8* @recent_snow_to_ss(i8* returned writeonly %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 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %0, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i64 3, i1 false)
br label %31
7: ; preds = %2
%8 = icmp slt i32 %4, 0
br i1 %8, label %9, label %10
9: ; preds = %7
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %0, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i64 3, i1 false)
br label %31
10: ; preds = %7
%11 = icmp ult i32 %4, 7
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = add nuw nsw i32 %4, 90
%14 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %31
15: ; preds = %10
%16 = icmp ult i32 %4, 600
br i1 %16, label %17, label %22
17: ; preds = %15
%18 = trunc i32 %4 to i16
%19 = udiv i16 %18, 10
%20 = zext i16 %19 to i32
%21 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %31
22: ; preds = %15
%23 = icmp ult i32 %4, 4001
br i1 %23, label %24, label %30
24: ; preds = %22
%25 = trunc i32 %4 to i16
%26 = udiv i16 %25, 100
%27 = add nuw nsw i16 %26, 50
%28 = zext i16 %27 to i32
%29 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %31
30: ; preds = %22
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(3) %0, i8* align 1 dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 3, i1 false)
br label %31
31: ; preds = %9, %17, %30, %24, %12, %6
ret i8* %0
}