#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 */
struct tm {
  int tm_min;
  int tm_hour;
  scalar_t__ tm_sec;
};
struct timespec {
  scalar_t__ tv_sec;
  int /*<<< orphan*/ tv_nsec;
};

/* Variables and functions */
scalar_t__ parse_date_or_time(char *, char *, char const **, struct tm *,
                              int /*<<< orphan*/ *);
bool parse_time(const char **string, struct timespec *ts) {
  struct tm tm;
  return parse_date_or_time("%H:%M:%S", "Incomplete time, should be hh:mm:ss",
                            string, &tm, &ts->tv_nsec) &&
         ({
           ts->tv_sec = tm.tm_sec + 60 * (tm.tm_min + 60 * tm.tm_hour);
           true;
         });
}


x86 assembly (clang, -O0):
<parse_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%r8
add    $0x8,%r8
lea    0xecd(%rip),%rdi
lea    0xecf(%rip),%rsi
lea    -0x20(%rbp),%rcx
call   1030 <parse_date_or_time@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x25(%rbp)
je     1182 <parse_time+0x72>
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%eax
imul   $0x3c,-0x1c(%rbp),%edx
add    %edx,%eax
imul   $0x3c,%eax,%eax
cltq
add    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_time>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%rdx
lea    0x8(%rsi),%r8
lea    0xeda(%rip),%rdi
lea    0xedc(%rip),%rsi
mov    %rsp,%rcx
call   1030 <parse_date_or_time@plt>
test   %rax,%rax
je     1156 <parse_time+0x46>
movslq (%rsp),%rcx
movslq 0x4(%rsp),%rdx
imul   $0x3c,%rdx,%rdx
add    %rcx,%rdx
imul   $0x3c,%rdx,%rcx
add    0x8(%rsp),%rcx
mov    %rcx,(%rbx)
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
mov    %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i32 }
%struct.tm = type { i32, i32, i64 }
@.str = [9 x i8] c"%H:%M:%S\00"
@.str.1 = [36 x i8] c"Incomplete time, should be hh:mm:ss\00"
define i32 @parse_time(i8** %0, %struct.timespec* %1) {
%3 = alloca i8**
%4 = alloca %struct.timespec*
%5 = alloca %struct.tm
%6 = alloca i32
store i8** %0, i8*** %3
store %struct.timespec* %1, %struct.timespec** %4
%7 = load i8**, i8*** %3
%8 = load %struct.timespec*, %struct.timespec** %4
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %8, i32 0, i32 1
%10 = call i64 @parse_date_or_time(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8** %7, %struct.tm* %5, i32* %9)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %2
%13 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 2
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %5, i32 0, i32 1
%18 = load i32, i32* %17
%19 = mul nsw i32 60, %18
%20 = add nsw i32 %16, %19
%21 = mul nsw i32 60, %20
%22 = sext i32 %21 to i64
%23 = add nsw i64 %14, %22
%24 = load %struct.timespec*, %struct.timespec** %4
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %24, i32 0, i32 0
store i64 %23, i64* %25
store i32 1, i32* %6
%26 = load i32, i32* %6
%27 = icmp ne i32 %26, 0
br label %28
28: ; preds = %12, %2
%29 = phi i1 [ false, %2 ], [ %27, %12 ]
%30 = zext i1 %29 to i32
ret i32 %30
}

LLVM IR (-O2):
%struct.timespec = type { i64, i32 }
%struct.tm = type { i32, i32, i64 }
@.str = [9 x i8] c"%H:%M:%S\00"
@.str.1 = [36 x i8] c"Incomplete time, should be hh:mm:ss\00"
define i32 @parse_time(i8** %0, %struct.timespec* %1) {
%3 = alloca %struct.tm
%4 = bitcast %struct.tm* %3 to i8*
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%6 = call i64 @parse_date_or_time(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i8** %0, %struct.tm* %3, i32* %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %21, label %8
8: ; preds = %2
%9 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
%14 = load i32, i32* %13
%15 = mul nsw i32 %14, 60
%16 = add nsw i32 %15, %12
%17 = mul nsw i32 %16, 60
%18 = sext i32 %17 to i64
%19 = add nsw i64 %10, %18
%20 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
store i64 %19, i64* %20
br label %21
21: ; preds = %8, %2
%22 = xor i1 %7, true
%23 = zext i1 %22 to i32
ret i32 %23
}