#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_hh(char *target, double h) {
  int ih = (int)h;
  if (ih <= 1500) {
    sprintf(target, "%02d", ih / 30);
  } else if (ih <= 9000) {
    if (ih < 1800) {
      strcpy(target, "50");
    } else {
      sprintf(target, "%2d", (ih / 300) + 50);
    }
  } else if (ih <= 21000) {
    sprintf(target, "%2d", (ih / 500) + 50);
  } else {
    strcpy(target, "89");
  }
  return target;
}


x86 assembly (clang, -O0):
<m_to_hh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x5dc,-0x14(%rbp)
jg     1168 <m_to_hh+0x48>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    $0x1e,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xea2(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1208 <m_to_hh+0xe8>
cmpl   $0x2328,-0x14(%rbp)
jg     11bc <m_to_hh+0x9c>
cmpl   $0x708,-0x14(%rbp)
jge    1197 <m_to_hh+0x77>
mov    -0x8(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strcpy@plt>
jmp    11b7 <m_to_hh+0x97>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    $0x12c,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
add    $0x32,%edx
lea    0xe56(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1203 <m_to_hh+0xe3>
cmpl   $0x5208,-0x14(%rbp)
jg     11ee <m_to_hh+0xce>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    $0x1f4,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
add    $0x32,%edx
lea    0xe24(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11fe <m_to_hh+0xde>
mov    -0x8(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1030 <strcpy@plt>
jmp    1203 <m_to_hh+0xe3>
jmp    1208 <m_to_hh+0xe8>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m_to_hh>:
push   %rbx
mov    %rdi,%rbx
cvttsd2si %xmm0,%eax
cmp    $0x5dc,%eax
jg     115a <m_to_hh+0x3a>
movslq %eax,%rcx
imul   $0xffffffff88888889,%rcx,%rdx
shr    $0x20,%rdx
add    %eax,%edx
mov    %edx,%eax
shr    $0x1f,%eax
sar    $0x4,%edx
add    %eax,%edx
lea    0xeb0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
jmp    11bb <m_to_hh+0x9b>
cmp    $0x2328,%eax
ja     1171 <m_to_hh+0x51>
cmp    $0x707,%eax
ja     1189 <m_to_hh+0x69>
lea    0xe96(%rip),%rsi
jmp    11b3 <m_to_hh+0x93>
cmp    $0x5208,%eax
ja     11ac <m_to_hh+0x8c>
movzwl %ax,%eax
shr    $0x2,%eax
imul   $0x20c5,%eax,%edx
shr    $0x14,%edx
jmp    1198 <m_to_hh+0x78>
movzwl %ax,%eax
shr    $0x2,%eax
imul   $0x6d3b,%eax,%edx
shr    $0x15,%edx
add    $0x32,%edx
lea    0xe66(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
jmp    11bb <m_to_hh+0x9b>
lea    0xe59(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02d\00"
@.str.1 = [3 x i8] c"50\00"
@.str.2 = [4 x i8] c"%2d\00"
@.str.3 = [3 x i8] c"89\00"
define i8* @m_to_hh(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 = fptosi double %6 to i32
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp sle i32 %8, 1500
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = sdiv i32 %12, 30
%14 = call i32 @sprintf(i8* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %45
15: ; preds = %2
%16 = load i32, i32* %5
%17 = icmp sle i32 %16, 9000
br i1 %17, label %18, label %31
18: ; preds = %15
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 1800
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i8*, i8** %3
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %30
24: ; preds = %18
%25 = load i8*, i8** %3
%26 = load i32, i32* %5
%27 = sdiv i32 %26, 300
%28 = add nsw i32 %27, 50
%29 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %24, %21
br label %44
31: ; preds = %15
%32 = load i32, i32* %5
%33 = icmp sle i32 %32, 21000
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = load i8*, i8** %3
%36 = load i32, i32* %5
%37 = sdiv i32 %36, 500
%38 = add nsw i32 %37, 50
%39 = call i32 @sprintf(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %43
40: ; preds = %31
%41 = load i8*, i8** %3
%42 = call i32 @strcpy(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %43
43: ; preds = %40, %34
br label %44
44: ; preds = %43, %30
br label %45
45: ; preds = %44, %10
%46 = load i8*, i8** %3
ret i8* %46
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02d\00"
@.str.1 = [3 x i8] c"50\00"
@.str.2 = [4 x i8] c"%2d\00"
@.str.3 = [3 x i8] c"89\00"
define i8* @m_to_hh(i8* returned %0, double %1) {
%3 = fptosi double %1 to i32
%4 = icmp slt i32 %3, 1501
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = sdiv i32 %3, 30
%7 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %30
8: ; preds = %2
%9 = icmp ult i32 %3, 9001
br i1 %9, label %10, label %20
10: ; preds = %8
%11 = icmp ult i32 %3, 1800
br i1 %11, label %12, label %14
12: ; preds = %10
%13 = tail call i32 @strcpy(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %30
14: ; preds = %10
%15 = trunc i32 %3 to i16
%16 = udiv i16 %15, 300
%17 = add nuw nsw i16 %16, 50
%18 = zext i16 %17 to i32
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %30
20: ; preds = %8
%21 = icmp ult i32 %3, 21001
br i1 %21, label %22, label %28
22: ; preds = %20
%23 = trunc i32 %3 to i16
%24 = udiv i16 %23, 500
%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 ([4 x i8], [4 x i8]* @.str.2, 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.3, i64 0, i64 0))
br label %30
30: ; preds = %14, %12, %28, %22, %5
ret i8* %0
}