#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__ charsequalcaseless(char const, char const);
int MHD_str_equal_caseless_n_(const char *const str1, const char *const str2,
                              size_t maxlen) {
  size_t i;
  for (i = 0; i < maxlen; ++i) {
    const char c1 = str1[i];
    const char c2 = str2[i];
    if (0 == c2)
      return 0 == c1;
    if (charsequalcaseless(c1, c2))
      continue;
    else
      return 0;
  }
  return !0;
}


x86 assembly (clang, -O0):
<MHD_str_equal_caseless_n_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    11b7 <MHD_str_equal_caseless_n_+0xa7>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x29(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x2a(%rbp)
movsbl -0x2a(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
jne    117c <MHD_str_equal_caseless_n_+0x6c>
movsbl -0x29(%rbp),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11be <MHD_str_equal_caseless_n_+0xae>
mov    -0x29(%rbp),%al
movsbl %al,%edi
movsbl -0x2a(%rbp),%esi
call   1030 <charsequalcaseless@plt>
cmp    $0x0,%rax
je     119a <MHD_str_equal_caseless_n_+0x8a>
jmp    11a6 <MHD_str_equal_caseless_n_+0x96>
movl   $0x0,-0x4(%rbp)
jmp    11be <MHD_str_equal_caseless_n_+0xae>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    112c <MHD_str_equal_caseless_n_+0x1c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MHD_str_equal_caseless_n_>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x1,%r14d
test   %rdx,%rdx
je     1167 <MHD_str_equal_caseless_n_+0x57>
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
xor    %ebp,%ebp
xchg   %ax,%ax
movzbl (%r12,%rbp,1),%eax
movzbl (%r15,%rbp,1),%ecx
test   %cl,%cl
je     1159 <MHD_str_equal_caseless_n_+0x49>
movsbl %al,%edi
movsbl %cl,%esi
call   1030 <charsequalcaseless@plt>
test   %rax,%rax
je     1164 <MHD_str_equal_caseless_n_+0x54>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1130 <MHD_str_equal_caseless_n_+0x20>
jmp    1167 <MHD_str_equal_caseless_n_+0x57>
xor    %r14d,%r14d
test   %al,%al
sete   %r14b
jmp    1167 <MHD_str_equal_caseless_n_+0x57>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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