#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 /*<<< orphan*/ SEEK_SET;
scalar_t__ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fread(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, unsigned long,
                         int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
unsigned long get_message_head(FILE *fp1, FILE *fp2,
                               unsigned long start_pos_data,
                               unsigned long delay) {
  unsigned long pos_data_2 = start_pos_data;
  unsigned long pos_data_1 = start_pos_data - delay;
  fseek(fp1, pos_data_1, SEEK_SET);
  fseek(fp2, pos_data_2, SEEK_SET);
  char ch1, ch2;
  while (1) {
    if (feof(fp1) || feof(fp2)) {
      printf("No Message Found!\n");
      return 0;
    }
    fread(&ch1, sizeof(char), 1, fp1);
    fread(&ch2, sizeof(char), 1, fp2);
    if (ch1 != ch2)
      return pos_data_2;
    pos_data_1++;
    pos_data_2++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<get_message_head>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rax
sub    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x2e4f(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x10(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
jne    11be <get_message_head+0x7e>
mov    -0x18(%rbp),%rdi
call   1050 <feof@plt>
cmp    $0x0,%rax
je     11d7 <get_message_head+0x97>
lea    0xe3b(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1239 <get_message_head+0xf9>
mov    -0x10(%rbp),%rcx
lea    -0x39(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
mov    -0x18(%rbp),%rcx
lea    -0x3a(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1030 <fread@plt>
movsbl -0x39(%rbp),%eax
movsbl -0x3a(%rbp),%ecx
cmp    %ecx,%eax
je     121c <get_message_head+0xdc>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1239 <get_message_head+0xf9>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1198 <get_message_head+0x58>
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_message_head>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rdx,%rsi
sub    %rcx,%rsi
mov    0x2e7d(%rip),%r12
mov    (%r12),%edx
call   1060 <fseek@plt>
mov    (%r12),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <fseek@plt>
mov    %r15,%rdi
call   1050 <feof@plt>
test   %rax,%rax
je     11a7 <get_message_head+0x67>
lea    0xe71(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xf(%rsp),%r12
lea    0xe(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
call   1050 <feof@plt>
test   %rax,%rax
jne    1188 <get_message_head+0x48>
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r15,%rcx
call   1040 <fread@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <fread@plt>
movzbl 0xf(%rsp),%eax
cmp    0xe(%rsp),%al
jne    1196 <get_message_head+0x56>
add    $0x1,%rbx
mov    %r15,%rdi
call   1050 <feof@plt>
test   %rax,%rax
je     11c0 <get_message_head+0x80>
jmp    1188 <get_message_head+0x48>

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [19 x i8] c"No Message Found!\0A\00"
define i64 @get_message_head(i32* %0, i32* %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8
%13 = alloca i8
store i32* %0, i32** %6
store i32* %1, i32** %7
store i64 %2, i64* %8
store i64 %3, i64* %9
%14 = load i64, i64* %8
store i64 %14, i64* %10
%15 = load i64, i64* %8
%16 = load i64, i64* %9
%17 = sub i64 %15, %16
store i64 %17, i64* %11
%18 = load i32*, i32** %6
%19 = load i64, i64* %11
%20 = load i32, i32* @SEEK_SET
%21 = call i32 @fseek(i32* %18, i64 %19, i32 %20)
%22 = load i32*, i32** %7
%23 = load i64, i64* %10
%24 = load i32, i32* @SEEK_SET
%25 = call i32 @fseek(i32* %22, i64 %23, i32 %24)
br label %26
26: ; preds = %4, %48
%27 = load i32*, i32** %6
%28 = call i64 @feof(i32* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load i32*, i32** %7
%32 = call i64 @feof(i32* %31)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %30, %26
%35 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
store i64 0, i64* %5
br label %53
36: ; preds = %30
%37 = load i32*, i32** %6
%38 = call i32 @fread(i8* %12, i32 1, i32 1, i32* %37)
%39 = load i32*, i32** %7
%40 = call i32 @fread(i8* %13, i32 1, i32 1, i32* %39)
%41 = load i8, i8* %12
%42 = sext i8 %41 to i32
%43 = load i8, i8* %13
%44 = sext i8 %43 to i32
%45 = icmp ne i32 %42, %44
br i1 %45, label %46, label %48
46: ; preds = %36
%47 = load i64, i64* %10
store i64 %47, i64* %5
br label %53
48: ; preds = %36
%49 = load i64, i64* %11
%50 = add i64 %49, 1
store i64 %50, i64* %11
%51 = load i64, i64* %10
%52 = add i64 %51, 1
store i64 %52, i64* %10
br label %26
53: ; preds = %46, %34
%54 = load i64, i64* %5
ret i64 %54
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@str = [18 x i8] c"No Message Found!\00"
define i64 @get_message_head(i32* nocapture %0, i32* nocapture %1, i64 %2, i64 %3) {
%5 = alloca i8
%6 = alloca i8
%7 = sub i64 %2, %3
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @fseek(i32* %0, i64 %7, i32 %8)
%10 = load i32, i32* @SEEK_SET
%11 = tail call i32 @fseek(i32* %1, i64 %2, i32 %10)
%12 = tail call i64 @feof(i32* %0)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %4, %26
%15 = phi i64 [ %27, %26 ], [ %2, %4 ]
%16 = tail call i64 @feof(i32* %1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %26, %14, %4
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %30
20: ; preds = %14
%21 = call i32 @fread(i8* %5, i32 1, i32 1, i32* %0)
%22 = call i32 @fread(i8* %6, i32 1, i32 1, i32* %1)
%23 = load i8, i8* %5
%24 = load i8, i8* %6
%25 = icmp eq i8 %23, %24
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = add i64 %15, 1
%28 = tail call i64 @feof(i32* %0)
%29 = icmp eq i64 %28, 0
br i1 %29, label %14, label %18
30: ; preds = %20, %18
%31 = phi i64 [ 0, %18 ], [ %15, %20 ]
ret i64 %31
}