#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
double strtod(char *, char **);
int toupper(char);
double read_dtime(char *arg, double defaultval) {
  double time = 0.0;
  double val;
  char *p;
  p = arg;
  do {
    val = strtod(p, &p);
    switch (toupper(*p)) {
    case 'Y':
      val *= (60.0 * 60.0 * 24.0 * 365.242199);
      p++;
      break;
    case 'D':
      val *= (60.0 * 60.0 * 24.0);
      p++;
      break;
    case 'H':
      val *= (60.0 * 60.0);
      p++;
      break;
    case 'M':
      val *= (60.0);
      p++;
      break;
    case 'S':
      p++;
      break;
    case '\0':
      break;
    default:
      fprintf(stderr, "Bad time specifier '%s'---using default\n", arg);
      return defaultval;
    }
    time += val;
  } while (*p);
  return time;
}


x86 assembly (clang, -O0):
<read_dtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1040 <strtod@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    %ecx,-0x34(%rbp)
test   %eax,%eax
je     1273 <read_dtime+0x143>
jmp    1181 <read_dtime+0x51>
mov    -0x34(%rbp),%eax
sub    $0x44,%eax
je     11f9 <read_dtime+0xc9>
jmp    1192 <read_dtime+0x62>
mov    -0x34(%rbp),%eax
sub    $0x48,%eax
je     121c <read_dtime+0xec>
jmp    11a3 <read_dtime+0x73>
mov    -0x34(%rbp),%eax
sub    $0x4d,%eax
je     123f <read_dtime+0x10f>
jmp    11b4 <read_dtime+0x84>
mov    -0x34(%rbp),%eax
sub    $0x53,%eax
je     1262 <read_dtime+0x132>
jmp    11c5 <read_dtime+0x95>
mov    -0x34(%rbp),%eax
sub    $0x59,%eax
jne    1278 <read_dtime+0x148>
jmp    11d6 <read_dtime+0xa6>
movsd  0xe3a(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12a0 <read_dtime+0x170>
movsd  0xe0f(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12a0 <read_dtime+0x170>
movsd  0xde4(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12a0 <read_dtime+0x170>
movsd  0xdb9(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12a0 <read_dtime+0x170>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    12a0 <read_dtime+0x170>
jmp    12a0 <read_dtime+0x170>
mov    0x2d61(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xd94(%rip),%rsi
call   1050 <fprintf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12c6 <read_dtime+0x196>
movsd  -0x28(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x30(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1151 <read_dtime+0x21>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_dtime>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
movsd  %xmm0,0x18(%rsp)
mov    %rdi,%r14
mov    %rdi,0x8(%rsp)
xorpd  %xmm0,%xmm0
lea    0x8(%rsp),%r15
lea    0xec7(%rip),%r12
mov    %rdi,%rbx
jmp    118c <read_dtime+0x5c>
mulsd  0xe9a(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %rbx,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
addsd  %xmm1,%xmm0
cmpb   $0x0,(%rbx)
je     1212 <read_dtime+0xe2>
movsd  %xmm0,0x20(%rsp)
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strtod@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x8(%rsp),%rbx
movsbl (%rbx),%edi
call   1030 <toupper@plt>
lea    -0x44(%rax),%ecx
cmp    $0x15,%ecx
ja     11d1 <read_dtime+0xa1>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
movsd  0x10(%rsp),%xmm1
jmp    *%rax
mulsd  0xe41(%rip),%xmm1
jmp    1170 <read_dtime+0x40>
test   %eax,%eax
movsd  0x10(%rsp),%xmm1
je     1179 <read_dtime+0x49>
jmp    11f4 <read_dtime+0xc4>
mulsd  0xe23(%rip),%xmm1
jmp    1170 <read_dtime+0x40>
mulsd  0xe29(%rip),%xmm1
jmp    1170 <read_dtime+0x40>
mov    0x2de5(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
mov    %r14,%rdx
call   1050 <fprintf@plt>
movsd  0x18(%rsp),%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [41 x i8] c"Bad time specifier '%s'---using default\0A\00"
define double @read_dtime(i8* %0, double %1) {
%3 = alloca double
%4 = alloca i8*
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i8*
store i8* %0, i8** %4
store double %1, double* %5
store double 0.000000e+00, double* %6
%9 = load i8*, i8** %4
store i8* %9, i8** %8
br label %10
10: ; preds = %49, %2
%11 = load i8*, i8** %8
%12 = call double @strtod(i8* %11, i8** %8)
store double %12, double* %7
%13 = load i8*, i8** %8
%14 = load i8, i8* %13
%15 = call i32 @toupper(i8 signext %14)
switch i32 %15, label %40 [
i32 89, label %16
i32 68, label %21
i32 72, label %26
i32 77, label %31
i32 83, label %36
i32 0, label %39
]
16: ; preds = %10
%17 = load double, double* %7
%18 = fmul double %17, 0x417E1853DFE5C91E
store double %18, double* %7
%19 = load i8*, i8** %8
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %8
br label %45
21: ; preds = %10
%22 = load double, double* %7
%23 = fmul double %22, 8.640000e+04
store double %23, double* %7
%24 = load i8*, i8** %8
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %8
br label %45
26: ; preds = %10
%27 = load double, double* %7
%28 = fmul double %27, 3.600000e+03
store double %28, double* %7
%29 = load i8*, i8** %8
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %8
br label %45
31: ; preds = %10
%32 = load double, double* %7
%33 = fmul double %32, 6.000000e+01
store double %33, double* %7
%34 = load i8*, i8** %8
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %8
br label %45
36: ; preds = %10
%37 = load i8*, i8** %8
%38 = getelementptr inbounds i8, i8* %37, i32 1
store i8* %38, i8** %8
br label %45
39: ; preds = %10
br label %45
40: ; preds = %10
%41 = load i32, i32* @stderr
%42 = load i8*, i8** %4
%43 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %42)
%44 = load double, double* %5
store double %44, double* %3
br label %55
45: ; preds = %39, %36, %31, %26, %21, %16
%46 = load double, double* %7
%47 = load double, double* %6
%48 = fadd double %47, %46
store double %48, double* %6
br label %49
49: ; preds = %45
%50 = load i8*, i8** %8
%51 = load i8, i8* %50
%52 = icmp ne i8 %51, 0
br i1 %52, label %10, label %53
53: ; preds = %49
%54 = load double, double* %6
store double %54, double* %3
br label %55
55: ; preds = %53, %40
%56 = load double, double* %3
ret double %56
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [41 x i8] c"Bad time specifier '%s'---using default\0A\00"
define double @read_dtime(i8* %0, double %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
store i8* %0, i8** %3
br label %5
5: ; preds = %29, %2
%6 = phi i8* [ %0, %2 ], [ %30, %29 ]
%7 = phi double [ 0.000000e+00, %2 ], [ %32, %29 ]
%8 = call double @strtod(i8* %6, i8** %3)
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = tail call i32 @toupper(i8 signext %10)
switch i32 %11, label %26 [
i32 89, label %12
i32 68, label %15
i32 72, label %18
i32 77, label %21
i32 83, label %24
i32 0, label %29
]
12: ; preds = %5
%13 = fmul double %8, 0x417E1853DFE5C91E
%14 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %14, i8** %3
br label %29
15: ; preds = %5
%16 = fmul double %8, 8.640000e+04
%17 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %17, i8** %3
br label %29
18: ; preds = %5
%19 = fmul double %8, 3.600000e+03
%20 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %20, i8** %3
br label %29
21: ; preds = %5
%22 = fmul double %8, 6.000000e+01
%23 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %23, i8** %3
br label %29
24: ; preds = %5
%25 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %25, i8** %3
br label %29
26: ; preds = %5
%27 = load i32, i32* @stderr
%28 = tail call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %35
29: ; preds = %5, %24, %21, %18, %15, %12
%30 = phi i8* [ %9, %5 ], [ %25, %24 ], [ %23, %21 ], [ %20, %18 ], [ %17, %15 ], [ %14, %12 ]
%31 = phi double [ %8, %5 ], [ %8, %24 ], [ %22, %21 ], [ %19, %18 ], [ %16, %15 ], [ %13, %12 ]
%32 = fadd double %7, %31
%33 = load i8, i8* %30
%34 = icmp eq i8 %33, 0
br i1 %34, label %35, label %5
35: ; preds = %29, %26
%36 = phi double [ %1, %26 ], [ %32, %29 ]
ret double %36
}