#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 */
struct misc_file_buffer {
  int dummy;
};

/* Variables and functions */
char const misc_get_char(struct misc_file_buffer *, unsigned int);
unsigned int strlen(char const *);
int match_keyword(struct misc_file_buffer *file, const char *keyword) {
  unsigned int i;
  for (i = 0; i < strlen(keyword); i++)
    if (misc_get_char(file, i) != keyword[i])
      return -1;
  return 0;
}


x86 assembly (clang, -O0):
<match_keyword>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jae    1194 <match_keyword+0x74>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1040 <misc_get_char@plt>
movsbl %al,%eax
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%edx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1181 <match_keyword+0x61>
movl   $0xffffffff,-0x4(%rbp)
jmp    119b <match_keyword+0x7b>
jmp    1186 <match_keyword+0x66>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1137 <match_keyword+0x17>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_keyword>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     1163 <match_keyword+0x43>
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <misc_get_char@plt>
cmp    (%r15,%rbx,1),%al
jne    1167 <match_keyword+0x47>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
mov    %eax,%eax
cmp    %rax,%rbx
jb     1140 <match_keyword+0x20>
xor    %eax,%eax
jmp    116c <match_keyword+0x4c>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.misc_file_buffer = type { i32 }
define i32 @match_keyword(%struct.misc_file_buffer* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.misc_file_buffer*
%5 = alloca i8*
%6 = alloca i32
store %struct.misc_file_buffer* %0, %struct.misc_file_buffer** %4
store i8* %1, i8** %5
store i32 0, i32* %6
br label %7
7: ; preds = %26, %2
%8 = load i32, i32* %6
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
%11 = icmp ult i32 %8, %10
br i1 %11, label %12, label %29
12: ; preds = %7
%13 = load %struct.misc_file_buffer*, %struct.misc_file_buffer** %4
%14 = load i32, i32* %6
%15 = call signext i8 @misc_get_char(%struct.misc_file_buffer* %13, i32 %14)
%16 = sext i8 %15 to i32
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %16, %22
br i1 %23, label %24, label %25
24: ; preds = %12
store i32 -1, i32* %3
br label %30
25: ; preds = %12
br label %26
26: ; preds = %25
%27 = load i32, i32* %6
%28 = add i32 %27, 1
store i32 %28, i32* %6
br label %7
29: ; preds = %7
store i32 0, i32* %3
br label %30
30: ; preds = %29, %24
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
%struct.misc_file_buffer = type { i32 }
define i32 @match_keyword(%struct.misc_file_buffer* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %17, label %9
5: ; preds = %9
%6 = tail call i32 @strlen(i8* %1)
%7 = zext i32 %6 to i64
%8 = icmp ult i64 %16, %7
br i1 %8, label %9, label %17
9: ; preds = %2, %5
%10 = phi i64 [ %16, %5 ], [ 0, %2 ]
%11 = trunc i64 %10 to i32
%12 = tail call signext i8 @misc_get_char(%struct.misc_file_buffer* %0, i32 %11)
%13 = getelementptr inbounds i8, i8* %1, i64 %10
%14 = load i8, i8* %13
%15 = icmp eq i8 %12, %14
%16 = add nuw nsw i64 %10, 1
br i1 %15, label %5, label %17
17: ; preds = %9, %5, %2
%18 = phi i32 [ 0, %2 ], [ 0, %5 ], [ -1, %9 ]
ret i32 %18
}