#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_hour;
  int tm_min;
  int tm_sec;
};

/* Variables and functions */
int /*<<< orphan*/ scan_ulong(char const *, unsigned long *);
int parsetime(const char *c, struct tm *x) {
  unsigned long tmp;
  c += scan_ulong(c, &tmp);
  x->tm_hour = (int)tmp;
  if (*c != ':')
    return -1;
  ++c;
  c += scan_ulong(c, &tmp);
  x->tm_min = (int)tmp;
  if (*c != ':')
    return -1;
  ++c;
  c += scan_ulong(c, &tmp);
  x->tm_sec = (int)tmp;
  if (*c != ' ')
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<parsetime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <scan_ulong@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     1165 <parsetime+0x55>
movl   $0xffffffff,-0x4(%rbp)
jmp    1210 <parsetime+0x100>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <scan_ulong@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
je     11b7 <parsetime+0xa7>
movl   $0xffffffff,-0x4(%rbp)
jmp    1210 <parsetime+0x100>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <scan_ulong@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     1209 <parsetime+0xf9>
movl   $0xffffffff,-0x4(%rbp)
jmp    1210 <parsetime+0x100>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parsetime>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1030 <scan_ulong@plt>
cltq
mov    0x8(%rsp),%ecx
mov    %ecx,(%r14)
mov    $0xffffffff,%ebp
cmpb   $0x3a,(%rbx,%rax,1)
jne    118a <parsetime+0x7a>
add    %rax,%rbx
lea    0x1(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1030 <scan_ulong@plt>
cltq
mov    0x8(%rsp),%ecx
mov    %ecx,0x4(%r14)
cmpb   $0x3a,0x1(%rbx,%rax,1)
jne    118a <parsetime+0x7a>
add    %rax,%rbx
add    $0x1,%rbx
lea    0x1(%rbx),%rdi
lea    0x8(%rsp),%rsi
call   1030 <scan_ulong@plt>
cltq
mov    0x8(%rsp),%ecx
mov    %ecx,0x8(%r14)
xor    %ebp,%ebp
cmpb   $0x20,0x1(%rbx,%rax,1)
setne  %bpl
neg    %ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
define i32 @parsetime(i8* %0, %struct.tm* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca %struct.tm*
%6 = alloca i64
store i8* %0, i8** %4
store %struct.tm* %1, %struct.tm** %5
%7 = load i8*, i8** %4
%8 = call i32 @scan_ulong(i8* %7, i64* %6)
%9 = load i8*, i8** %4
%10 = sext i32 %8 to i64
%11 = getelementptr inbounds i8, i8* %9, i64 %10
store i8* %11, i8** %4
%12 = load i64, i64* %6
%13 = trunc i64 %12 to i32
%14 = load %struct.tm*, %struct.tm** %5
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 0
store i32 %13, i32* %15
%16 = load i8*, i8** %4
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 58
br i1 %19, label %20, label %21
20: ; preds = %2
store i32 -1, i32* %3
br label %56
21: ; preds = %2
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
%24 = load i8*, i8** %4
%25 = call i32 @scan_ulong(i8* %24, i64* %6)
%26 = load i8*, i8** %4
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds i8, i8* %26, i64 %27
store i8* %28, i8** %4
%29 = load i64, i64* %6
%30 = trunc i64 %29 to i32
%31 = load %struct.tm*, %struct.tm** %5
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 1
store i32 %30, i32* %32
%33 = load i8*, i8** %4
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 58
br i1 %36, label %37, label %38
37: ; preds = %21
store i32 -1, i32* %3
br label %56
38: ; preds = %21
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
%41 = load i8*, i8** %4
%42 = call i32 @scan_ulong(i8* %41, i64* %6)
%43 = load i8*, i8** %4
%44 = sext i32 %42 to i64
%45 = getelementptr inbounds i8, i8* %43, i64 %44
store i8* %45, i8** %4
%46 = load i64, i64* %6
%47 = trunc i64 %46 to i32
%48 = load %struct.tm*, %struct.tm** %5
%49 = getelementptr inbounds %struct.tm, %struct.tm* %48, i32 0, i32 2
store i32 %47, i32* %49
%50 = load i8*, i8** %4
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp ne i32 %52, 32
br i1 %53, label %54, label %55
54: ; preds = %38
store i32 -1, i32* %3
br label %56
55: ; preds = %38
store i32 0, i32* %3
br label %56
56: ; preds = %55, %54, %37, %20
%57 = load i32, i32* %3
ret i32 %57
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
define i32 @parsetime(i8* %0, %struct.tm* nocapture writeonly %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = call i32 @scan_ulong(i8* %0, i64* %3)
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %0, i64 %6
%8 = load i64, i64* %3
%9 = trunc i64 %8 to i32
%10 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 0
store i32 %9, i32* %10
%11 = load i8, i8* %7
%12 = icmp eq i8 %11, 58
br i1 %12, label %13, label %34
13: ; preds = %2
%14 = getelementptr inbounds i8, i8* %7, i64 1
%15 = call i32 @scan_ulong(i8* %14, i64* %3)
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i64, i64* %3
%19 = trunc i64 %18 to i32
%20 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 1
store i32 %19, i32* %20
%21 = load i8, i8* %17
%22 = icmp eq i8 %21, 58
br i1 %22, label %23, label %34
23: ; preds = %13
%24 = getelementptr inbounds i8, i8* %17, i64 1
%25 = call i32 @scan_ulong(i8* %24, i64* %3)
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i64, i64* %3
%29 = trunc i64 %28 to i32
%30 = getelementptr inbounds %struct.tm, %struct.tm* %1, i64 0, i32 2
store i32 %29, i32* %30
%31 = load i8, i8* %27
%32 = icmp ne i8 %31, 32
%33 = sext i1 %32 to i32
br label %34
34: ; preds = %23, %13, %2
%35 = phi i32 [ -1, %2 ], [ -1, %13 ], [ %33, %23 ]
ret i32 %35
}