#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 dd_strtime2int(const char *time) {
  int rc, h, m, s;
  if (!time)
    return 0;
  rc = sscanf(time, "%u:%u:%u", &h, &m, &s);
  if (rc != 3)
    return 0;
  return h * 3600 + m * 60 + s;
}


x86 assembly (clang, -O0):
<dd_strtime2int>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <dd_strtime2int+0x23>
movl   $0x0,-0x4(%rbp)
jmp    117b <dd_strtime2int+0x6b>
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 <dd_strtime2int+0x58>
movl   $0x0,-0x4(%rbp)
jmp    117b <dd_strtime2int+0x6b>
imul   $0xe10,-0x18(%rbp),%eax
imul   $0x3c,-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):
<dd_strtime2int>:
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
test   %rdi,%rdi
je     114f <dd_strtime2int+0x3f>
lea    0xedd(%rip),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
call   1030 <sscanf@plt>
cmp    $0x3,%eax
jne    114f <dd_strtime2int+0x3f>
imul   $0xe10,0xc(%rsp),%eax
imul   $0x3c,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"%u:%u:%u\00"
define i32 @dd_strtime2int(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 %25
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 %25
17: ; preds = %11
%18 = load i32, i32* %5
%19 = mul nsw i32 %18, 3600
%20 = load i32, i32* %6
%21 = mul nsw i32 %20, 60
%22 = add nsw i32 %19, %21
%23 = load i32, i32* %7
%24 = add nsw i32 %22, %23
store i32 %24, i32* %2
br label %25
25: ; preds = %17, %16, %10
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [9 x i8] c"%u:%u:%u\00"
define i32 @dd_strtime2int(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 nsw i32 %13, 3600
%15 = load i32, i32* %3
%16 = mul nsw i32 %15, 60
%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
}