#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(int /*<<< orphan*/);
int strlen(char const *);
int /*<<< orphan*/ substring(char *, char const *, int, int);
int /*<<< orphan*/ trim(char *);
int calculate_duration(const char *input) {
  int len = strlen(input);
  char buf[len];
  substring(buf, input, 0, len - 6);
  int minute = atoi(trim(buf));
  substring(buf, input, len - 5, len - 3);
  int second = atoi(trim(buf));
  substring(buf, input, len - 2, len);
  int frame = atoi(trim(buf));
  return (int)((minute * 60 + second + (float)frame / 75) * 1000);
}


x86 assembly (clang, -O0):
<calculate_duration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%ecx
sub    $0x6,%ecx
xor    %edx,%edx
call   1050 <substring@plt>
mov    -0x38(%rbp),%rdi
call   1040 <trim@plt>
mov    %eax,%edi
call   1060 <atoi@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x5,%edx
mov    -0xc(%rbp),%ecx
sub    $0x3,%ecx
call   1050 <substring@plt>
mov    -0x38(%rbp),%rdi
call   1040 <trim@plt>
mov    %eax,%edi
call   1060 <atoi@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x2,%edx
mov    -0xc(%rbp),%ecx
call   1050 <substring@plt>
mov    -0x38(%rbp),%rdi
call   1040 <trim@plt>
mov    %eax,%edi
call   1060 <atoi@plt>
mov    %eax,-0x2c(%rbp)
imul   $0x3c,-0x24(%rbp),%eax
add    -0x28(%rbp),%eax
cvtsi2ss %eax,%xmm0
cvtsi2ssl -0x2c(%rbp),%xmm1
movss  0xdf5(%rip),%xmm2
divss  %xmm2,%xmm1
addss  %xmm1,%xmm0
movss  0xde1(%rip),%xmm1
mulss  %xmm1,%xmm0
cvttss2si %xmm0,%eax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calculate_duration>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %eax,%r15d
mov    %eax,%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    -0x6(%r15),%ecx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1050 <substring@plt>
mov    %rbx,%rdi
call   1040 <trim@plt>
mov    %eax,%edi
call   1060 <atoi@plt>
mov    %eax,%r12d
lea    -0x5(%r15),%edx
lea    -0x3(%r15),%ecx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <substring@plt>
mov    %rbx,%rdi
call   1040 <trim@plt>
mov    %eax,%edi
call   1060 <atoi@plt>
mov    %eax,%r13d
lea    -0x2(%r15),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%ecx
call   1050 <substring@plt>
mov    %rbx,%rdi
call   1040 <trim@plt>
mov    %eax,%edi
call   1060 <atoi@plt>
imul   $0x3c,%r12d,%ecx
add    %r13d,%ecx
cvtsi2ss %ecx,%xmm0
cvtsi2ss %eax,%xmm1
divss  0xe14(%rip),%xmm1
addss  %xmm0,%xmm1
mulss  0xe0c(%rip),%xmm1
cvttss2si %xmm1,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @calculate_duration(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %4
%14 = alloca i8, i64 %12
store i64 %12, i64* %5
%15 = load i8*, i8** %2
%16 = load i32, i32* %3
%17 = sub nsw i32 %16, 6
%18 = call i32 @substring(i8* %14, i8* %15, i32 0, i32 %17)
%19 = call i32 @trim(i8* %14)
%20 = call i32 @atoi(i32 %19)
store i32 %20, i32* %6
%21 = load i8*, i8** %2
%22 = load i32, i32* %3
%23 = sub nsw i32 %22, 5
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 3
%26 = call i32 @substring(i8* %14, i8* %21, i32 %23, i32 %25)
%27 = call i32 @trim(i8* %14)
%28 = call i32 @atoi(i32 %27)
store i32 %28, i32* %7
%29 = load i8*, i8** %2
%30 = load i32, i32* %3
%31 = sub nsw i32 %30, 2
%32 = load i32, i32* %3
%33 = call i32 @substring(i8* %14, i8* %29, i32 %31, i32 %32)
%34 = call i32 @trim(i8* %14)
%35 = call i32 @atoi(i32 %34)
store i32 %35, i32* %8
%36 = load i32, i32* %6
%37 = mul nsw i32 %36, 60
%38 = load i32, i32* %7
%39 = add nsw i32 %37, %38
%40 = sitofp i32 %39 to float
%41 = load i32, i32* %8
%42 = sitofp i32 %41 to float
%43 = fdiv float %42, 7.500000e+01
%44 = fadd float %40, %43
%45 = fmul float %44, 1.000000e+03
%46 = fptosi float %45 to i32
%47 = load i8*, i8** %4
ret i32 %46
}

LLVM IR (-O2):
define i32 @calculate_duration(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = add nsw i32 %2, -6
%6 = call i32 @substring(i8* %4, i8* %0, i32 0, i32 %5)
%7 = call i32 @trim(i8* %4)
%8 = call i32 @atoi(i32 %7)
%9 = add nsw i32 %2, -5
%10 = add nsw i32 %2, -3
%11 = call i32 @substring(i8* %4, i8* %0, i32 %9, i32 %10)
%12 = call i32 @trim(i8* %4)
%13 = call i32 @atoi(i32 %12)
%14 = add nsw i32 %2, -2
%15 = call i32 @substring(i8* %4, i8* %0, i32 %14, i32 %2)
%16 = call i32 @trim(i8* %4)
%17 = call i32 @atoi(i32 %16)
%18 = mul nsw i32 %8, 60
%19 = add nsw i32 %13, %18
%20 = sitofp i32 %19 to float
%21 = sitofp i32 %17 to float
%22 = fdiv float %21, 7.500000e+01
%23 = fadd float %22, %20
%24 = fmul float %23, 1.000000e+03
%25 = fptosi float %24 to i32
ret i32 %25
}