#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*/ uint32_t;

/* Variables and functions */
scalar_t__ u_char_iscased(int /*<<< orphan*/);
scalar_t__ u_char_iscaseignorable(int /*<<< orphan*/);
int /*<<< orphan*/ u_decode(char const **, char const *, char const *);
int /*<<< orphan*/ u_decode_r(char const **, char const *, char const *);
bool is_final_sigma(const char *string, const char *p, const char *q,
                    const char *end) {
  if (p == string)
    return false;
  uint32_t c;
  while (q < end) {
    c = u_decode(&q, q, end);
    if (u_char_iscaseignorable(c))
      continue;
    if (u_char_iscased(c))
      return false;
    break;
  }
  while (string < p) {
    c = u_decode_r(&p, string, p);
    if (u_char_iscaseignorable(c))
      continue;
    if (u_char_iscased(c))
      return true;
    return false;
  }
  return false;
}


x86 assembly (clang, -O0):
<is_final_sigma>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    1172 <is_final_sigma+0x32>
movl   $0x0,-0x4(%rbp)
jmp    1242 <is_final_sigma+0x102>
jmp    1177 <is_final_sigma+0x37>
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11d3 <is_final_sigma+0x93>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    -0x20(%rbp),%rdi
call   1050 <u_decode@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1030 <u_char_iscaseignorable@plt>
cmp    $0x0,%rax
je     11b0 <is_final_sigma+0x70>
jmp    1177 <is_final_sigma+0x37>
mov    -0x2c(%rbp),%edi
call   1040 <u_char_iscased@plt>
cmp    $0x0,%rax
je     11ce <is_final_sigma+0x8e>
movl   $0x0,-0x4(%rbp)
jmp    1242 <is_final_sigma+0x102>
jmp    11d3 <is_final_sigma+0x93>
jmp    11d8 <is_final_sigma+0x98>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    123b <is_final_sigma+0xfb>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x18(%rbp),%rdi
call   1060 <u_decode_r@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
call   1030 <u_char_iscaseignorable@plt>
cmp    $0x0,%rax
je     1211 <is_final_sigma+0xd1>
jmp    11d8 <is_final_sigma+0x98>
mov    -0x2c(%rbp),%edi
call   1040 <u_char_iscased@plt>
cmp    $0x0,%rax
je     122f <is_final_sigma+0xef>
movl   $0x1,-0x4(%rbp)
jmp    1242 <is_final_sigma+0x102>
movl   $0x0,-0x4(%rbp)
jmp    1242 <is_final_sigma+0x102>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_final_sigma>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,0x10(%rsp)
mov    %rdx,0x8(%rsp)
xor    %r14d,%r14d
cmp    %rdi,%rsi
je     11f9 <is_final_sigma+0xb9>
mov    %rcx,%r13
mov    %rsi,%rbp
mov    %rdi,%r15
cmp    %rcx,%rdx
jae    11b4 <is_final_sigma+0x74>
lea    0x8(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rdx,%rsi
mov    %r13,%rdx
call   1050 <u_decode@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <u_char_iscaseignorable@plt>
test   %rax,%rax
je     11a8 <is_final_sigma+0x68>
mov    0x8(%rsp),%rdx
cmp    %r13,%rdx
jb     1180 <is_final_sigma+0x40>
jmp    11b4 <is_final_sigma+0x74>
mov    %ebx,%edi
call   1040 <u_char_iscased@plt>
test   %rax,%rax
jne    11f9 <is_final_sigma+0xb9>
cmp    %r15,%rbp
jbe    11f9 <is_final_sigma+0xb9>
lea    0x10(%rsp),%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1060 <u_decode_r@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <u_char_iscaseignorable@plt>
test   %rax,%rax
je     11e8 <is_final_sigma+0xa8>
mov    0x10(%rsp),%rbp
cmp    %r15,%rbp
ja     11c0 <is_final_sigma+0x80>
jmp    11f9 <is_final_sigma+0xb9>
mov    %ebp,%edi
call   1040 <u_char_iscased@plt>
xor    %r14d,%r14d
test   %rax,%rax
setne  %r14b
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @is_final_sigma(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
%11 = load i8*, i8** %7
%12 = load i8*, i8** %6
%13 = icmp eq i8* %11, %12
br i1 %13, label %14, label %15
14: ; preds = %4
store i32 0, i32* %5
br label %54
15: ; preds = %4
br label %16
16: ; preds = %27, %15
%17 = load i8*, i8** %8
%18 = load i8*, i8** %9
%19 = icmp ult i8* %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load i8*, i8** %8
%22 = load i8*, i8** %9
%23 = call i32 @u_decode(i8** %8, i8* %21, i8* %22)
store i32 %23, i32* %10
%24 = load i32, i32* %10
%25 = call i64 @u_char_iscaseignorable(i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %20
br label %16
28: ; preds = %20
%29 = load i32, i32* %10
%30 = call i64 @u_char_iscased(i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 0, i32* %5
br label %54
33: ; preds = %28
br label %34
34: ; preds = %33, %16
br label %35
35: ; preds = %46, %34
%36 = load i8*, i8** %6
%37 = load i8*, i8** %7
%38 = icmp ult i8* %36, %37
br i1 %38, label %39, label %53
39: ; preds = %35
%40 = load i8*, i8** %6
%41 = load i8*, i8** %7
%42 = call i32 @u_decode_r(i8** %7, i8* %40, i8* %41)
store i32 %42, i32* %10
%43 = load i32, i32* %10
%44 = call i64 @u_char_iscaseignorable(i32 %43)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %39
br label %35
47: ; preds = %39
%48 = load i32, i32* %10
%49 = call i64 @u_char_iscased(i32 %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %47
store i32 1, i32* %5
br label %54
52: ; preds = %47
store i32 0, i32* %5
br label %54
53: ; preds = %35
store i32 0, i32* %5
br label %54
54: ; preds = %53, %52, %51, %32, %14
%55 = load i32, i32* %5
ret i32 %55
}

LLVM IR (-O2):
define i32 @is_final_sigma(i8* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = icmp eq i8* %1, %0
br i1 %7, label %38, label %8
8: ; preds = %4
%9 = icmp ult i8* %2, %3
br i1 %9, label %10, label %23
10: ; preds = %8, %15
%11 = phi i8* [ %16, %15 ], [ %2, %8 ]
%12 = call i32 @u_decode(i8** %6, i8* %11, i8* %3)
%13 = call i64 @u_char_iscaseignorable(i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %10
%16 = load i8*, i8** %6
%17 = icmp ult i8* %16, %3
br i1 %17, label %10, label %23
18: ; preds = %10
%19 = call i64 @u_char_iscased(i32 %12)
%20 = icmp eq i64 %19, 0
%21 = icmp ugt i8* %1, %0
%22 = and i1 %20, %21
br i1 %22, label %25, label %38
23: ; preds = %15, %8
%24 = icmp ugt i8* %1, %0
br i1 %24, label %25, label %38
25: ; preds = %23, %18
br label %26
26: ; preds = %25, %31
%27 = phi i8* [ %32, %31 ], [ %1, %25 ]
%28 = call i32 @u_decode_r(i8** %5, i8* %0, i8* %27)
%29 = call i64 @u_char_iscaseignorable(i32 %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %34, label %31
31: ; preds = %26
%32 = load i8*, i8** %5
%33 = icmp ugt i8* %32, %0
br i1 %33, label %26, label %38
34: ; preds = %26
%35 = call i64 @u_char_iscased(i32 %28)
%36 = icmp ne i64 %35, 0
%37 = zext i1 %36 to i32
br label %38
38: ; preds = %31, %23, %18, %34, %4
%39 = phi i32 [ 0, %4 ], [ 0, %18 ], [ %37, %34 ], [ 0, %23 ], [ 0, %31 ]
ret i32 %39
}