#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 *, int *);
int parse_msf(const char *str) {
  int res;
  int m, s, f;
  if (!str)
    return 0;
  res = sscanf(str, "%i:%i:%i", &m, &s, &f);
  if (res != 3)
    return 0;
  return m * 60 * 1000 + s * 1000 + f;
}


x86 assembly (clang, -O0):
<parse_msf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <parse_msf+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1181 <parse_msf+0x71>
mov    -0x10(%rbp),%rdi
lea    0xec2(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1030 <sscanf@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
je     1168 <parse_msf+0x58>
movl   $0x0,-0x4(%rbp)
jmp    1181 <parse_msf+0x71>
imul   $0x3c,-0x18(%rbp),%eax
imul   $0x3e8,%eax,%eax
imul   $0x3e8,-0x1c(%rbp),%ecx
add    %ecx,%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_msf>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
test   %rdi,%rdi
je     1152 <parse_msf+0x42>
lea    0xedd(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
call   1030 <sscanf@plt>
cmp    $0x3,%eax
jne    1152 <parse_msf+0x42>
imul   $0xea60,0xc(%rsp),%eax
imul   $0x3e8,0x8(%rsp),%ebx
add    %eax,%ebx
add    0x4(%rsp),%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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