#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 */
size_t fread(unsigned char *, int, int, int /*<<< orphan*/ *);
scalar_t__ memcmp(unsigned char *, unsigned char *, size_t);
bool substringfound(FILE *filea, FILE *fileb) {
  unsigned char buffera[4096], bufferb[4096];
  size_t size_filea, size_fileb;
  while (true) {
    size_filea = fread(buffera, sizeof(unsigned char), 4096, filea);
    size_fileb = fread(bufferb, sizeof(unsigned char), 4096, fileb);
    if (memcmp(buffera, bufferb, size_filea) != 0)
      return false;
    if (size_filea < 4096)
      return true;
    if (size_fileb < 4096)
      return false;
  }
}


x86 assembly (clang, -O0):
<substringfound>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %rax,-0x2028(%rbp)
lea    -0x2020(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1030 <fread@plt>
mov    %rax,-0x2030(%rbp)
lea    -0x1020(%rbp),%rdi
lea    -0x2020(%rbp),%rsi
mov    -0x2028(%rbp),%rdx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     11a5 <substringfound+0x85>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <substringfound+0xc4>
cmpq   $0x1000,-0x2028(%rbp)
jae    11c2 <substringfound+0xa2>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <substringfound+0xc4>
cmpq   $0x1000,-0x2030(%rbp)
jae    11df <substringfound+0xbf>
movl   $0x0,-0x4(%rbp)
jmp    11e4 <substringfound+0xc4>
jmp    1133 <substringfound+0x13>
mov    -0x4(%rbp),%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<substringfound>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2008,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
lea    0x1000(%rsp),%r15
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r12,%rcx
call   1030 <fread@plt>
mov    %rax,%rbx
mov    %r13,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
mov    %rax,%rbp
mov    %r15,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1040 <memcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    11b1 <substringfound+0x91>
cmp    $0x1000,%rbx
jb     11ac <substringfound+0x8c>
cmp    $0xfff,%rbp
ja     1150 <substringfound+0x30>
jmp    11b1 <substringfound+0x91>
mov    $0x1,%eax
add    $0x2008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @substringfound(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [4096 x i8]
%7 = alloca [4096 x i8]
%8 = alloca i64
%9 = alloca i64
store i32* %0, i32** %4
store i32* %1, i32** %5
br label %10
10: ; preds = %2, %31
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%12 = load i32*, i32** %4
%13 = call i64 @fread(i8* %11, i32 1, i32 4096, i32* %12)
store i64 %13, i64* %8
%14 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%15 = load i32*, i32** %5
%16 = call i64 @fread(i8* %14, i32 1, i32 4096, i32* %15)
store i64 %16, i64* %9
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%19 = load i64, i64* %8
%20 = call i64 @memcmp(i8* %17, i8* %18, i64 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %10
store i32 0, i32* %3
br label %32
23: ; preds = %10
%24 = load i64, i64* %8
%25 = icmp ult i64 %24, 4096
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 1, i32* %3
br label %32
27: ; preds = %23
%28 = load i64, i64* %9
%29 = icmp ult i64 %28, 4096
br i1 %29, label %30, label %31
30: ; preds = %27
store i32 0, i32* %3
br label %32
31: ; preds = %27
br label %10
32: ; preds = %30, %26, %22
%33 = load i32, i32* %3
ret i32 %33
}

LLVM IR (-O2):
define i32 @substringfound(i32* nocapture %0, i32* nocapture %1) {
%3 = alloca [4096 x i8]
%4 = alloca [4096 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
br label %7
7: ; preds = %14, %2
%8 = call i64 @fread(i8* %5, i32 1, i32 4096, i32* %0)
%9 = call i64 @fread(i8* %6, i32 1, i32 4096, i32* %1)
%10 = call i64 @memcmp(i8* %5, i8* %6, i64 %8)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = icmp ult i64 %8, 4096
br i1 %13, label %16, label %14
14: ; preds = %12
%15 = icmp ult i64 %9, 4096
br i1 %15, label %16, label %7
16: ; preds = %14, %12, %7
%17 = phi i32 [ 0, %7 ], [ 1, %12 ], [ 0, %14 ]
ret i32 %17
}