#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 chartoint(char);
int strtoint(char str[]) {
  int num1 = chartoint(str[0]);
  int num2 = chartoint(str[1]);
  int num3 = chartoint(str[3]);
  int num4 = chartoint(str[4]);
  int num5 = chartoint(str[6]);
  int num6 = chartoint(str[7]);
  return ((num1 * 10 + num2) * 60 + (num3 * 10 + num4)) * 1000000 +
         (num5 * 100 + num6 * 10) * 1000;
}


x86 assembly (clang, -O0):
<strtoint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <chartoint@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <chartoint@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1030 <chartoint@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x4(%rax),%edi
call   1030 <chartoint@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x6(%rax),%edi
call   1030 <chartoint@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl 0x7(%rax),%edi
call   1030 <chartoint@plt>
mov    %eax,-0x20(%rbp)
imul   $0xa,-0xc(%rbp),%eax
add    -0x10(%rbp),%eax
imul   $0x3c,%eax,%eax
imul   $0xa,-0x14(%rbp),%ecx
add    -0x18(%rbp),%ecx
add    %ecx,%eax
imul   $0xf4240,%eax,%eax
imul   $0x64,-0x1c(%rbp),%ecx
imul   $0xa,-0x20(%rbp),%edx
add    %edx,%ecx
imul   $0x3e8,%ecx,%ecx
add    %ecx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtoint>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <chartoint@plt>
mov    %eax,%r14d
movsbl 0x1(%rbx),%edi
call   1030 <chartoint@plt>
mov    %eax,%r15d
movsbl 0x3(%rbx),%edi
call   1030 <chartoint@plt>
mov    %eax,%r12d
movsbl 0x4(%rbx),%edi
call   1030 <chartoint@plt>
mov    %eax,%r13d
movsbl 0x6(%rbx),%edi
call   1030 <chartoint@plt>
mov    %eax,%ebp
movsbl 0x7(%rbx),%edi
call   1030 <chartoint@plt>
lea    (%r14,%r14,4),%ecx
lea    (%r15,%rcx,2),%ecx
imul   $0x3c,%ecx,%ecx
lea    (%r12,%r12,4),%edx
lea    (%rcx,%rdx,2),%ecx
add    %r13d,%ecx
imul   $0xf4240,%ecx,%ecx
imul   $0x64,%ebp,%edx
lea    (%rax,%rax,4),%eax
lea    (%rdx,%rax,2),%eax
imul   $0x3e8,%eax,%eax
add    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @strtoint(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %2
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = call i32 @chartoint(i8 signext %11)
store i32 %12, i32* %3
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i8, i8* %14
%16 = call i32 @chartoint(i8 signext %15)
store i32 %16, i32* %4
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i64 3
%19 = load i8, i8* %18
%20 = call i32 @chartoint(i8 signext %19)
store i32 %20, i32* %5
%21 = load i8*, i8** %2
%22 = getelementptr inbounds i8, i8* %21, i64 4
%23 = load i8, i8* %22
%24 = call i32 @chartoint(i8 signext %23)
store i32 %24, i32* %6
%25 = load i8*, i8** %2
%26 = getelementptr inbounds i8, i8* %25, i64 6
%27 = load i8, i8* %26
%28 = call i32 @chartoint(i8 signext %27)
store i32 %28, i32* %7
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 7
%31 = load i8, i8* %30
%32 = call i32 @chartoint(i8 signext %31)
store i32 %32, i32* %8
%33 = load i32, i32* %3
%34 = mul nsw i32 %33, 10
%35 = load i32, i32* %4
%36 = add nsw i32 %34, %35
%37 = mul nsw i32 %36, 60
%38 = load i32, i32* %5
%39 = mul nsw i32 %38, 10
%40 = load i32, i32* %6
%41 = add nsw i32 %39, %40
%42 = add nsw i32 %37, %41
%43 = mul nsw i32 %42, 1000000
%44 = load i32, i32* %7
%45 = mul nsw i32 %44, 100
%46 = load i32, i32* %8
%47 = mul nsw i32 %46, 10
%48 = add nsw i32 %45, %47
%49 = mul nsw i32 %48, 1000
%50 = add nsw i32 %43, %49
ret i32 %50
}

LLVM IR (-O2):
define i32 @strtoint(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = tail call i32 @chartoint(i8 signext %2)
%4 = getelementptr inbounds i8, i8* %0, i64 1
%5 = load i8, i8* %4
%6 = tail call i32 @chartoint(i8 signext %5)
%7 = getelementptr inbounds i8, i8* %0, i64 3
%8 = load i8, i8* %7
%9 = tail call i32 @chartoint(i8 signext %8)
%10 = getelementptr inbounds i8, i8* %0, i64 4
%11 = load i8, i8* %10
%12 = tail call i32 @chartoint(i8 signext %11)
%13 = getelementptr inbounds i8, i8* %0, i64 6
%14 = load i8, i8* %13
%15 = tail call i32 @chartoint(i8 signext %14)
%16 = getelementptr inbounds i8, i8* %0, i64 7
%17 = load i8, i8* %16
%18 = tail call i32 @chartoint(i8 signext %17)
%19 = mul nsw i32 %3, 10
%20 = add nsw i32 %6, %19
%21 = mul nsw i32 %20, 60
%22 = mul nsw i32 %9, 10
%23 = add i32 %22, %21
%24 = add i32 %23, %12
%25 = mul nsw i32 %24, 1000000
%26 = mul nsw i32 %15, 100
%27 = mul nsw i32 %18, 10
%28 = add nsw i32 %27, %26
%29 = mul nsw i32 %28, 1000
%30 = add nsw i32 %29, %25
ret i32 %30
}