#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 /*<<< orphan*/ strchr(char *, char);
int strtoul(char *, char **, int);
int strtohhmm(char *str) {
  char *next;
  int hh, mm;
  if (!str)
    return -1;
  hh = strtoul(str, &next, 10);
  if (next <= str || !strchr(":hHuU", *next))
    return -1;
  mm = strtoul(next + 1, NULL, 10);
  return hh * 100 + mm;
}


x86 assembly (clang, -O0):
<strtohhmm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <strtohhmm+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b1 <strtohhmm+0x91>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jbe    1182 <strtohhmm+0x62>
mov    -0x18(%rbp),%rax
lea    0xe8f(%rip),%rdi
movsbl (%rax),%esi
call   1030 <strchr@plt>
cmp    $0x0,%eax
jne    118e <strtohhmm+0x6e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b1 <strtohhmm+0x91>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    %eax,-0x20(%rbp)
imul   $0x64,-0x1c(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strtohhmm>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0xffffffff,%r15d
test   %rdi,%rdi
je     117c <strtohhmm+0x5c>
mov    %rdi,%rbx
mov    %rsp,%rsi
mov    $0xa,%edx
call   1040 <strtoul@plt>
mov    (%rsp),%rbp
cmp    %rbx,%rbp
jbe    117c <strtohhmm+0x5c>
mov    %eax,%r14d
movsbl 0x0(%rbp),%esi
lea    0xea7(%rip),%rdi
call   1030 <strchr@plt>
test   %eax,%eax
je     117c <strtohhmm+0x5c>
add    $0x1,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtoul@plt>
imul   $0x64,%r14d,%r15d
add    %eax,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c":hHuU\00"
define i32 @strtohhmm(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = icmp ne i8* %7, null
br i1 %8, label %10, label %9
9: ; preds = %1
store i32 -1, i32* %2
br label %30
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @strtoul(i8* %11, i8** %4, i32 10)
store i32 %12, i32* %5
%13 = load i8*, i8** %4
%14 = load i8*, i8** %3
%15 = icmp ule i8* %13, %14
br i1 %15, label %21, label %16
16: ; preds = %10
%17 = load i8*, i8** %4
%18 = load i8, i8* %17
%19 = call i32 @strchr(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8 signext %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %16, %10
store i32 -1, i32* %2
br label %30
22: ; preds = %16
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = call i32 @strtoul(i8* %24, i8** null, i32 10)
store i32 %25, i32* %6
%26 = load i32, i32* %5
%27 = mul nsw i32 %26, 100
%28 = load i32, i32* %6
%29 = add nsw i32 %27, %28
store i32 %29, i32* %2
br label %30
30: ; preds = %22, %21, %9
%31 = load i32, i32* %2
ret i32 %31
}

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