#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 /*<<< orphan*/ assert(char const *);
scalar_t__ strncasecmp(char const *, char const *, size_t);
int trio_equal_max(const char *first, size_t max, const char *second) {
  assert(first);
  assert(second);
  if ((first != 0) && (second != 0)) {
    return (0 == strncasecmp(first, second, max));
  }
  return (1 == 0);
}


x86 assembly (clang, -O0):
<trio_equal_max>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <assert@plt>
mov    -0x20(%rbp),%rdi
call   1030 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
je     1185 <trio_equal_max+0x65>
cmpq   $0x0,-0x20(%rbp)
je     1185 <trio_equal_max+0x65>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <strncasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    118c <trio_equal_max+0x6c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<trio_equal_max>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <assert@plt>
mov    %r15,%rdi
call   1030 <assert@plt>
xor    %eax,%eax
test   %rbx,%rbx
je     1160 <trio_equal_max+0x40>
test   %r15,%r15
je     1160 <trio_equal_max+0x40>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <strncasecmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @trio_equal_max(i8* %0, i64 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
%8 = load i8*, i8** %5
%9 = call i32 @assert(i8* %8)
%10 = load i8*, i8** %7
%11 = call i32 @assert(i8* %10)
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %24
14: ; preds = %3
%15 = load i8*, i8** %7
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i8*, i8** %5
%19 = load i8*, i8** %7
%20 = load i64, i64* %6
%21 = call i64 @strncasecmp(i8* %18, i8* %19, i64 %20)
%22 = icmp eq i64 0, %21
%23 = zext i1 %22 to i32
store i32 %23, i32* %4
br label %25
24: ; preds = %14, %3
store i32 0, i32* %4
br label %25
25: ; preds = %24, %17
%26 = load i32, i32* %4
ret i32 %26
}

LLVM IR (-O2):
define i32 @trio_equal_max(i8* %0, i64 %1, i8* %2) {
%4 = tail call i32 @assert(i8* %0)
%5 = tail call i32 @assert(i8* %2)
%6 = icmp ne i8* %0, null
%7 = icmp ne i8* %2, null
%8 = and i1 %6, %7
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = tail call i64 @strncasecmp(i8* %0, i8* %2, i64 %1)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %3, %9
%14 = phi i32 [ %12, %9 ], [ 0, %3 ]
ret i32 %14
}