#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 ext_cmp_exten(char const *, char const *);
int ext_cmp_pattern(char const *, char const *);
int ext_cmp(const char *left, const char *right) {
  if (left[0] != '_') {
    if (right[0] == '_') {
      return -1;
    }
    return ext_cmp_exten(left, right);
  }
  if (right[0] != '_') {
    return 1;
  }
  return ext_cmp_pattern(left + 1, right + 1);
}


x86 assembly (clang, -O0):
<ext_cmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1171 <ext_cmp+0x51>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
jne    115c <ext_cmp+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11a5 <ext_cmp+0x85>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <ext_cmp_exten@plt>
mov    %eax,-0x4(%rbp)
jmp    11a5 <ext_cmp+0x85>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     118d <ext_cmp+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    11a5 <ext_cmp+0x85>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
call   1030 <ext_cmp_pattern@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ext_cmp>:
cmpb   $0x5f,(%rdi)
mov    (%rsi),%cl
jne    113e <ext_cmp+0x1e>
mov    $0x1,%eax
cmp    $0x5f,%cl
jne    1148 <ext_cmp+0x28>
add    $0x1,%rdi
add    $0x1,%rsi
jmp    1030 <ext_cmp_pattern@plt>
mov    $0xffffffff,%eax
cmp    $0x5f,%cl
jne    1149 <ext_cmp+0x29>
ret
jmp    1040 <ext_cmp_exten@plt>

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

LLVM IR (-O2):
define i32 @ext_cmp(i8* %0, i8* %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 95
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 95
br i1 %4, label %10, label %7
7: ; preds = %2
br i1 %6, label %15, label %8
8: ; preds = %7
%9 = tail call i32 @ext_cmp_exten(i8* %0, i8* %1)
br label %15
10: ; preds = %2
br i1 %6, label %11, label %15
11: ; preds = %10
%12 = getelementptr inbounds i8, i8* %0, i64 1
%13 = getelementptr inbounds i8, i8* %1, i64 1
%14 = tail call i32 @ext_cmp_pattern(i8* %12, i8* %13)
br label %15
15: ; preds = %10, %7, %11, %8
%16 = phi i32 [ %9, %8 ], [ %14, %11 ], [ -1, %7 ], [ 1, %10 ]
ret i32 %16
}