#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 *strchr(char *, char);
long time2frames(char *s) {
  int mins = 0, secs = 0, frames = 0;
  char *p, *t;
  if (!(p = strchr(s, ':')))
    return -1;
  *p = '\0';
  mins = atoi(s);
  p++;
  if (!(t = strchr(p, ':')))
    return -1;
  *t = '\0';
  secs = atoi(p);
  t++;
  frames = atoi(t);
  return 75 * (mins * 60 + secs) + frames;
}


x86 assembly (clang, -O0):
<time2frames>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    116a <time2frames+0x4a>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11f0 <time2frames+0xd0>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
jne    11b2 <time2frames+0x92>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    11f0 <time2frames+0xd0>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x1c(%rbp)
imul   $0x3c,-0x14(%rbp),%eax
add    -0x18(%rbp),%eax
imul   $0x4b,%eax,%eax
add    -0x1c(%rbp),%eax
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time2frames>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    $0x3a,%esi
call   1030 <strchr@plt>
mov    $0xffffffffffffffff,%r15
test   %rax,%rax
je     1192 <time2frames+0x72>
mov    %rax,%rbx
movb   $0x0,(%rax)
add    $0x1,%rbx
mov    %rbx,%rdi
mov    $0x3a,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1192 <time2frames+0x72>
mov    %rax,%r12
mov    %r14,%rdi
call   1040 <atoi@plt>
mov    %eax,%ebp
movb   $0x0,(%r12)
mov    %rbx,%rdi
call   1040 <atoi@plt>
mov    %eax,%ebx
add    $0x1,%r12
mov    %r12,%rdi
call   1040 <atoi@plt>
imul   $0x3c,%ebp,%ecx
add    %ebx,%ecx
imul   $0x4b,%ecx,%ecx
add    %eax,%ecx
movslq %ecx,%r15
mov    %r15,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i64 @time2frames(i8* %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store i8* %0, i8** %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%9 = load i8*, i8** %3
%10 = call i8* @strchr(i8* %9, i8 signext 58)
store i8* %10, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %13, label %12
12: ; preds = %1
store i64 -1, i64* %2
br label %39
13: ; preds = %1
%14 = load i8*, i8** %7
store i8 0, i8* %14
%15 = load i8*, i8** %3
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %4
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = call i8* @strchr(i8* %19, i8 signext 58)
store i8* %20, i8** %8
%21 = icmp ne i8* %20, null
br i1 %21, label %23, label %22
22: ; preds = %13
store i64 -1, i64* %2
br label %39
23: ; preds = %13
%24 = load i8*, i8** %8
store i8 0, i8* %24
%25 = load i8*, i8** %7
%26 = call i32 @atoi(i8* %25)
store i32 %26, i32* %5
%27 = load i8*, i8** %8
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %8
%29 = load i8*, i8** %8
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %6
%31 = load i32, i32* %4
%32 = mul nsw i32 %31, 60
%33 = load i32, i32* %5
%34 = add nsw i32 %32, %33
%35 = mul nsw i32 75, %34
%36 = load i32, i32* %6
%37 = add nsw i32 %35, %36
%38 = sext i32 %37 to i64
store i64 %38, i64* %2
br label %39
39: ; preds = %23, %22, %12
%40 = load i64, i64* %2
ret i64 %40
}

LLVM IR (-O2):
define i64 @time2frames(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%3 = icmp eq i8* %2, null
br i1 %3, label %18, label %4
4: ; preds = %1
store i8 0, i8* %2
%5 = getelementptr inbounds i8, i8* %2, i64 1
%6 = tail call i8* @strchr(i8* %5, i8 signext 58)
%7 = icmp eq i8* %6, null
br i1 %7, label %18, label %8
8: ; preds = %4
%9 = tail call i32 @atoi(i8* %0)
store i8 0, i8* %6
%10 = tail call i32 @atoi(i8* %5)
%11 = getelementptr inbounds i8, i8* %6, i64 1
%12 = tail call i32 @atoi(i8* %11)
%13 = mul nsw i32 %9, 60
%14 = add nsw i32 %10, %13
%15 = mul nsw i32 %14, 75
%16 = add nsw i32 %15, %12
%17 = sext i32 %16 to i64
br label %18
18: ; preds = %4, %1, %8
%19 = phi i64 [ %17, %8 ], [ -1, %1 ], [ -1, %4 ]
ret i64 %19
}