#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 off_t;

/* Variables and functions */
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ assert(int);
int lseek(int, int, int /*<<< orphan*/);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, long long, long long, long long);
int /*<<< orphan*/ read(int, char *, int);
void found_match(int fd_in, off_t len, off_t off, off_t old_off) {
  char olddata[len], newdata[len];
  off_t current_off;
  if (old_off + len <= off) {
    printf("match: %llu %llu %llu\n", (long long)old_off, (long long)off,
           (long long)len);
  }
  current_off = lseek(fd_in, 0, SEEK_CUR);
  lseek(fd_in, old_off, SEEK_SET);
  read(fd_in, olddata, len);
  lseek(fd_in, off, SEEK_SET);
  read(fd_in, newdata, len);
  lseek(fd_in, current_off, SEEK_SET);
  assert(memcmp(olddata, newdata, len) == 0);
}


x86 assembly (clang, -O0):
<found_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11d0 <found_match+0x80>
movslq -0x10(%rbp),%rsi
movslq -0xc(%rbp),%rdx
movslq -0x8(%rbp),%rcx
lea    0xe35(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%edi
mov    0x2e0e(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    0x2de5(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    -0x40(%rbp),%rsi
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
call   1050 <read@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    0x2dc2(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    -0x38(%rbp),%rsi
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
call   1050 <read@plt>
mov    -0x4(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    0x2d9f(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1060 <memcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<found_match>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %esi,%r14d
mov    %edi,%ebx
mov    %esi,%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
lea    (%r14,%r13,1),%eax
mov    %edx,-0x2c(%rbp)
cmp    %edx,%eax
jg     11a3 <found_match+0x53>
movslq %r13d,%rsi
movslq -0x2c(%rbp),%rdx
movslq %r14d,%rcx
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
xor    %esi,%esi
call   1040 <lseek@plt>
mov    %eax,-0x30(%rbp)
mov    0x2e19(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    %r13d,%esi
call   1040 <lseek@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   1050 <read@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    -0x2c(%rbp),%esi
call   1040 <lseek@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r14d,%edx
call   1050 <read@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    -0x30(%rbp),%esi
call   1040 <lseek@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14d,%edx
call   1060 <memcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1070 <assert@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"match: %llu %llu %llu\0A\00"
@SEEK_CUR = global i32 0
@SEEK_SET = global i32 0
define void @found_match(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%13 = load i32, i32* %6
%14 = zext i32 %13 to i64
%15 = call i8* @llvm.stacksave()
store i8* %15, i8** %9
%16 = alloca i8, i64 %14
store i64 %14, i64* %10
%17 = load i32, i32* %6
%18 = zext i32 %17 to i64
%19 = alloca i8, i64 %18
store i64 %18, i64* %11
%20 = load i32, i32* %8
%21 = load i32, i32* %6
%22 = add nsw i32 %20, %21
%23 = load i32, i32* %7
%24 = icmp sle i32 %22, %23
br i1 %24, label %25, label %33
25: ; preds = %4
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = load i32, i32* %6
%31 = sext i32 %30 to i64
%32 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %27, i64 %29, i64 %31)
br label %33
33: ; preds = %25, %4
%34 = load i32, i32* %5
%35 = load i32, i32* @SEEK_CUR
%36 = call i32 @lseek(i32 %34, i32 0, i32 %35)
store i32 %36, i32* %12
%37 = load i32, i32* %5
%38 = load i32, i32* %8
%39 = load i32, i32* @SEEK_SET
%40 = call i32 @lseek(i32 %37, i32 %38, i32 %39)
%41 = load i32, i32* %5
%42 = load i32, i32* %6
%43 = call i32 @read(i32 %41, i8* %16, i32 %42)
%44 = load i32, i32* %5
%45 = load i32, i32* %7
%46 = load i32, i32* @SEEK_SET
%47 = call i32 @lseek(i32 %44, i32 %45, i32 %46)
%48 = load i32, i32* %5
%49 = load i32, i32* %6
%50 = call i32 @read(i32 %48, i8* %19, i32 %49)
%51 = load i32, i32* %5
%52 = load i32, i32* %12
%53 = load i32, i32* @SEEK_SET
%54 = call i32 @lseek(i32 %51, i32 %52, i32 %53)
%55 = load i32, i32* %6
%56 = call i64 @memcmp(i8* %16, i8* %19, i32 %55)
%57 = icmp eq i64 %56, 0
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = load i8*, i8** %9
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"match: %llu %llu %llu\0A\00"
@SEEK_CUR = global i32 0
@SEEK_SET = global i32 0
define void @found_match(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = zext i32 %1 to i64
%6 = alloca i8, i64 %5
%7 = alloca i8, i64 %5
%8 = add nsw i32 %3, %1
%9 = icmp sgt i32 %8, %2
br i1 %9, label %15, label %10
10: ; preds = %4
%11 = sext i32 %3 to i64
%12 = sext i32 %2 to i64
%13 = sext i32 %1 to i64
%14 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i64 %11, i64 %12, i64 %13)
br label %15
15: ; preds = %10, %4
%16 = load i32, i32* @SEEK_CUR
%17 = tail call i32 @lseek(i32 %0, i32 0, i32 %16)
%18 = load i32, i32* @SEEK_SET
%19 = tail call i32 @lseek(i32 %0, i32 %3, i32 %18)
%20 = call i32 @read(i32 %0, i8* %6, i32 %1)
%21 = load i32, i32* @SEEK_SET
%22 = tail call i32 @lseek(i32 %0, i32 %2, i32 %21)
%23 = call i32 @read(i32 %0, i8* %7, i32 %1)
%24 = load i32, i32* @SEEK_SET
%25 = tail call i32 @lseek(i32 %0, i32 %17, i32 %24)
%26 = call i64 @memcmp(i8* %6, i8* %7, i32 %1)
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
ret void
}