#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*/ ferror(int /*<<< orphan*/);
int sscanf(char const *, char *, double *, double *, double *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ usage(int /*<<< orphan*/ *);
double parse_timespec(const char *string) {
  int ret;
  double h = 0, m = 0, s = 0;
  if (!string || !string[0])
    return 0;
  ret = sscanf(string, "%lf:%lf:%lf", &h, &m, &s);
  switch (ret) {
  case 1:
    s = h;
    m = 0;
    h = 0;
    break;
  case 2:
    s = m;
    m = h;
    h = 0;
    break;
  case 3:
    break;
  default:
    ferror(stderr);
    usage(NULL);
  }
  return (h * 3600) + (m * 60) + s;
}


x86 assembly (clang, -O0):
<parse_timespec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116c <parse_timespec+0x3c>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1179 <parse_timespec+0x49>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1256 <parse_timespec+0x126>
mov    -0x10(%rbp),%rdi
lea    0xe8c(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x30(%rbp),%r8
call   1040 <sscanf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x1,%eax
je     11ce <parse_timespec+0x9e>
jmp    11ac <parse_timespec+0x7c>
mov    -0x34(%rbp),%eax
sub    $0x2,%eax
je     11ed <parse_timespec+0xbd>
jmp    11bd <parse_timespec+0x8d>
mov    -0x34(%rbp),%eax
sub    $0x3,%eax
je     120e <parse_timespec+0xde>
jmp    1213 <parse_timespec+0xe3>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    122a <parse_timespec+0xfa>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    122a <parse_timespec+0xfa>
jmp    122a <parse_timespec+0xfa>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <usage@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xdd1(%rip),%xmm1
mulsd  -0x28(%rbp),%xmm1
movsd  0xdbc(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_timespec>:
sub    $0x18,%rsp
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
xorpd  %xmm0,%xmm0
test   %rdi,%rdi
je     1205 <parse_timespec+0xd5>
cmpb   $0x0,(%rdi)
je     1205 <parse_timespec+0xd5>
lea    0xea5(%rip),%rsi
mov    %rsp,%rdx
lea    0x8(%rsp),%rcx
lea    0x10(%rsp),%r8
call   1040 <sscanf@plt>
cmp    $0x3,%eax
je     11e0 <parse_timespec+0xb0>
cmp    $0x2,%eax
je     11aa <parse_timespec+0x7a>
cmp    $0x1,%eax
jne    11cb <parse_timespec+0x9b>
movsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
jmp    11e0 <parse_timespec+0xb0>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movq   $0x0,(%rsp)
jmp    11e0 <parse_timespec+0xb0>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
call   1030 <ferror@plt>
xor    %edi,%edi
call   1050 <usage@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0xe0d(%rip),%xmm1
mulsd  0xe0d(%rip),%xmm0
addsd  %xmm1,%xmm0
addsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"%lf:%lf:%lf\00"
@stderr = global i32 0
define double @parse_timespec(i8* %0) {
%2 = alloca double
%3 = alloca i8*
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i8* %0, i8** %3
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %10, %1
store double 0.000000e+00, double* %2
br label %37
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double* %5, double* %6, double* %7)
store i32 %18, i32* %4
%19 = load i32, i32* %4
switch i32 %19, label %26 [
i32 1, label %20
i32 2, label %22
i32 3, label %25
]
20: ; preds = %16
%21 = load double, double* %5
store double %21, double* %7
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %5
br label %30
22: ; preds = %16
%23 = load double, double* %6
store double %23, double* %7
%24 = load double, double* %5
store double %24, double* %6
store double 0.000000e+00, double* %5
br label %30
25: ; preds = %16
br label %30
26: ; preds = %16
%27 = load i32, i32* @stderr
%28 = call i32 @ferror(i32 %27)
%29 = call i32 @usage(i32* null)
br label %30
30: ; preds = %26, %25, %22, %20
%31 = load double, double* %5
%32 = load double, double* %6
%33 = fmul double %32, 6.000000e+01
%34 = call double @llvm.fmuladd.f64(double %31, double 3.600000e+03, double %33)
%35 = load double, double* %7
%36 = fadd double %34, %35
store double %36, double* %2
br label %37
37: ; preds = %30, %15
%38 = load double, double* %2
ret double %38
}

LLVM IR (-O2):
@.str = [12 x i8] c"%lf:%lf:%lf\00"
@stderr = global i32 0
define double @parse_timespec(i8* %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%6 = bitcast double* %3 to i8*
store double 0.000000e+00, double* %3
%7 = bitcast double* %4 to i8*
store double 0.000000e+00, double* %4
%8 = icmp eq i8* %0, null
br i1 %8, label %30, label %9
9: ; preds = %1
%10 = load i8, i8* %0
%11 = icmp eq i8 %10, 0
br i1 %11, label %30, label %12
12: ; preds = %9
%13 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), double* %2, double* %3, double* %4)
switch i32 %13, label %19 [
i32 1, label %14
i32 2, label %16
i32 3, label %23
]
14: ; preds = %12
%15 = load double, double* %2
store double %15, double* %4
store double 0.000000e+00, double* %3
store double 0.000000e+00, double* %2
br label %23
16: ; preds = %12
%17 = load double, double* %3
store double %17, double* %4
%18 = load double, double* %2
store double %18, double* %3
store double 0.000000e+00, double* %2
br label %23
19: ; preds = %12
%20 = load i32, i32* @stderr
%21 = call i32 @ferror(i32 %20)
%22 = call i32 @usage(i32* null)
br label %23
23: ; preds = %19, %12, %16, %14
%24 = load double, double* %2
%25 = load double, double* %3
%26 = fmul double %25, 6.000000e+01
%27 = call double @llvm.fmuladd.f64(double %24, double 3.600000e+03, double %26)
%28 = load double, double* %4
%29 = fadd double %28, %27
br label %30
30: ; preds = %1, %9, %23
%31 = phi double [ %29, %23 ], [ 0.000000e+00, %9 ], [ 0.000000e+00, %1 ]
ret double %31
}