#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 */
char *strchr(char const *, char);
int strlen(char const *);
int is_revision_metadata(const char *buff) {
  char *p1, *p2;
  int len;
  if (!(p1 = strchr(buff, ':')))
    return 0;
  p2 = strchr(buff, ' ');
  if (p2 && p2 < p1)
    return 0;
  len = strlen(buff);
  if (len > 1 && buff[len - 2] == ';')
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<is_revision_metadata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1154 <is_revision_metadata+0x34>
movl   $0x0,-0x4(%rbp)
jmp    11ce <is_revision_metadata+0xae>
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     118b <is_revision_metadata+0x6b>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    118b <is_revision_metadata+0x6b>
movl   $0x0,-0x4(%rbp)
jmp    11ce <is_revision_metadata+0xae>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jle    11c7 <is_revision_metadata+0xa7>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
sub    $0x2,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3b,%eax
jne    11c7 <is_revision_metadata+0xa7>
movl   $0x1,-0x4(%rbp)
jmp    11ce <is_revision_metadata+0xae>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_revision_metadata>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    $0x3a,%esi
call   1040 <strchr@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     1172 <is_revision_metadata+0x52>
mov    %rax,%rbp
mov    %rbx,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1153 <is_revision_metadata+0x33>
cmp    %rbp,%rax
jb     1172 <is_revision_metadata+0x52>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x2,%eax
jl     116f <is_revision_metadata+0x4f>
add    $0xfffffffe,%eax
mov    $0x1,%r14d
cmpb   $0x3b,(%rbx,%rax,1)
je     1172 <is_revision_metadata+0x52>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_revision_metadata(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
%7 = load i8*, i8** %3
%8 = call i8* @strchr(i8* %7, i8 signext 58)
store i8* %8, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 0, i32* %2
br label %37
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i8* @strchr(i8* %12, i8 signext 32)
store i8* %13, i8** %5
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %21
16: ; preds = %11
%17 = load i8*, i8** %5
%18 = load i8*, i8** %4
%19 = icmp ult i8* %17, %18
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 0, i32* %2
br label %37
21: ; preds = %16, %11
%22 = load i8*, i8** %3
%23 = call i32 @strlen(i8* %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp sgt i32 %24, 1
br i1 %25, label %26, label %36
26: ; preds = %21
%27 = load i8*, i8** %3
%28 = load i32, i32* %6
%29 = sub nsw i32 %28, 2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 59
br i1 %34, label %35, label %36
35: ; preds = %26
store i32 1, i32* %2
br label %37
36: ; preds = %26, %21
store i32 0, i32* %2
br label %37
37: ; preds = %36, %35, %20, %10
%38 = load i32, i32* %2
ret i32 %38
}

LLVM IR (-O2):
define i32 @is_revision_metadata(i8* %0) {
%2 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 58)
%3 = icmp eq i8* %2, null
br i1 %3, label %19, label %4
4: ; preds = %1
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 32)
%6 = icmp ne i8* %5, null
%7 = icmp ult i8* %5, %2
%8 = select i1 %6, i1 %7, i1 false
br i1 %8, label %19, label %9
9: ; preds = %4
%10 = tail call i32 @strlen(i8* %0)
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %18
12: ; preds = %9
%13 = add nsw i32 %10, -2
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 59
br i1 %17, label %19, label %18
18: ; preds = %12, %9
br label %19
19: ; preds = %12, %4, %1, %18
%20 = phi i32 [ 0, %18 ], [ 0, %1 ], [ 0, %4 ], [ 1, %12 ]
ret i32 %20
}