#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 */
scalar_t__ isspace(char const);
scalar_t__ toupper(char const);
int detectsuffix(const char *str, const char *suffix) {
  while (toupper(*str) == toupper(*suffix)) {
    if (*str == '\0')
      return 1;
    str++;
    suffix++;
  }
  if (*suffix != 0)
    return 0;
  while (isspace(*str))
    str++;
  return (*str == '\0') ? 1 : 0;
}


x86 assembly (clang, -O0):
<detectsuffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jne    1195 <detectsuffix+0x75>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    1178 <detectsuffix+0x58>
movl   $0x1,-0x4(%rbp)
jmp    11f4 <detectsuffix+0xd4>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1130 <detectsuffix+0x10>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b1 <detectsuffix+0x91>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <detectsuffix+0xd4>
jmp    11b6 <detectsuffix+0x96>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
je     11dd <detectsuffix+0xbd>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11b6 <detectsuffix+0x96>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<detectsuffix>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1030 <toupper@plt>
mov    %rax,%r15
movsbl (%r14),%edi
call   1030 <toupper@plt>
cmp    %rax,%r15
jne    117d <detectsuffix+0x5d>
nopw   0x0(%rax,%rax,1)
cmpb   $0x0,(%rbx)
je     11ac <detectsuffix+0x8c>
lea    0x1(%r14),%r12
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <toupper@plt>
mov    %rax,%r15
movsbl 0x1(%r14),%edi
call   1030 <toupper@plt>
mov    %r12,%r14
cmp    %rax,%r15
je     1150 <detectsuffix+0x30>
jmp    1180 <detectsuffix+0x60>
mov    %r14,%r12
xor    %eax,%eax
cmpb   $0x0,(%r12)
jne    11b1 <detectsuffix+0x91>
nopl   0x0(%rax)
movsbl (%rbx),%edi
call   1040 <isspace@plt>
add    $0x1,%rbx
test   %rax,%rax
jne    1190 <detectsuffix+0x70>
xor    %eax,%eax
cmpb   $0x0,-0x1(%rbx)
sete   %al
jmp    11b1 <detectsuffix+0x91>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @detectsuffix(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
br label %6
6: ; preds = %20, %2
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = call i64 @toupper(i8 signext %8)
%10 = load i8*, i8** %5
%11 = load i8, i8* %10
%12 = call i64 @toupper(i8 signext %11)
%13 = icmp eq i64 %9, %12
br i1 %13, label %14, label %25
14: ; preds = %6
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 1, i32* %3
br label %47
20: ; preds = %14
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %5
br label %6
25: ; preds = %6
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %25
store i32 0, i32* %3
br label %47
31: ; preds = %25
br label %32
32: ; preds = %37, %31
%33 = load i8*, i8** %4
%34 = load i8, i8* %33
%35 = call i64 @isspace(i8 signext %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %4
br label %32
40: ; preds = %32
%41 = load i8*, i8** %4
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 0
%45 = zext i1 %44 to i64
%46 = select i1 %44, i32 1, i32 0
store i32 %46, i32* %3
br label %47
47: ; preds = %40, %30, %19
%48 = load i32, i32* %3
ret i32 %48
}

LLVM IR (-O2):
define i32 @detectsuffix(i8* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %0
%4 = tail call i64 @toupper(i8 signext %3)
%5 = load i8, i8* %1
%6 = tail call i64 @toupper(i8 signext %5)
%7 = icmp eq i64 %4, %6
br i1 %7, label %8, label %21
8: ; preds = %2, %13
%9 = phi i8* [ %15, %13 ], [ %1, %2 ]
%10 = phi i8* [ %14, %13 ], [ %0, %2 ]
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
br i1 %12, label %36, label %13
13: ; preds = %8
%14 = getelementptr inbounds i8, i8* %10, i64 1
%15 = getelementptr inbounds i8, i8* %9, i64 1
%16 = load i8, i8* %14
%17 = tail call i64 @toupper(i8 signext %16)
%18 = load i8, i8* %15
%19 = tail call i64 @toupper(i8 signext %18)
%20 = icmp eq i64 %17, %19
br i1 %20, label %8, label %21
21: ; preds = %13, %2
%22 = phi i8* [ %0, %2 ], [ %14, %13 ]
%23 = phi i8* [ %1, %2 ], [ %15, %13 ]
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 0
br i1 %25, label %26, label %36
26: ; preds = %21, %26
%27 = phi i8* [ %31, %26 ], [ %22, %21 ]
%28 = load i8, i8* %27
%29 = tail call i64 @isspace(i8 signext %28)
%30 = icmp eq i64 %29, 0
%31 = getelementptr inbounds i8, i8* %27, i64 1
br i1 %30, label %32, label %26
32: ; preds = %26
%33 = load i8, i8* %27
%34 = icmp eq i8 %33, 0
%35 = zext i1 %34 to i32
br label %36
36: ; preds = %8, %21, %32
%37 = phi i32 [ %35, %32 ], [ 0, %21 ], [ 1, %8 ]
ret i32 %37
}