#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
double strtod(char const *, char **);
unsigned long get_duration(const char *str) {
  char *e;
  double t = strtod(str, &e);
  switch (*e) {
  case 'd':
  case 'D':
    t *= 24.0;
  case 'h':
  case 'H':
    t *= 60.0;
  case 'm':
  case 'M':
    t *= 60.0;
  case 's':
  case 'S':
  case 0:
    return (unsigned long)t;
  default:
    fprintf(stderr, "Invalid size %s\n", e);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<get_duration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <strtod@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
test   %eax,%eax
je     1223 <get_duration+0xf3>
jmp    1165 <get_duration+0x35>
mov    -0x1c(%rbp),%eax
sub    $0x44,%eax
je     11ed <get_duration+0xbd>
jmp    1176 <get_duration+0x46>
mov    -0x1c(%rbp),%eax
sub    $0x48,%eax
je     11ff <get_duration+0xcf>
jmp    1187 <get_duration+0x57>
mov    -0x1c(%rbp),%eax
sub    $0x4d,%eax
je     1211 <get_duration+0xe1>
jmp    1198 <get_duration+0x68>
mov    -0x1c(%rbp),%eax
sub    $0x53,%eax
je     1223 <get_duration+0xf3>
jmp    11a9 <get_duration+0x79>
mov    -0x1c(%rbp),%eax
sub    $0x64,%eax
je     11ed <get_duration+0xbd>
jmp    11ba <get_duration+0x8a>
mov    -0x1c(%rbp),%eax
sub    $0x68,%eax
je     11ff <get_duration+0xcf>
jmp    11cb <get_duration+0x9b>
mov    -0x1c(%rbp),%eax
sub    $0x6d,%eax
je     1211 <get_duration+0xe1>
jmp    11dc <get_duration+0xac>
mov    -0x1c(%rbp),%eax
sub    $0x73,%eax
je     1223 <get_duration+0xf3>
jmp    1254 <get_duration+0x124>
movsd  0xe0b(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe01(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xdef(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xde0(%rip),%xmm2
movaps %xmm0,%xmm1
subsd  %xmm2,%xmm1
cvttsd2si %xmm1,%rcx
cvttsd2si %xmm0,%rax
mov    %rax,%rdx
sar    $0x3f,%rdx
and    %rdx,%rcx
or     %rcx,%rax
add    $0x20,%rsp
pop    %rbp
ret
mov    0x2d85(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xdb0(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<get_duration>:
push   %rax
mov    %rsp,%rsi
call   1030 <strtod@plt>
mov    (%rsp),%rdx
movsbl (%rdx),%ecx
lea    -0x44(%rcx),%eax
cmp    $0x2f,%eax
ja     1191 <get_duration+0x61>
lea    0xec9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mulsd  0xea0(%rip),%xmm0
mulsd  0xea0(%rip),%xmm0
mulsd  0xe98(%rip),%xmm0
cvttsd2si %xmm0,%rcx
mov    %rcx,%rdx
sar    $0x3f,%rdx
subsd  0xe8c(%rip),%xmm0
cvttsd2si %xmm0,%rax
and    %rdx,%rax
or     %rcx,%rax
pop    %rcx
ret
test   %ecx,%ecx
je     1170 <get_duration+0x40>
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
lea    0xf33(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [17 x i8] c"Invalid size %s\0A\00"
define i64 @get_duration(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca double
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call double @strtod(i8* %5, i8** %3)
store double %6, double* %4
%7 = load i8*, i8** %3
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %22 [
i32 100, label %10
i32 68, label %10
i32 104, label %13
i32 72, label %13
i32 109, label %16
i32 77, label %16
i32 115, label %19
i32 83, label %19
i32 0, label %19
]
10: ; preds = %1, %1
%11 = load double, double* %4
%12 = fmul double %11, 2.400000e+01
store double %12, double* %4
br label %13
13: ; preds = %1, %1, %10
%14 = load double, double* %4
%15 = fmul double %14, 6.000000e+01
store double %15, double* %4
br label %16
16: ; preds = %1, %1, %13
%17 = load double, double* %4
%18 = fmul double %17, 6.000000e+01
store double %18, double* %4
br label %19
19: ; preds = %1, %1, %1, %16
%20 = load double, double* %4
%21 = fptoui double %20 to i64
ret i64 %21
22: ; preds = %1
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %3
%25 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [17 x i8] c"Invalid size %s\0A\00"
define i64 @get_duration(i8* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call double @strtod(i8* %0, i8** %2)
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
switch i32 %7, label %19 [
i32 100, label %8
i32 68, label %8
i32 104, label %10
i32 72, label %10
i32 109, label %13
i32 77, label %13
i32 115, label %16
i32 83, label %16
i32 0, label %16
]
8: ; preds = %1, %1
%9 = fmul double %4, 2.400000e+01
br label %10
10: ; preds = %1, %1, %8
%11 = phi double [ %4, %1 ], [ %4, %1 ], [ %9, %8 ]
%12 = fmul double %11, 6.000000e+01
br label %13
13: ; preds = %1, %1, %10
%14 = phi double [ %4, %1 ], [ %4, %1 ], [ %12, %10 ]
%15 = fmul double %14, 6.000000e+01
br label %16
16: ; preds = %1, %1, %1, %13
%17 = phi double [ %4, %1 ], [ %4, %1 ], [ %4, %1 ], [ %15, %13 ]
%18 = fptoui double %17 to i64
ret i64 %18
19: ; preds = %1
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %5)
%22 = tail call i32 @exit(i32 1)
unreachable
}