#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*/ str_lower(char *);
int /*<<< orphan*/ strcpy(char *, char *);
int str_match(char *p, char *u) {
  char ptrn[10000];
  char usrqry[10000];
  strcpy(ptrn, p);
  strcpy(usrqry, u);
  str_lower(ptrn);
  str_lower(usrqry);
  int i;
  for (i = 0; ptrn[i] != '\0' || usrqry[i] != '\0'; i++)
    if (ptrn[i] != usrqry[i])
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<str_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4e50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x2730(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x4e40(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x2730(%rbp),%rdi
call   1040 <str_lower@plt>
lea    -0x4e40(%rbp),%rdi
call   1040 <str_lower@plt>
movl   $0x0,-0x4e44(%rbp)
movslq -0x4e44(%rbp),%rax
movsbl -0x2730(%rbp,%rax,1),%ecx
ff
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x4e45(%rbp)
jne    11b0 <str_match+0x90>
movslq -0x4e44(%rbp),%rax
movsbl -0x4e40(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
setne  %al
mov    %al,-0x4e45(%rbp)
mov    -0x4e45(%rbp),%al
test   $0x1,%al
jne    11c3 <str_match+0xa3>
jmp    120e <str_match+0xee>
movslq -0x4e44(%rbp),%rax
movsbl -0x2730(%rbp,%rax,1),%eax
ff
movslq -0x4e44(%rbp),%rcx
movsbl -0x4e40(%rbp,%rcx,1),%ecx
ff
cmp    %ecx,%eax
je     11f5 <str_match+0xd5>
movl   $0x0,-0x4(%rbp)
jmp    1215 <str_match+0xf5>
jmp    11fa <str_match+0xda>
mov    -0x4e44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4e44(%rbp)
jmp    1175 <str_match+0x55>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x4e50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_match>:
push   %r15
push   %r14
push   %rbx
sub    $0x4e20,%rsp
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0x2710(%rsp),%r14
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <str_lower@plt>
mov    %r15,%rdi
call   1040 <str_lower@plt>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x2710(%rsp,%rax,1),%ebx
movzbl (%rsp,%rax,1),%edx
mov    %ebx,%ecx
or     %dl,%cl
je     118e <str_match+0x6e>
add    $0x1,%rax
cmp    %dl,%bl
je     1170 <str_match+0x50>
xor    %eax,%eax
jmp    1193 <str_match+0x73>
mov    $0x1,%eax
add    $0x4e20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @str_match(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [10000 x i8]
%7 = alloca [10000 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%10 = load i8*, i8** %4
%11 = call i32 @strcpy(i8* %9, i8* %10)
%12 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%13 = load i8*, i8** %5
%14 = call i32 @strcpy(i8* %12, i8* %13)
%15 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 0
%16 = call i32 @str_lower(i8* %15)
%17 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 0
%18 = call i32 @str_lower(i8* %17)
store i32 0, i32* %8
br label %19
19: ; preds = %49, %2
%20 = load i32, i32* %8
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %33, label %26
26: ; preds = %19
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br label %33
33: ; preds = %26, %19
%34 = phi i1 [ true, %19 ], [ %32, %26 ]
br i1 %34, label %35, label %52
35: ; preds = %33
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [10000 x i8], [10000 x i8]* %6, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [10000 x i8], [10000 x i8]* %7, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %40, %45
br i1 %46, label %47, label %48
47: ; preds = %35
store i32 0, i32* %3
br label %53
48: ; preds = %35
br label %49
49: ; preds = %48
%50 = load i32, i32* %8
%51 = add nsw i32 %50, 1
store i32 %51, i32* %8
br label %19
52: ; preds = %33
store i32 1, i32* %3
br label %53
53: ; preds = %52, %47
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
define i32 @str_match(i8* %0, i8* %1) {
%3 = alloca [10000 x i8]
%4 = alloca [10000 x i8]
%5 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 0
%7 = call i32 @strcpy(i8* %5, i8* %0)
%8 = call i32 @strcpy(i8* %6, i8* %1)
%9 = call i32 @str_lower(i8* %5)
%10 = call i32 @str_lower(i8* %6)
br label %11
11: ; preds = %20, %2
%12 = phi i64 [ %22, %20 ], [ 0, %2 ]
%13 = getelementptr inbounds [10000 x i8], [10000 x i8]* %3, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
%16 = getelementptr inbounds [10000 x i8], [10000 x i8]* %4, i64 0, i64 %12
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
%19 = select i1 %15, i1 %18, i1 false
br i1 %19, label %23, label %20
20: ; preds = %11
%21 = icmp eq i8 %14, %17
%22 = add nuw i64 %12, 1
br i1 %21, label %11, label %23
23: ; preds = %11, %20
%24 = phi i32 [ 0, %20 ], [ 1, %11 ]
ret i32 %24
}