#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 */
scalar_t__ memcmp(char *, unsigned char *, int);
int sscanf(char *, char *, long *, long *, long *, long *);
long parse_marker(unsigned char *marker) {
  long hh, mm, ss, ms;
  if (memcmp("Marker ", marker, 7))
    return -1;
  if (4 != sscanf((char *)marker + 7, "%ld:%ld:%ld.%ld", &hh, &mm, &ss, &ms))
    return -1;
  return ((hh * 60 + mm) * 60 + ss) * 1000 + ms;
}


x86 assembly (clang, -O0):
<parse_marker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xec9(%rip),%rdi
mov    $0x7,%edx
call   1030 <memcmp@plt>
cmp    $0x0,%rax
je     1158 <parse_marker+0x38>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11b8 <parse_marker+0x98>
mov    -0x10(%rbp),%rdi
add    $0x7,%rdi
lea    0xea1(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
lea    -0x30(%rbp),%r9
call   1040 <sscanf@plt>
mov    %eax,%ecx
mov    $0x4,%eax
cmp    %ecx,%eax
je     1198 <parse_marker+0x78>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11b8 <parse_marker+0x98>
imul   $0x3c,-0x18(%rbp),%rax
add    -0x20(%rbp),%rax
imul   $0x3c,%rax,%rax
add    -0x28(%rbp),%rax
imul   $0x3e8,%rax,%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_marker>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
lea    0xecf(%rip),%rdi
mov    %rbx,%rsi
mov    $0x7,%edx
call   1030 <memcmp@plt>
mov    $0xffffffffffffffff,%r14
test   %rax,%rax
jne    1196 <parse_marker+0x76>
add    $0x7,%rbx
lea    0xeb3(%rip),%rsi
lea    0x20(%rsp),%rdx
lea    0x18(%rsp),%rcx
lea    0x10(%rsp),%r8
lea    0x8(%rsp),%r9
mov    %rbx,%rdi
call   1040 <sscanf@plt>
cmp    $0x4,%eax
jne    1196 <parse_marker+0x76>
imul   $0x3c,0x20(%rsp),%rax
add    0x18(%rsp),%rax
imul   $0x3c,%rax,%rax
add    0x10(%rsp),%rax
imul   $0x3e8,%rax,%r14
add    0x8(%rsp),%r14
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Marker \00"
@.str.1 = [16 x i8] c"%ld:%ld:%ld.%ld\00"
define i64 @parse_marker(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i64 @memcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %8, i32 7)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %1
store i64 -1, i64* %2
br label %29
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 7
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64* %4, i64* %5, i64* %6, i64* %7)
%16 = icmp ne i32 4, %15
br i1 %16, label %17, label %18
17: ; preds = %12
store i64 -1, i64* %2
br label %29
18: ; preds = %12
%19 = load i64, i64* %4
%20 = mul nsw i64 %19, 60
%21 = load i64, i64* %5
%22 = add nsw i64 %20, %21
%23 = mul nsw i64 %22, 60
%24 = load i64, i64* %6
%25 = add nsw i64 %23, %24
%26 = mul nsw i64 %25, 1000
%27 = load i64, i64* %7
%28 = add nsw i64 %26, %27
store i64 %28, i64* %2
br label %29
29: ; preds = %18, %17, %11
%30 = load i64, i64* %2
ret i64 %30
}

LLVM IR (-O2):
@.str = [8 x i8] c"Marker \00"
@.str.1 = [16 x i8] c"%ld:%ld:%ld.%ld\00"
define i64 @parse_marker(i8* %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = bitcast i64* %2 to i8*
%7 = bitcast i64* %3 to i8*
%8 = bitcast i64* %4 to i8*
%9 = bitcast i64* %5 to i8*
%10 = tail call i64 @memcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0, i32 7)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %27
12: ; preds = %1
%13 = getelementptr inbounds i8, i8* %0, i64 7
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3, i64* %4, i64* %5)
%15 = icmp eq i32 %14, 4
br i1 %15, label %16, label %27
16: ; preds = %12
%17 = load i64, i64* %2
%18 = mul nsw i64 %17, 60
%19 = load i64, i64* %3
%20 = add nsw i64 %18, %19
%21 = mul nsw i64 %20, 60
%22 = load i64, i64* %4
%23 = add nsw i64 %21, %22
%24 = mul nsw i64 %23, 1000
%25 = load i64, i64* %5
%26 = add nsw i64 %24, %25
br label %27
27: ; preds = %12, %1, %16
%28 = phi i64 [ %26, %16 ], [ -1, %1 ], [ -1, %12 ]
ret i64 %28
}