#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 atoi(char *);
char *strpbrk(char *, char *);
int /*<<< orphan*/ xerrf(char *, char *);
int tcode2ms(char *val) {
  int secs;
  char *s = val;
  secs = atoi(val);
  val = strpbrk(val, ".:");
  if (val == NULL)
    goto msfail;
  if (*val++ == '.')
    goto msget;
  secs = secs * 60 + atoi(val);
  val = strpbrk(val, ".:");
  if (val == NULL)
    goto msfail;
  if (*val++ == '.')
    goto msget;
  secs = secs * 60 + atoi(val);
  val = strpbrk(val, ".:");
  if (val == NULL || *val++ == ':')
    goto msfail;
msget:
  return secs * 1000 + atoi(val);
msfail:
  xerrf("Incorrect timecode string %s.\n", s);
}


x86 assembly (clang, -O0):
<tcode2ms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1040 <strpbrk@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1174 <tcode2ms+0x44>
jmp    1272 <tcode2ms+0x142>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1194 <tcode2ms+0x64>
jmp    1250 <tcode2ms+0x120>
imul   $0x3c,-0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1040 <strpbrk@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d2 <tcode2ms+0xa2>
jmp    1272 <tcode2ms+0x142>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11f2 <tcode2ms+0xc2>
jmp    1250 <tcode2ms+0x120>
imul   $0x3c,-0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1040 <strpbrk@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1246 <tcode2ms+0x116>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    124b <tcode2ms+0x11b>
jmp    1272 <tcode2ms+0x142>
jmp    1250 <tcode2ms+0x120>
imul   $0x3e8,-0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    1282 <tcode2ms+0x152>
mov    -0x20(%rbp),%rsi
lea    0xd86(%rip),%rdi
call   1030 <xerrf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcode2ms>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
call   1050 <atoi@plt>
mov    %eax,%ebp
lea    0xeb7(%rip),%rsi
mov    %r14,%rdi
call   1040 <strpbrk@plt>
test   %rax,%rax
je     11c1 <tcode2ms+0x91>
mov    %rax,%rbx
add    $0x1,%rbx
cmpb   $0x2e,(%rax)
je     11e1 <tcode2ms+0xb1>
mov    %rbx,%rdi
call   1050 <atoi@plt>
mov    %eax,%r15d
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strpbrk@plt>
test   %rax,%rax
je     11c1 <tcode2ms+0x91>
mov    %rax,%rbx
imul   $0x3c,%ebp,%eax
add    %eax,%r15d
mov    %rbx,%rax
add    $0x1,%rbx
cmpb   $0x2e,(%rax)
jne    119b <tcode2ms+0x6b>
mov    %r15d,%ebp
jmp    11e1 <tcode2ms+0xb1>
lea    0xe5e(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strpbrk@plt>
test   %rax,%rax
je     11c1 <tcode2ms+0x91>
mov    %rax,%r12
mov    %rbx,%rdi
call   1050 <atoi@plt>
cmpb   $0x3a,(%r12)
jne    11d2 <tcode2ms+0xa2>
lea    0xe3b(%rip),%rdi
mov    %r14,%rsi
call   1030 <xerrf@plt>
jmp    11f1 <tcode2ms+0xc1>
mov    %eax,%ebp
imul   $0x3c,%r15d,%eax
add    %eax,%ebp
add    $0x1,%r12
mov    %r12,%rbx
imul   $0x3e8,%ebp,%ebp
mov    %rbx,%rdi
call   1050 <atoi@plt>
add    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c".:\00"
@.str.1 = [31 x i8] c"Incorrect timecode string %s.\0A\00"
define i32 @tcode2ms(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
store i8* %6, i8** %5
%7 = load i8*, i8** %3
%8 = call i32 @atoi(i8* %7)
store i32 %8, i32* %4
%9 = load i8*, i8** %3
%10 = call i8* @strpbrk(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %10, i8** %3
%11 = load i8*, i8** %3
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %1
br label %63
14: ; preds = %1
%15 = load i8*, i8** %3
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %3
%17 = load i8, i8* %15
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 46
br i1 %19, label %20, label %21
20: ; preds = %14
br label %57
21: ; preds = %14
%22 = load i32, i32* %4
%23 = mul nsw i32 %22, 60
%24 = load i8*, i8** %3
%25 = call i32 @atoi(i8* %24)
%26 = add nsw i32 %23, %25
store i32 %26, i32* %4
%27 = load i8*, i8** %3
%28 = call i8* @strpbrk(i8* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %28, i8** %3
%29 = load i8*, i8** %3
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %32
31: ; preds = %21
br label %63
32: ; preds = %21
%33 = load i8*, i8** %3
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %3
%35 = load i8, i8* %33
%36 = sext i8 %35 to i32
%37 = icmp eq i32 %36, 46
br i1 %37, label %38, label %39
38: ; preds = %32
br label %57
39: ; preds = %32
%40 = load i32, i32* %4
%41 = mul nsw i32 %40, 60
%42 = load i8*, i8** %3
%43 = call i32 @atoi(i8* %42)
%44 = add nsw i32 %41, %43
store i32 %44, i32* %4
%45 = load i8*, i8** %3
%46 = call i8* @strpbrk(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %46, i8** %3
%47 = load i8*, i8** %3
%48 = icmp eq i8* %47, null
br i1 %48, label %55, label %49
49: ; preds = %39
%50 = load i8*, i8** %3
%51 = getelementptr inbounds i8, i8* %50, i32 1
store i8* %51, i8** %3
%52 = load i8, i8* %50
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 58
br i1 %54, label %55, label %56
55: ; preds = %49, %39
br label %63
56: ; preds = %49
br label %57
57: ; preds = %56, %38, %20
%58 = load i32, i32* %4
%59 = mul nsw i32 %58, 1000
%60 = load i8*, i8** %3
%61 = call i32 @atoi(i8* %60)
%62 = add nsw i32 %59, %61
store i32 %62, i32* %2
br label %66
63: ; preds = %55, %31, %13
%64 = load i8*, i8** %5
%65 = call i32 @xerrf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %64)
br label %66
66: ; preds = %63, %57
%67 = load i32, i32* %2
ret i32 %67
}

LLVM IR (-O2):
@.str = [3 x i8] c".:\00"
@.str.1 = [31 x i8] c"Incorrect timecode string %s.\0A\00"
define i32 @tcode2ms(i8* %0) {
%2 = tail call i32 @atoi(i8* %0)
%3 = tail call i8* @strpbrk(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i8* %3, null
br i1 %4, label %35, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %3, i64 1
%7 = load i8, i8* %3
%8 = icmp eq i8 %7, 46
br i1 %8, label %29, label %9
9: ; preds = %5
%10 = mul nsw i32 %2, 60
%11 = tail call i32 @atoi(i8* %6)
%12 = add nsw i32 %11, %10
%13 = tail call i8* @strpbrk(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i8* %13, null
br i1 %14, label %35, label %15
15: ; preds = %9
%16 = getelementptr inbounds i8, i8* %13, i64 1
%17 = load i8, i8* %13
%18 = icmp eq i8 %17, 46
br i1 %18, label %29, label %19
19: ; preds = %15
%20 = tail call i8* @strpbrk(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %35, label %22
22: ; preds = %19
%23 = mul nsw i32 %12, 60
%24 = tail call i32 @atoi(i8* %16)
%25 = add nsw i32 %24, %23
%26 = getelementptr inbounds i8, i8* %20, i64 1
%27 = load i8, i8* %20
%28 = icmp eq i8 %27, 58
br i1 %28, label %35, label %29
29: ; preds = %22, %15, %5
%30 = phi i8* [ %6, %5 ], [ %16, %15 ], [ %26, %22 ]
%31 = phi i32 [ %2, %5 ], [ %12, %15 ], [ %25, %22 ]
%32 = mul nsw i32 %31, 1000
%33 = tail call i32 @atoi(i8* %30)
%34 = add nsw i32 %32, %33
br label %37
35: ; preds = %19, %22, %9, %1
%36 = tail call i32 @xerrf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %37
37: ; preds = %35, %29
%38 = phi i32 [ undef, %35 ], [ %34, %29 ]
ret i32 %38
}