#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int getc(int /*<<< orphan*/ *);
int cmp_exact(const char *key, FILE *fp) {
  const unsigned char *k = (unsigned char *)key;
  int c;
  while (*k != 0 && (c = getc(fp)) == *k) {
    k++;
  }
  return *k == 0 ? 0 : c == '\n' ? 1 : c == EOF ? -1 : *k - c;
}


x86 assembly (clang, -O0):
<cmp_exact>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1d(%rbp)
je     1158 <cmp_exact+0x48>
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1168 <cmp_exact+0x58>
jmp    1179 <cmp_exact+0x69>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <cmp_exact+0x18>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
jne    1193 <cmp_exact+0x83>
xor    %eax,%eax
mov    %eax,-0x24(%rbp)
jmp    11e2 <cmp_exact+0xd2>
cmpl   $0xa,-0x1c(%rbp)
jne    11aa <cmp_exact+0x9a>
mov    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11dc <cmp_exact+0xcc>
mov    -0x1c(%rbp),%eax
mov    0x2e34(%rip),%rcx
cmp    (%rcx),%eax
jne    11c9 <cmp_exact+0xb9>
mov    $0xffffffff,%eax
mov    %eax,-0x2c(%rbp)
jmp    11d6 <cmp_exact+0xc6>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmp_exact>:
push   %rbp
push   %r14
push   %rbx
xor    %r14d,%r14d
cmpb   $0x0,(%rdi)
je     1170 <cmp_exact+0x60>
mov    %rsi,%rbx
mov    %rdi,%rbp
add    $0x1,%rbp
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <getc@plt>
movzbl -0x1(%rbp),%ecx
cmp    %ecx,%eax
jne    114c <cmp_exact+0x3c>
cmpb   $0x0,0x0(%rbp)
lea    0x1(%rbp),%rbp
jne    1130 <cmp_exact+0x20>
jmp    1170 <cmp_exact+0x60>
test   %ecx,%ecx
je     1170 <cmp_exact+0x60>
mov    $0x1,%r14d
cmp    $0xa,%eax
je     1170 <cmp_exact+0x60>
mov    0x2e86(%rip),%rdx
sub    %eax,%ecx
cmp    (%rdx),%eax
mov    $0xffffffff,%r14d
cmovne %ecx,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@EOF = global i32 0
define i32 @cmp_exact(i8* nocapture %0, i32* nocapture %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %25, label %8
5: ; preds = %8
%6 = load i8, i8* %14
%7 = icmp eq i8 %6, 0
br i1 %7, label %25, label %8
8: ; preds = %2, %5
%9 = phi i8* [ %14, %5 ], [ %0, %2 ]
%10 = tail call i32 @getc(i32* %1)
%11 = load i8, i8* %9
%12 = zext i8 %11 to i32
%13 = icmp eq i32 %10, %12
%14 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %13, label %5, label %15
15: ; preds = %8
%16 = zext i8 %11 to i32
%17 = icmp eq i8 %11, 0
br i1 %17, label %25, label %18
18: ; preds = %15
%19 = icmp eq i32 %10, 10
br i1 %19, label %25, label %20
20: ; preds = %18
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %10, %21
%23 = sub nsw i32 %16, %10
%24 = select i1 %22, i32 -1, i32 %23
br label %25
25: ; preds = %5, %2, %20, %18, %15
%26 = phi i32 [ 0, %15 ], [ 1, %18 ], [ %24, %20 ], [ 0, %2 ], [ 0, %5 ]
ret i32 %26
}