#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 */
double atof(char *);
int strlen(char *);
double atoft(char *s) {
  char last;
  int len;
  double suff = 1.0;
  len = strlen(s);
  last = s[len - 1];
  s[len - 1] = '\0';
  switch (last) {
  case 'h':
  case 'H':
    suff *= 60;
  case 'm':
  case 'M':
    suff *= 60;
  case 's':
  case 'S':
    suff *= atof(s);
    s[len - 1] = last;
    return suff;
  }
  s[len - 1] = last;
  return atof(s);
}


x86 assembly (clang, -O0):
<atoft>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movabs $0x3ff0000000000000,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0xffffffff,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x48,%eax
je     11d4 <atoft+0xb4>
jmp    117f <atoft+0x5f>
mov    -0x24(%rbp),%eax
sub    $0x4d,%eax
je     11e6 <atoft+0xc6>
jmp    1190 <atoft+0x70>
mov    -0x24(%rbp),%eax
sub    $0x53,%eax
je     11f8 <atoft+0xd8>
jmp    11a1 <atoft+0x81>
mov    -0x24(%rbp),%eax
sub    $0x68,%eax
je     11d4 <atoft+0xb4>
jmp    11b2 <atoft+0x92>
mov    -0x24(%rbp),%eax
sub    $0x6d,%eax
je     11e6 <atoft+0xc6>
jmp    11c3 <atoft+0xa3>
mov    -0x24(%rbp),%eax
sub    $0x73,%eax
je     11f8 <atoft+0xd8>
jmp    122d <atoft+0x10d>
movsd  0xe24(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe12(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124e <atoft+0x12e>
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<atoft>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
call   1040 <strlen@plt>
movslq %eax,%r14
movsbl -0x1(%r14,%rbx,1),%ebp
movb   $0x0,-0x1(%r14,%rbx,1)
mov    %ebp,%eax
add    $0xffffffb8,%eax
cmp    $0x2b,%eax
ja     11b7 <atoft+0x97>
movabs $0x100000001,%rcx
bt     %rax,%rcx
jb     118d <atoft+0x6d>
movabs $0x2000000020,%rcx
bt     %rax,%rcx
jb     1183 <atoft+0x63>
movabs $0x80000000800,%rcx
bt     %rax,%rcx
jae    11b7 <atoft+0x97>
movsd  0xe7f(%rip),%xmm0
jmp    1195 <atoft+0x75>
movsd  0xe7d(%rip),%xmm0
jmp    1195 <atoft+0x75>
movsd  0xe7b(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %rbx,%rdi
call   1030 <atof@plt>
mulsd  0x8(%rsp),%xmm0
mov    %bpl,-0x1(%rbx,%r14,1)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %bpl,-0x1(%rbx,%r14,1)
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <atof@plt>

LLVM IR (-O0):
define double @atoft(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
%6 = alloca double
store i8* %0, i8** %3
store double 1.000000e+00, double* %6
%7 = load i8*, i8** %3
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %5
%11 = sub nsw i32 %10, 1
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %9, i64 %12
%14 = load i8, i8* %13
store i8 %14, i8* %4
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
store i8 0, i8* %19
%20 = load i8, i8* %4
%21 = sext i8 %20 to i32
switch i32 %21, label %40 [
i32 104, label %22
i32 72, label %22
i32 109, label %25
i32 77, label %25
i32 115, label %28
i32 83, label %28
]
22: ; preds = %1, %1
%23 = load double, double* %6
%24 = fmul double %23, 6.000000e+01
store double %24, double* %6
br label %25
25: ; preds = %1, %1, %22
%26 = load double, double* %6
%27 = fmul double %26, 6.000000e+01
store double %27, double* %6
br label %28
28: ; preds = %1, %1, %25
%29 = load i8*, i8** %3
%30 = call double @atof(i8* %29)
%31 = load double, double* %6
%32 = fmul double %31, %30
store double %32, double* %6
%33 = load i8, i8* %4
%34 = load i8*, i8** %3
%35 = load i32, i32* %5
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
store i8 %33, i8* %38
%39 = load double, double* %6
store double %39, double* %2
br label %49
40: ; preds = %1
%41 = load i8, i8* %4
%42 = load i8*, i8** %3
%43 = load i32, i32* %5
%44 = sub nsw i32 %43, 1
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %42, i64 %45
store i8 %41, i8* %46
%47 = load i8*, i8** %3
%48 = call double @atof(i8* %47)
store double %48, double* %2
br label %49
49: ; preds = %40, %28
%50 = load double, double* %2
ret double %50
}

LLVM IR (-O2):
define double @atoft(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -1
%4 = sext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
store i8 0, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %15 [
i32 104, label %8
i32 72, label %8
i32 109, label %9
i32 77, label %9
i32 115, label %11
i32 83, label %11
]
8: ; preds = %1, %1
br label %9
9: ; preds = %1, %1, %8
%10 = phi double [ 6.000000e+01, %1 ], [ 6.000000e+01, %1 ], [ 3.600000e+03, %8 ]
br label %11
11: ; preds = %1, %1, %9
%12 = phi double [ 1.000000e+00, %1 ], [ 1.000000e+00, %1 ], [ %10, %9 ]
%13 = tail call double @atof(i8* %0)
%14 = fmul double %12, %13
store i8 %6, i8* %5
br label %17
15: ; preds = %1
store i8 %6, i8* %5
%16 = tail call double @atof(i8* %0)
br label %17
17: ; preds = %15, %11
%18 = phi double [ %16, %15 ], [ %14, %11 ]
ret double %18
}