#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 *, int *);
int get_time(char *strptr, int *hour, int *min, int *sec) {
  int fields_found = 0;
  int sign;
  fields_found = sscanf(strptr, "%i:%i:%i", hour, min, sec);
  switch (fields_found) {
  case 0:
    *hour = 2;
  case 1:
    *min = 0;
  case 2:
    *sec = 0;
  }
  sign = *hour < 0 ? -1 : 1;
  return (*hour * 3600) + (sign * ((*min * 60) + *sec));
}


x86 assembly (clang, -O0):
<get_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
lea    0xeba(%rip),%rsi
call   1030 <sscanf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
test   %eax,%eax
je     1183 <get_time+0x73>
jmp    1161 <get_time+0x51>
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
je     118d <get_time+0x7d>
jmp    1172 <get_time+0x62>
mov    -0x2c(%rbp),%eax
sub    $0x2,%eax
je     1197 <get_time+0x87>
jmp    11a1 <get_time+0x91>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
mov    $0x1,%eax
mov    $0xffffffff,%ecx
cmp    $0x0,%edx
cmovl  %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
imul   $0xe10,(%rax),%eax
mov    -0x28(%rbp),%ecx
mov    -0x18(%rbp),%rdx
imul   $0x3c,(%rdx),%edx
mov    -0x20(%rbp),%rsi
add    (%rsi),%edx
imul   %edx,%ecx
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_time>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %rsi,%r14
lea    0xedb(%rip),%rsi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
call   1030 <sscanf@plt>
test   %eax,%eax
je     1146 <get_time+0x36>
cmp    $0x1,%eax
je     114d <get_time+0x3d>
cmp    $0x2,%eax
je     1153 <get_time+0x43>
mov    (%r15),%eax
jmp    115c <get_time+0x4c>
movl   $0x2,(%r14)
movl   $0x0,(%rbx)
movl   $0x0,(%r15)
xor    %eax,%eax
mov    (%r14),%ecx
imul   $0xe10,%ecx,%edx
imul   $0x3c,(%rbx),%esi
add    %eax,%esi
mov    %esi,%eax
neg    %eax
test   %ecx,%ecx
cmovns %esi,%eax
add    %edx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%i:%i:%i\00"
define i32 @get_time(i8* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
store i32 0, i32* %9
%11 = load i8*, i8** %5
%12 = load i32*, i32** %6
%13 = load i32*, i32** %7
%14 = load i32*, i32** %8
%15 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %12, i32* %13, i32* %14)
store i32 %15, i32* %9
%16 = load i32, i32* %9
switch i32 %16, label %23 [
i32 0, label %17
i32 1, label %19
i32 2, label %21
]
17: ; preds = %4
%18 = load i32*, i32** %6
store i32 2, i32* %18
br label %19
19: ; preds = %4, %17
%20 = load i32*, i32** %7
store i32 0, i32* %20
br label %21
21: ; preds = %4, %19
%22 = load i32*, i32** %8
store i32 0, i32* %22
br label %23
23: ; preds = %21, %4
%24 = load i32*, i32** %6
%25 = load i32, i32* %24
%26 = icmp slt i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i32 -1, i32 1
store i32 %28, i32* %10
%29 = load i32*, i32** %6
%30 = load i32, i32* %29
%31 = mul nsw i32 %30, 3600
%32 = load i32, i32* %10
%33 = load i32*, i32** %7
%34 = load i32, i32* %33
%35 = mul nsw i32 %34, 60
%36 = load i32*, i32** %8
%37 = load i32, i32* %36
%38 = add nsw i32 %35, %37
%39 = mul nsw i32 %32, %38
%40 = add nsw i32 %31, %39
ret i32 %40
}

LLVM IR (-O2):
@.str = [9 x i8] c"%i:%i:%i\00"
define i32 @get_time(i8* nocapture %0, i32* %1, i32* %2, i32* %3) {
%5 = tail call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2, i32* %3)
switch i32 %5, label %6 [
i32 0, label %8
i32 1, label %9
i32 2, label %10
]
6: ; preds = %4
%7 = load i32, i32* %3
br label %11
8: ; preds = %4
store i32 2, i32* %1
br label %9
9: ; preds = %4, %8
store i32 0, i32* %2
br label %10
10: ; preds = %4, %9
store i32 0, i32* %3
br label %11
11: ; preds = %6, %10
%12 = phi i32 [ %7, %6 ], [ 0, %10 ]
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, -1
%15 = mul nsw i32 %13, 3600
%16 = load i32, i32* %2
%17 = mul nsw i32 %16, 60
%18 = add nsw i32 %17, %12
%19 = sub nsw i32 0, %18
%20 = select i1 %14, i32 %18, i32 %19
%21 = add nsw i32 %20, %15
ret i32 %21
}