#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 sscanf(char const *, char *, int *);
int strlen(char const *);
int RD_Cnv_TString_to_msec(const char *str) {
  int hour;
  int minute;
  int second;
  int tenth;
  if (strlen(str) < 10) {
    return -1;
  }
  if (sscanf(str, "%02d", &hour) != 1) {
    return -1;
  }
  if ((hour < 0) || (hour > 23)) {
    return -1;
  }
  if (sscanf(str + 3, "%02d", &minute) != 1) {
    return -1;
  }
  if ((minute < 0) || (minute > 59)) {
    return -1;
  }
  if (sscanf(str + 6, "%02d", &second) != 1) {
    return -1;
  }
  if ((second < 0) || (second > 59)) {
    return -1;
  }
  if (sscanf(str + 9, "%1d", &tenth) != 1) {
    return -1;
  }
  if ((tenth < 0) || (tenth > 9)) {
    return -1;
  }
  return 3600000 * hour + 60000 * minute + 1000 * second + 100 * tenth;
}


x86 assembly (clang, -O0):
<RD_Cnv_TString_to_msec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xa,%eax
jge    114a <RD_Cnv_TString_to_msec+0x2a>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <RD_Cnv_TString_to_msec+0x17c>
mov    -0x10(%rbp),%rdi
lea    0xeab(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     1173 <RD_Cnv_TString_to_msec+0x53>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <RD_Cnv_TString_to_msec+0x17c>
cmpl   $0x0,-0x14(%rbp)
jl     1187 <RD_Cnv_TString_to_msec+0x67>
cmpl   $0x17,-0x14(%rbp)
jle    1193 <RD_Cnv_TString_to_msec+0x73>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <RD_Cnv_TString_to_msec+0x17c>
mov    -0x10(%rbp),%rdi
add    $0x3,%rdi
lea    0xe5e(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     11c0 <RD_Cnv_TString_to_msec+0xa0>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <RD_Cnv_TString_to_msec+0x17c>
cmpl   $0x0,-0x18(%rbp)
jl     11d4 <RD_Cnv_TString_to_msec+0xb4>
cmpl   $0x3b,-0x18(%rbp)
jle    11e0 <RD_Cnv_TString_to_msec+0xc0>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <RD_Cnv_TString_to_msec+0x17c>
mov    -0x10(%rbp),%rdi
add    $0x6,%rdi
lea    0xe11(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     120d <RD_Cnv_TString_to_msec+0xed>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <RD_Cnv_TString_to_msec+0x17c>
cmpl   $0x0,-0x1c(%rbp)
jl     1221 <RD_Cnv_TString_to_msec+0x101>
cmpl   $0x3b,-0x1c(%rbp)
jle    122d <RD_Cnv_TString_to_msec+0x10d>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <RD_Cnv_TString_to_msec+0x17c>
mov    -0x10(%rbp),%rdi
add    $0x9,%rdi
lea    0xdc9(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
je     125a <RD_Cnv_TString_to_msec+0x13a>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <RD_Cnv_TString_to_msec+0x17c>
cmpl   $0x0,-0x20(%rbp)
jl     126e <RD_Cnv_TString_to_msec+0x14e>
cmpl   $0x9,-0x20(%rbp)
jle    127a <RD_Cnv_TString_to_msec+0x15a>
movl   $0xffffffff,-0x4(%rbp)
jmp    129c <RD_Cnv_TString_to_msec+0x17c>
imul   $0x36ee80,-0x14(%rbp),%eax
imul   $0xea60,-0x18(%rbp),%ecx
add    %ecx,%eax
imul   $0x3e8,-0x1c(%rbp),%ecx
add    %ecx,%eax
imul   $0x64,-0x20(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RD_Cnv_TString_to_msec>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    $0xffffffff,%ebp
cmp    $0xa,%eax
jl     11ed <RD_Cnv_TString_to_msec+0xcd>
lea    0xebd(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11ed <RD_Cnv_TString_to_msec+0xcd>
cmpl   $0x17,0x10(%rsp)
ja     11ed <RD_Cnv_TString_to_msec+0xcd>
lea    0x3(%rbx),%rdi
lea    0xe91(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11ed <RD_Cnv_TString_to_msec+0xcd>
cmpl   $0x3b,0xc(%rsp)
ja     11ed <RD_Cnv_TString_to_msec+0xcd>
lea    0x6(%rbx),%rdi
lea    0xe70(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11ed <RD_Cnv_TString_to_msec+0xcd>
cmpl   $0x3b,0x8(%rsp)
ja     11ed <RD_Cnv_TString_to_msec+0xcd>
add    $0x9,%rbx
lea    0xe54(%rip),%rsi
lea    0x14(%rsp),%rdx
mov    %rbx,%rdi
call   1040 <sscanf@plt>
cmp    $0x1,%eax
jne    11ed <RD_Cnv_TString_to_msec+0xcd>
mov    0x14(%rsp),%eax
cmp    $0x9,%eax
ja     11ed <RD_Cnv_TString_to_msec+0xcd>
imul   $0x36ee80,0x10(%rsp),%ecx
imul   $0xea60,0xc(%rsp),%edx
imul   $0x3e8,0x8(%rsp),%esi
imul   $0x64,%eax,%ebp
add    %ecx,%ebp
add    %edx,%ebp
add    %esi,%ebp
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02d\00"
@.str.1 = [4 x i8] c"%1d\00"
define i32 @RD_Cnv_TString_to_msec(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %9, 10
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 -1, i32* %2
br label %75
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %4)
%15 = icmp ne i32 %14, 1
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 -1, i32* %2
br label %75
17: ; preds = %12
%18 = load i32, i32* %4
%19 = icmp slt i32 %18, 0
br i1 %19, label %23, label %20
20: ; preds = %17
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 23
br i1 %22, label %23, label %24
23: ; preds = %20, %17
store i32 -1, i32* %2
br label %75
24: ; preds = %20
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i64 3
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %5)
%28 = icmp ne i32 %27, 1
br i1 %28, label %29, label %30
29: ; preds = %24
store i32 -1, i32* %2
br label %75
30: ; preds = %24
%31 = load i32, i32* %5
%32 = icmp slt i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %5
%35 = icmp sgt i32 %34, 59
br i1 %35, label %36, label %37
36: ; preds = %33, %30
store i32 -1, i32* %2
br label %75
37: ; preds = %33
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i64 6
%40 = call i32 @sscanf(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %6)
%41 = icmp ne i32 %40, 1
br i1 %41, label %42, label %43
42: ; preds = %37
store i32 -1, i32* %2
br label %75
43: ; preds = %37
%44 = load i32, i32* %6
%45 = icmp slt i32 %44, 0
br i1 %45, label %49, label %46
46: ; preds = %43
%47 = load i32, i32* %6
%48 = icmp sgt i32 %47, 59
br i1 %48, label %49, label %50
49: ; preds = %46, %43
store i32 -1, i32* %2
br label %75
50: ; preds = %46
%51 = load i8*, i8** %3
%52 = getelementptr inbounds i8, i8* %51, i64 9
%53 = call i32 @sscanf(i8* %52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%54 = icmp ne i32 %53, 1
br i1 %54, label %55, label %56
55: ; preds = %50
store i32 -1, i32* %2
br label %75
56: ; preds = %50
%57 = load i32, i32* %7
%58 = icmp slt i32 %57, 0
br i1 %58, label %62, label %59
59: ; preds = %56
%60 = load i32, i32* %7
%61 = icmp sgt i32 %60, 9
br i1 %61, label %62, label %63
62: ; preds = %59, %56
store i32 -1, i32* %2
br label %75
63: ; preds = %59
%64 = load i32, i32* %4
%65 = mul nsw i32 3600000, %64
%66 = load i32, i32* %5
%67 = mul nsw i32 60000, %66
%68 = add nsw i32 %65, %67
%69 = load i32, i32* %6
%70 = mul nsw i32 1000, %69
%71 = add nsw i32 %68, %70
%72 = load i32, i32* %7
%73 = mul nsw i32 100, %72
%74 = add nsw i32 %71, %73
store i32 %74, i32* %2
br label %75
75: ; preds = %63, %62, %55, %49, %42, %36, %29, %23, %16, %11
%76 = load i32, i32* %2
ret i32 %76
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02d\00"
@.str.1 = [4 x i8] c"%1d\00"
define i32 @RD_Cnv_TString_to_msec(i8* %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = tail call i32 @strlen(i8* %0)
%11 = icmp slt i32 %10, 10
br i1 %11, label %50, label %12
12: ; preds = %1
%13 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %2)
%14 = icmp ne i32 %13, 1
%15 = load i32, i32* %2
%16 = icmp ugt i32 %15, 23
%17 = select i1 %14, i1 true, i1 %16
br i1 %17, label %50, label %18
18: ; preds = %12
%19 = getelementptr inbounds i8, i8* %0, i64 3
%20 = call i32 @sscanf(i8* %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3)
%21 = icmp ne i32 %20, 1
%22 = load i32, i32* %3
%23 = icmp ugt i32 %22, 59
%24 = select i1 %21, i1 true, i1 %23
br i1 %24, label %50, label %25
25: ; preds = %18
%26 = getelementptr inbounds i8, i8* %0, i64 6
%27 = call i32 @sscanf(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %4)
%28 = icmp ne i32 %27, 1
%29 = load i32, i32* %4
%30 = icmp ugt i32 %29, 59
%31 = select i1 %28, i1 true, i1 %30
br i1 %31, label %50, label %32
32: ; preds = %25
%33 = getelementptr inbounds i8, i8* %0, i64 9
%34 = call i32 @sscanf(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %50
36: ; preds = %32
%37 = load i32, i32* %5
%38 = icmp ugt i32 %37, 9
br i1 %38, label %50, label %39
39: ; preds = %36
%40 = load i32, i32* %2
%41 = mul nsw i32 %40, 3600000
%42 = load i32, i32* %3
%43 = mul nsw i32 %42, 60000
%44 = load i32, i32* %4
%45 = mul nsw i32 %44, 1000
%46 = mul nuw nsw i32 %37, 100
%47 = add i32 %41, %46
%48 = add i32 %47, %43
%49 = add i32 %48, %45
br label %50
50: ; preds = %36, %32, %25, %18, %12, %1, %39
%51 = phi i32 [ %49, %39 ], [ -1, %1 ], [ -1, %12 ], [ -1, %18 ], [ -1, %25 ], [ -1, %32 ], [ -1, %36 ]
ret i32 %51
}