#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 *, char *, int *, int *);
char *strstr(char *, char *);
int getlogtime(char *line) {
  int s, m;
  char *ptr;
  ptr = strstr(line, "2002:");
  if (!ptr)
    return -1;
  ptr += 8;
  if (sscanf(ptr, "%d:%d", &m, &s) != 2)
    return -1;
  return m * 60 + s;
}


x86 assembly (clang, -O0):
<getlogtime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec9(%rip),%rsi
call   1040 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1157 <getlogtime+0x37>
movl   $0xffffffff,-0x4(%rbp)
jmp    119a <getlogtime+0x7a>
mov    -0x20(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe98(%rip),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x14(%rbp),%rcx
call   1030 <sscanf@plt>
cmp    $0x2,%eax
je     1190 <getlogtime+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    119a <getlogtime+0x7a>
imul   $0x3c,-0x18(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getlogtime>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rsi
call   1040 <strstr@plt>
mov    $0xffffffff,%ebx
test   %rax,%rax
je     1166 <getlogtime+0x46>
add    $0x8,%rax
lea    0xec0(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
mov    %rax,%rdi
call   1030 <sscanf@plt>
cmp    $0x2,%eax
jne    1166 <getlogtime+0x46>
imul   $0x3c,0x8(%rsp),%ebx
add    0xc(%rsp),%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

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