#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 */
typedef int /*<<< orphan*/ regex_t;

/* Variables and functions */
int /*<<< orphan*/ REG_EXTENDED;
scalar_t__ regcomp(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int regexec(int /*<<< orphan*/ *, char *, int /*<<< orphan*/,
            int /*<<< orphan*/, int /*<<< orphan*/);
int validate(char *hour) {
  int rt;
  regex_t reg;
  if (regcomp(&reg, "(0[1-9]|1[0-2]):[0-5][0-9]:[0-5][0-9][AP]M",
              REG_EXTENDED) != 0)
    return 1;
  if ((rt = regexec(&reg, hour, 0, 0, 0)) != 0)
    return rt;
  return 0;
}


x86 assembly (clang, -O0):
<validate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rdi
lea    0xec0(%rip),%rsi
call   1030 <regcomp@plt>
cmp    $0x0,%rax
je     115b <validate+0x3b>
movl   $0x1,-0x4(%rbp)
jmp    118f <validate+0x6f>
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1040 <regexec@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1188 <validate+0x68>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    118f <validate+0x6f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    0x2eb1(%rip),%rax
mov    (%rax),%edx
lea    0xec8(%rip),%rsi
lea    0xc(%rsp),%rdi
call   1030 <regcomp@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
jne    1163 <validate+0x43>
lea    0xc(%rsp),%rdi
mov    %rbx,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1040 <regexec@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [43 x i8] c"(0[1-9]|1[0-2]):[0-5][0-9]:[0-5][0-9][AP]M\00"
@REG_EXTENDED = global i32 0
define i32 @validate(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i32, i32* @REG_EXTENDED
%7 = call i64 @regcomp(i32* %5, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %1
store i32 1, i32* %2
br label %17
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i32 @regexec(i32* %5, i8* %11, i32 0, i32 0, i32 0)
store i32 %12, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %10
%15 = load i32, i32* %4
store i32 %15, i32* %2
br label %17
16: ; preds = %10
store i32 0, i32* %2
br label %17
17: ; preds = %16, %14, %9
%18 = load i32, i32* %2
ret i32 %18
}

LLVM IR (-O2):
@.str = [43 x i8] c"(0[1-9]|1[0-2]):[0-5][0-9]:[0-5][0-9][AP]M\00"
@REG_EXTENDED = global i32 0
define i32 @validate(i8* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = load i32, i32* @REG_EXTENDED
%5 = call i64 @regcomp(i32* %2, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 @regexec(i32* %2, i8* %0, i32 0, i32 0, i32 0)
br label %9
9: ; preds = %7, %1
%10 = phi i32 [ 1, %1 ], [ %8, %7 ]
ret i32 %10
}