#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*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ strlen(char *);
char *strrchr(char *, char);
int hmsf2fsec(char *instring, double *seconds) {
  char *charptr;
  int i = 0;
  if (!strlen(instring))
    return 0;
  *seconds = 0;
  charptr = strrchr(instring, ':');
  if (charptr == NULL)
    charptr = instring;
  else {
    *charptr = '\0';
    charptr++;
  }
  if (!sscanf(charptr, "%lf", seconds))
    return 0;
  if (charptr == instring)
    return 1;
  charptr = strrchr(instring, ':');
  if (charptr == NULL)
    charptr = instring;
  else {
    *charptr = '\0';
    charptr++;
  }
  if (!sscanf(charptr, "%d", &i))
    return 0;
  *seconds += i * 60;
  if (charptr == instring)
    return 1;
  charptr = strrchr(instring, ':');
  if (charptr == NULL)
    charptr = instring;
  else {
    *charptr = '\0';
    charptr++;
  }
  if (!sscanf(charptr, "%d", &i))
    return 0;
  *seconds += i * 3600;
  if (charptr == instring)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<hmsf2fsec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    1165 <hmsf2fsec+0x35>
movl   $0x0,-0x4(%rbp)
jmp    1328 <hmsf2fsec+0x1f8>
mov    -0x18(%rbp),%rax
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    119a <hmsf2fsec+0x6a>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11ad <hmsf2fsec+0x7d>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x0,%eax
jne    11d8 <hmsf2fsec+0xa8>
movl   $0x0,-0x4(%rbp)
jmp    1328 <hmsf2fsec+0x1f8>
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    11f2 <hmsf2fsec+0xc2>
movl   $0x1,-0x4(%rbp)
jmp    1328 <hmsf2fsec+0x1f8>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    121c <hmsf2fsec+0xec>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    122f <hmsf2fsec+0xff>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdca(%rip),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x0,%eax
jne    125a <hmsf2fsec+0x12a>
movl   $0x0,-0x4(%rbp)
jmp    1328 <hmsf2fsec+0x1f8>
imul   $0x3c,-0x24(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1288 <hmsf2fsec+0x158>
movl   $0x1,-0x4(%rbp)
jmp    1328 <hmsf2fsec+0x1f8>
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    12b2 <hmsf2fsec+0x182>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    12c5 <hmsf2fsec+0x195>
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xd34(%rip),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1050 <sscanf@plt>
cmp    $0x0,%eax
jne    12f0 <hmsf2fsec+0x1c0>
movl   $0x0,-0x4(%rbp)
jmp    1328 <hmsf2fsec+0x1f8>
imul   $0xe10,-0x24(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1321 <hmsf2fsec+0x1f1>
movl   $0x1,-0x4(%rbp)
jmp    1328 <hmsf2fsec+0x1f8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hmsf2fsec>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
movl   $0x0,0xc(%rsp)
call   1030 <strlen@plt>
test   %eax,%eax
je     1260 <hmsf2fsec+0x130>
movq   $0x0,(%r14)
mov    %r12,%rdi
mov    $0x3a,%esi
call   1040 <strrchr@plt>
mov    %r12,%rbx
test   %rax,%rax
je     117d <hmsf2fsec+0x4d>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,%rbx
lea    0xe7c(%rip),%rsi
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <sscanf@plt>
test   %eax,%eax
je     1262 <hmsf2fsec+0x132>
mov    $0x1,%ebp
cmp    %r12,%rbx
je     1262 <hmsf2fsec+0x132>
mov    %r12,%rdi
mov    $0x3a,%esi
call   1040 <strrchr@plt>
mov    %r12,%r15
test   %rax,%rax
je     11c8 <hmsf2fsec+0x98>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,%r15
lea    0xe35(%rip),%rsi
xor    %ebp,%ebp
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <sscanf@plt>
test   %eax,%eax
je     1262 <hmsf2fsec+0x132>
imul   $0x3c,0xc(%rsp),%eax
cvtsi2sd %eax,%xmm0
addsd  (%r14),%xmm0
movsd  %xmm0,(%r14)
mov    $0x1,%ebp
cmp    %r12,%r15
je     1262 <hmsf2fsec+0x132>
mov    %r12,%rdi
mov    $0x3a,%esi
call   1040 <strrchr@plt>
mov    %r12,%r15
test   %rax,%rax
je     1220 <hmsf2fsec+0xf0>
movb   $0x0,(%rax)
add    $0x1,%rax
mov    %rax,%r15
lea    0xddd(%rip),%rsi
xor    %ebp,%ebp
lea    0xc(%rsp),%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <sscanf@plt>
test   %eax,%eax
je     1262 <hmsf2fsec+0x132>
imul   $0xe10,0xc(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  (%r14),%xmm0
movsd  %xmm0,(%r14)
xor    %ebp,%ebp
cmp    %r12,%r15
sete   %bpl
jmp    1262 <hmsf2fsec+0x132>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @hmsf2fsec(i8* %0, double* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca double*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store double* %1, double** %5
store i32 0, i32* %7
%8 = load i8*, i8** %4
%9 = call i32 @strlen(i8* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %2
store i32 0, i32* %3
br label %90
12: ; preds = %2
%13 = load double*, double** %5
store double 0.000000e+00, double* %13
%14 = load i8*, i8** %4
%15 = call i8* @strrchr(i8* %14, i8 signext 58)
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = load i8*, i8** %4
store i8* %19, i8** %6
br label %24
20: ; preds = %12
%21 = load i8*, i8** %6
store i8 0, i8* %21
%22 = load i8*, i8** %6
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %6
br label %24
24: ; preds = %20, %18
%25 = load i8*, i8** %6
%26 = load double*, double** %5
%27 = call i32 (i8*, i8*, ...) @sscanf(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %24
store i32 0, i32* %3
br label %90
30: ; preds = %24
%31 = load i8*, i8** %6
%32 = load i8*, i8** %4
%33 = icmp eq i8* %31, %32
br i1 %33, label %34, label %35
34: ; preds = %30
store i32 1, i32* %3
br label %90
35: ; preds = %30
%36 = load i8*, i8** %4
%37 = call i8* @strrchr(i8* %36, i8 signext 58)
store i8* %37, i8** %6
%38 = load i8*, i8** %6
%39 = icmp eq i8* %38, null
br i1 %39, label %40, label %42
40: ; preds = %35
%41 = load i8*, i8** %4
store i8* %41, i8** %6
br label %46
42: ; preds = %35
%43 = load i8*, i8** %6
store i8 0, i8* %43
%44 = load i8*, i8** %6
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %6
br label %46
46: ; preds = %42, %40
%47 = load i8*, i8** %6
%48 = call i32 (i8*, i8*, ...) @sscanf(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%49 = icmp ne i32 %48, 0
br i1 %49, label %51, label %50
50: ; preds = %46
store i32 0, i32* %3
br label %90
51: ; preds = %46
%52 = load i32, i32* %7
%53 = mul nsw i32 %52, 60
%54 = sitofp i32 %53 to double
%55 = load double*, double** %5
%56 = load double, double* %55
%57 = fadd double %56, %54
store double %57, double* %55
%58 = load i8*, i8** %6
%59 = load i8*, i8** %4
%60 = icmp eq i8* %58, %59
br i1 %60, label %61, label %62
61: ; preds = %51
store i32 1, i32* %3
br label %90
62: ; preds = %51
%63 = load i8*, i8** %4
%64 = call i8* @strrchr(i8* %63, i8 signext 58)
store i8* %64, i8** %6
%65 = load i8*, i8** %6
%66 = icmp eq i8* %65, null
br i1 %66, label %67, label %69
67: ; preds = %62
%68 = load i8*, i8** %4
store i8* %68, i8** %6
br label %73
69: ; preds = %62
%70 = load i8*, i8** %6
store i8 0, i8* %70
%71 = load i8*, i8** %6
%72 = getelementptr inbounds i8, i8* %71, i32 1
store i8* %72, i8** %6
br label %73
73: ; preds = %69, %67
%74 = load i8*, i8** %6
%75 = call i32 (i8*, i8*, ...) @sscanf(i8* %74, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%76 = icmp ne i32 %75, 0
br i1 %76, label %78, label %77
77: ; preds = %73
store i32 0, i32* %3
br label %90
78: ; preds = %73
%79 = load i32, i32* %7
%80 = mul nsw i32 %79, 3600
%81 = sitofp i32 %80 to double
%82 = load double*, double** %5
%83 = load double, double* %82
%84 = fadd double %83, %81
store double %84, double* %82
%85 = load i8*, i8** %6
%86 = load i8*, i8** %4
%87 = icmp eq i8* %85, %86
br i1 %87, label %88, label %89
88: ; preds = %78
store i32 1, i32* %3
br label %90
89: ; preds = %78
store i32 0, i32* %3
br label %90
90: ; preds = %89, %88, %77, %61, %50, %34, %29, %11
%91 = load i32, i32* %3
ret i32 %91
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @hmsf2fsec(i8* %0, double* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %51, label %7
7: ; preds = %2
store double 0.000000e+00, double* %1
%8 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 58)
%9 = icmp eq i8* %8, null
br i1 %9, label %12, label %10
10: ; preds = %7
store i8 0, i8* %8
%11 = getelementptr inbounds i8, i8* %8, i64 1
br label %12
12: ; preds = %7, %10
%13 = phi i8* [ %11, %10 ], [ %0, %7 ]
%14 = tail call i32 (i8*, i8*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double* %1)
%15 = icmp eq i32 %14, 0
br i1 %15, label %51, label %16
16: ; preds = %12
%17 = icmp eq i8* %13, %0
br i1 %17, label %51, label %18
18: ; preds = %16
%19 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 58)
%20 = icmp eq i8* %19, null
br i1 %20, label %23, label %21
21: ; preds = %18
store i8 0, i8* %19
%22 = getelementptr inbounds i8, i8* %19, i64 1
br label %23
23: ; preds = %18, %21
%24 = phi i8* [ %22, %21 ], [ %0, %18 ]
%25 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%26 = icmp eq i32 %25, 0
br i1 %26, label %51, label %27
27: ; preds = %23
%28 = load i32, i32* %3
%29 = mul nsw i32 %28, 60
%30 = sitofp i32 %29 to double
%31 = load double, double* %1
%32 = fadd double %31, %30
store double %32, double* %1
%33 = icmp eq i8* %24, %0
br i1 %33, label %51, label %34
34: ; preds = %27
%35 = call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 58)
%36 = icmp eq i8* %35, null
br i1 %36, label %39, label %37
37: ; preds = %34
store i8 0, i8* %35
%38 = getelementptr inbounds i8, i8* %35, i64 1
br label %39
39: ; preds = %34, %37
%40 = phi i8* [ %38, %37 ], [ %0, %34 ]
%41 = call i32 (i8*, i8*, ...) @sscanf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%42 = icmp eq i32 %41, 0
br i1 %42, label %51, label %43
43: ; preds = %39
%44 = load i32, i32* %3
%45 = mul nsw i32 %44, 3600
%46 = sitofp i32 %45 to double
%47 = load double, double* %1
%48 = fadd double %47, %46
store double %48, double* %1
%49 = icmp eq i8* %40, %0
%50 = zext i1 %49 to i32
br label %51
51: ; preds = %43, %39, %27, %23, %16, %12, %2
%52 = phi i32 [ 0, %2 ], [ 0, %12 ], [ 1, %16 ], [ 0, %23 ], [ 1, %27 ], [ 0, %39 ], [ %50, %43 ]
ret i32 %52
}