#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*/ exit(int);
int lseek(int, int, int);
int /*<<< orphan*/ read(int, char *, int);
int strlen(char *);
int cmpStr(int fd, int start, char str[]) {
  char bfr;
  int len, i;
  len = lseek(fd, 0L, 2);
  for (i = 1; i < strlen(str); i++) {
    if (lseek(fd, start, 0) < len) {
      start++;
      read(fd, &bfr, sizeof(char));
      if ((char)bfr != str[i])
        return 0;
    } else
      exit(1);
  }
  return 1;
}


x86 assembly (clang, -O0):
<cmpStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <lseek@plt>
mov    %eax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11fd <cmpStr+0xbd>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
xor    %edx,%edx
call   1040 <lseek@plt>
cmp    -0x20(%rbp),%eax
jge    11e0 <cmpStr+0xa0>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x19(%rbp),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
movsbl -0x19(%rbp),%eax
mov    -0x18(%rbp),%rcx
movslq -0x24(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     11db <cmpStr+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    1204 <cmpStr+0xc4>
jmp    11ea <cmpStr+0xaa>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    11ef <cmpStr+0xaf>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116b <cmpStr+0x2b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmpStr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r13
mov    %esi,%r15d
mov    %edi,%ebp
xor    %esi,%esi
mov    $0x2,%edx
call   1040 <lseek@plt>
mov    %eax,%r14d
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cmp    $0x2,%ecx
jl     11dc <cmpStr+0x9c>
mov    %r15d,%r12d
mov    $0x1,%ebx
lea    0x7(%rsp),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    (%r12,%rbx,1),%esi
add    $0xffffffff,%esi
mov    %ebp,%edi
xor    %edx,%edx
call   1040 <lseek@plt>
cmp    %r14d,%eax
jge    11eb <cmpStr+0xab>
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <read@plt>
movzbl 0x7(%rsp),%eax
cmp    0x0(%r13,%rbx,1),%al
jne    11da <cmpStr+0x9a>
add    $0x1,%rbx
mov    %r13,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1190 <cmpStr+0x50>
mov    $0x1,%eax
jmp    11dc <cmpStr+0x9c>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
define i32 @cmpStr(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%11 = load i32, i32* %5
%12 = call i32 @lseek(i32 %11, i32 0, i32 2)
store i32 %12, i32* %9
store i32 1, i32* %10
br label %13
13: ; preds = %43, %3
%14 = load i32, i32* %10
%15 = load i8*, i8** %7
%16 = call i32 @strlen(i8* %15)
%17 = icmp slt i32 %14, %16
br i1 %17, label %18, label %46
18: ; preds = %13
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = call i32 @lseek(i32 %19, i32 %20, i32 0)
%22 = load i32, i32* %9
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %40
24: ; preds = %18
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
%27 = load i32, i32* %5
%28 = call i32 @read(i32 %27, i8* %8, i32 1)
%29 = load i8, i8* %8
%30 = sext i8 %29 to i32
%31 = load i8*, i8** %7
%32 = load i32, i32* %10
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %30, %36
br i1 %37, label %38, label %39
38: ; preds = %24
store i32 0, i32* %4
br label %47
39: ; preds = %24
br label %42
40: ; preds = %18
%41 = call i32 @exit(i32 1)
unreachable
42: ; preds = %39
br label %43
43: ; preds = %42
%44 = load i32, i32* %10
%45 = add nsw i32 %44, 1
store i32 %45, i32* %10
br label %13
46: ; preds = %13
store i32 1, i32* %4
br label %47
47: ; preds = %46, %38
%48 = load i32, i32* %4
ret i32 %48
}

LLVM IR (-O2):
define i32 @cmpStr(i32 %0, i32 %1, i8* %2) {
%4 = alloca i8
%5 = tail call i32 @lseek(i32 %0, i32 0, i32 2)
%6 = tail call i32 @strlen(i8* %2)
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %27
8: ; preds = %3, %21
%9 = phi i64 [ %23, %21 ], [ 1, %3 ]
%10 = phi i32 [ %22, %21 ], [ %1, %3 ]
%11 = tail call i32 @lseek(i32 %0, i32 %10, i32 0)
%12 = icmp slt i32 %11, %5
br i1 %12, label %13, label %19
13: ; preds = %8
%14 = call i32 @read(i32 %0, i8* %4, i32 1)
%15 = load i8, i8* %4
%16 = getelementptr inbounds i8, i8* %2, i64 %9
%17 = load i8, i8* %16
%18 = icmp eq i8 %15, %17
br i1 %18, label %21, label %27
19: ; preds = %8
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %13
%22 = add nsw i32 %10, 1
%23 = add nuw nsw i64 %9, 1
%24 = tail call i32 @strlen(i8* %2)
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %8, label %27
27: ; preds = %13, %21, %3
%28 = phi i32 [ 1, %3 ], [ 1, %21 ], [ 0, %13 ]
ret i32 %28
}