#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*/ isdigit(char const);
char *strchr(char const *, char);
const char *find_base_60(const char *buff) {
  const char *rval = strchr(buff + 3, ':');
  int i;
  if (rval) {
    rval -= 2;
    for (i = 0; rval && i < 8; i++)
      if (i == 2 || i == 5) {
        if (rval[i] != ':')
          rval = NULL;
      } else if (!isdigit(rval[i]))
        rval = NULL;
  }
  return (rval);
}


x86 assembly (clang, -O0):
<find_base_60>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
add    $0x3,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11ff <find_base_60+0xdf>
mov    -0x10(%rbp),%rax
add    $0xfffffffffffffffe,%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x15(%rbp)
je     117a <find_base_60+0x5a>
cmpl   $0x8,-0x14(%rbp)
setl   %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    118a <find_base_60+0x6a>
jmp    11fa <find_base_60+0xda>
cmpl   $0x2,-0x14(%rbp)
je     119e <find_base_60+0x7e>
cmpl   $0x5,-0x14(%rbp)
jne    11c0 <find_base_60+0xa0>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3a,%eax
je     11bb <find_base_60+0x9b>
movq   $0x0,-0x10(%rbp)
jmp    11e7 <find_base_60+0xc7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    11e2 <find_base_60+0xc2>
movq   $0x0,-0x10(%rbp)
jmp    11e7 <find_base_60+0xc7>
jmp    11ec <find_base_60+0xcc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1160 <find_base_60+0x40>
jmp    11ff <find_base_60+0xdf>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_base_60>:
push   %r14
push   %rbx
push   %rax
add    $0x3,%rdi
mov    $0x3a,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1180 <find_base_60+0x60>
mov    %rax,%r14
add    $0xfffffffffffffffe,%r14
xor    %ebx,%ebx
cmp    $0x5,%ebx
je     114a <find_base_60+0x2a>
cmp    $0x2,%ebx
jne    1170 <find_base_60+0x50>
cmpb   $0x3a,(%r14,%rbx,1)
je     1154 <find_base_60+0x34>
xor    %r14d,%r14d
test   %r14,%r14
je     1183 <find_base_60+0x63>
lea    0x1(%rbx),%rax
cmp    $0x7,%rbx
mov    %rax,%rbx
jb     1140 <find_base_60+0x20>
jmp    1183 <find_base_60+0x63>
nopl   0x0(%rax,%rax,1)
movsbl (%r14,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %eax,%eax
je     1151 <find_base_60+0x31>
jmp    1154 <find_base_60+0x34>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @find_base_60(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = getelementptr inbounds i8, i8* %5, i64 3
%7 = call i8* @strchr(i8* %6, i8 signext 58)
store i8* %7, i8** %3
%8 = load i8*, i8** %3
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %52
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 -2
store i8* %12, i8** %3
store i32 0, i32* %4
br label %13
13: ; preds = %48, %10
%14 = load i8*, i8** %3
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 8
br label %19
19: ; preds = %16, %13
%20 = phi i1 [ false, %13 ], [ %18, %16 ]
br i1 %20, label %21, label %51
21: ; preds = %19
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 2
br i1 %23, label %27, label %24
24: ; preds = %21
%25 = load i32, i32* %4
%26 = icmp eq i32 %25, 5
br i1 %26, label %27, label %37
27: ; preds = %24, %21
%28 = load i8*, i8** %3
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 58
br i1 %34, label %35, label %36
35: ; preds = %27
store i8* null, i8** %3
br label %36
36: ; preds = %35, %27
br label %47
37: ; preds = %24
%38 = load i8*, i8** %3
%39 = load i32, i32* %4
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = call i32 @isdigit(i8 signext %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %46, label %45
45: ; preds = %37
store i8* null, i8** %3
br label %46
46: ; preds = %45, %37
br label %47
47: ; preds = %46, %36
br label %48
48: ; preds = %47
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %13
51: ; preds = %19
br label %52
52: ; preds = %51, %1
%53 = load i8*, i8** %3
ret i8* %53
}

LLVM IR (-O2):
define i8* @find_base_60(i8* %0) {
%2 = getelementptr inbounds i8, i8* %0, i64 3
%3 = tail call i8* @strchr(i8* %2, i8 signext 58)
%4 = icmp eq i8* %3, null
br i1 %4, label %28, label %5
5: ; preds = %1
%6 = getelementptr inbounds i8, i8* %3, i64 -2
br label %7
7: ; preds = %5, %22
%8 = phi i64 [ 0, %5 ], [ %24, %22 ]
%9 = phi i8* [ %6, %5 ], [ %23, %22 ]
%10 = trunc i64 %8 to i32
switch i32 %10, label %16 [
i32 5, label %11
i32 2, label %11
]
11: ; preds = %7, %7
%12 = getelementptr inbounds i8, i8* %9, i64 %8
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 58
%15 = select i1 %14, i8* %9, i8* null
br label %22
16: ; preds = %7
%17 = getelementptr inbounds i8, i8* %9, i64 %8
%18 = load i8, i8* %17
%19 = tail call i32 @isdigit(i8 signext %18)
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i8* null, i8* %9
br label %22
22: ; preds = %16, %11
%23 = phi i8* [ %15, %11 ], [ %21, %16 ]
%24 = add nuw nsw i64 %8, 1
%25 = icmp ne i8* %23, null
%26 = icmp ult i64 %8, 7
%27 = select i1 %25, i1 %26, i1 false
br i1 %27, label %7, label %28
28: ; preds = %22, %1
%29 = phi i8* [ null, %1 ], [ %23, %22 ]
ret i8* %29
}