#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__ isupper(unsigned char);
int strlen(char const *);
char tolower(char);
int pm_keymatch(const char *const strarg, const char *const keywordarg,
                int const minchars) {
  int len;
  const char *keyword;
  const char *str;
  str = strarg;
  keyword = keywordarg;
  len = strlen(str);
  if (len < minchars)
    return 0;
  while (--len >= 0) {
    register char c1, c2;
    c1 = *str++;
    c2 = *keyword++;
    if (c2 == '\0')
      return 0;
    if ((isupper((unsigned char)(c1))))
      c1 = tolower(c1);
    if ((isupper((unsigned char)(c2))))
      c2 = tolower(c2);
    if (c1 != c2)
      return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<pm_keymatch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1177 <pm_keymatch+0x47>
movl   $0x0,-0x4(%rbp)
jmp    1235 <pm_keymatch+0x105>
jmp    117c <pm_keymatch+0x4c>
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jl     122e <pm_keymatch+0xfe>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
mov    (%rax),%al
mov    %al,-0x31(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x28(%rbp)
mov    (%rax),%al
mov    %al,-0x32(%rbp)
movsbl -0x32(%rbp),%eax
cmp    $0x0,%eax
jne    11cf <pm_keymatch+0x9f>
movl   $0x0,-0x4(%rbp)
jmp    1235 <pm_keymatch+0x105>
movzbl -0x31(%rbp),%edi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     11ee <pm_keymatch+0xbe>
movsbl -0x31(%rbp),%edi
call   1040 <tolower@plt>
mov    %al,-0x31(%rbp)
movzbl -0x32(%rbp),%edi
call   1050 <isupper@plt>
cmp    $0x0,%rax
je     120d <pm_keymatch+0xdd>
movsbl -0x32(%rbp),%edi
call   1040 <tolower@plt>
mov    %al,-0x32(%rbp)
movsbl -0x31(%rbp),%eax
movsbl -0x32(%rbp),%ecx
cmp    %ecx,%eax
je     1229 <pm_keymatch+0xf9>
movl   $0x0,-0x4(%rbp)
jmp    1235 <pm_keymatch+0x105>
jmp    117c <pm_keymatch+0x4c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pm_keymatch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,(%rsp)
mov    %rdi,%r15
call   1030 <strlen@plt>
xor    %r12d,%r12d
cmp    %ebx,%eax
jl     11bb <pm_keymatch+0x8b>
mov    %eax,%ebp
xor    %r14d,%r14d
xor    %r12d,%r12d
jmp    116c <pm_keymatch+0x3c>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r14
add    $0xffffffff,%ebp
cmp    %bl,%r13b
jne    11bb <pm_keymatch+0x8b>
test   %ebp,%ebp
jle    11b5 <pm_keymatch+0x85>
mov    (%rsp),%rax
movzbl (%rax,%r14,1),%ebx
test   %bl,%bl
je     11bb <pm_keymatch+0x8b>
movzbl (%r15,%r14,1),%r13d
movzbl %r13b,%edi
call   1050 <isupper@plt>
test   %rax,%rax
je     119c <pm_keymatch+0x6c>
movsbl %r13b,%edi
call   1040 <tolower@plt>
mov    %eax,%r13d
movzbl %bl,%edi
call   1050 <isupper@plt>
test   %rax,%rax
je     1160 <pm_keymatch+0x30>
movsbl %bl,%edi
call   1040 <tolower@plt>
mov    %eax,%ebx
jmp    1160 <pm_keymatch+0x30>
mov    $0x1,%r12d
mov    %r12d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @pm_keymatch(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8
%12 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%13 = load i8*, i8** %5
store i8* %13, i8** %10
%14 = load i8*, i8** %6
store i8* %14, i8** %9
%15 = load i8*, i8** %10
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %8
%17 = load i32, i32* %8
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %3
store i32 0, i32* %4
br label %60
21: ; preds = %3
br label %22
22: ; preds = %58, %21
%23 = load i32, i32* %8
%24 = add nsw i32 %23, -1
store i32 %24, i32* %8
%25 = icmp sge i32 %24, 0
br i1 %25, label %26, label %59
26: ; preds = %22
%27 = load i8*, i8** %10
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %10
%29 = load i8, i8* %27
store i8 %29, i8* %11
%30 = load i8*, i8** %9
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %9
%32 = load i8, i8* %30
store i8 %32, i8* %12
%33 = load i8, i8* %12
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %26
store i32 0, i32* %4
br label %60
37: ; preds = %26
%38 = load i8, i8* %11
%39 = call i64 @isupper(i8 zeroext %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %37
%42 = load i8, i8* %11
%43 = call signext i8 @tolower(i8 signext %42)
store i8 %43, i8* %11
br label %44
44: ; preds = %41, %37
%45 = load i8, i8* %12
%46 = call i64 @isupper(i8 zeroext %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %44
%49 = load i8, i8* %12
%50 = call signext i8 @tolower(i8 signext %49)
store i8 %50, i8* %12
br label %51
51: ; preds = %48, %44
%52 = load i8, i8* %11
%53 = sext i8 %52 to i32
%54 = load i8, i8* %12
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %53, %55
br i1 %56, label %57, label %58
57: ; preds = %51
store i32 0, i32* %4
br label %60
58: ; preds = %51
br label %22
59: ; preds = %22
store i32 1, i32* %4
br label %60
60: ; preds = %59, %57, %36, %20
%61 = load i32, i32* %4
ret i32 %61
}

LLVM IR (-O2):
define i32 @pm_keymatch(i8* %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp slt i32 %4, %2
br i1 %5, label %32, label %6
6: ; preds = %3, %29
%7 = phi i32 [ %10, %29 ], [ %4, %3 ]
%8 = phi i8* [ %15, %29 ], [ %1, %3 ]
%9 = phi i8* [ %13, %29 ], [ %0, %3 ]
%10 = add nsw i32 %7, -1
%11 = icmp sgt i32 %7, 0
br i1 %11, label %12, label %32
12: ; preds = %6
%13 = getelementptr inbounds i8, i8* %9, i64 1
%14 = load i8, i8* %9
%15 = getelementptr inbounds i8, i8* %8, i64 1
%16 = load i8, i8* %8
%17 = icmp eq i8 %16, 0
br i1 %17, label %32, label %18
18: ; preds = %12
%19 = tail call i64 @isupper(i8 zeroext %14)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call signext i8 @tolower(i8 signext %14)
br label %23
23: ; preds = %21, %18
%24 = phi i8 [ %22, %21 ], [ %14, %18 ]
%25 = tail call i64 @isupper(i8 zeroext %16)
%26 = icmp eq i64 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %23
%28 = tail call signext i8 @tolower(i8 signext %16)
br label %29
29: ; preds = %27, %23
%30 = phi i8 [ %28, %27 ], [ %16, %23 ]
%31 = icmp eq i8 %24, %30
br i1 %31, label %6, label %32
32: ; preds = %12, %6, %29, %3
%33 = phi i32 [ 0, %3 ], [ 0, %12 ], [ 1, %6 ], [ 0, %29 ]
ret i32 %33
}