#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__ tolower(char const);
int gs_is_caseaffix(const char *string, const char *affix) {
  while (*affix) {
    if (tolower(*string) != tolower(*affix))
      return 0;
    string++;
    affix++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<gs_is_caseaffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1182 <gs_is_caseaffix+0x72>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <tolower@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     1165 <gs_is_caseaffix+0x55>
movl   $0x0,-0x4(%rbp)
jmp    1189 <gs_is_caseaffix+0x79>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <gs_is_caseaffix+0x10>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gs_is_caseaffix>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%r14d
cmpb   $0x0,(%rsi)
je     115d <gs_is_caseaffix+0x4d>
mov    %rsi,%r12
mov    %rdi,%r15
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1030 <tolower@plt>
mov    %rax,%rbp
movsbl (%r12,%rbx,1),%edi
call   1030 <tolower@plt>
cmp    %rax,%rbp
jne    115a <gs_is_caseaffix+0x4a>
cmpb   $0x0,0x1(%r12,%rbx,1)
lea    0x1(%rbx),%rbx
jne    1130 <gs_is_caseaffix+0x20>
jmp    115d <gs_is_caseaffix+0x4d>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @gs_is_caseaffix(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 = %19, %2
%7 = load i8*, i8** %5
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
%13 = call i64 @tolower(i8 signext %12)
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = call i64 @tolower(i8 signext %15)
%17 = icmp ne i64 %13, %16
br i1 %17, label %18, label %19
18: ; preds = %10
store i32 0, i32* %3
br label %25
19: ; preds = %10
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
%22 = load i8*, i8** %5
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %5
br label %6
24: ; preds = %6
store i32 1, i32* %3
br label %25
25: ; preds = %24, %18
%26 = load i32, i32* %3
ret i32 %26
}

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