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

/* Variables and functions */
int /*<<< orphan*/ False;
int /*<<< orphan*/ True;
int fread(char *, int, int, int /*<<< orphan*/ *);
Bool Read(char *ptr, int size, int nitems, FILE *stream) {
  size *= nitems;
  while (size) {
    nitems = fread(ptr, 1, size, stream);
    if (nitems <= 0)
      return False;
    size -= nitems;
    ptr += nitems;
  }
  return True;
}


x86 assembly (clang, -O0):
<Read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%eax
imul   -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     118e <Read+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jg     116d <Read+0x5d>
mov    0x2e85(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    119a <Read+0x8a>
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    1130 <Read+0x20>
mov    0x2e4b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Read>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
imul   %edx,%ebp
mov    0x2ebc(%rip),%r15
test   %ebp,%ebp
je     1164 <Read+0x54>
mov    %rcx,%r14
mov    %rdi,%rbx
mov    0x2eb3(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %r14,%rcx
call   1030 <fread@plt>
test   %eax,%eax
jle    1161 <Read+0x51>
mov    %eax,%ecx
add    %rcx,%rbx
sub    %eax,%ebp
jne    1140 <Read+0x30>
jmp    1164 <Read+0x54>
mov    %r12,%r15
mov    (%r15),%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@False = global i32 0
@True = global i32 0
define i32 @Read(i8* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32* %3, i32** %9
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = mul nsw i32 %11, %10
store i32 %12, i32* %7
br label %13
13: ; preds = %25, %4
%14 = load i32, i32* %7
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %33
16: ; preds = %13
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = load i32*, i32** %9
%20 = call i32 @fread(i8* %17, i32 1, i32 %18, i32* %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp sle i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %16
%24 = load i32, i32* @False
store i32 %24, i32* %5
br label %35
25: ; preds = %16
%26 = load i32, i32* %8
%27 = load i32, i32* %7
%28 = sub nsw i32 %27, %26
store i32 %28, i32* %7
%29 = load i32, i32* %8
%30 = load i8*, i8** %6
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8* %32, i8** %6
br label %13
33: ; preds = %13
%34 = load i32, i32* @True
store i32 %34, i32* %5
br label %35
35: ; preds = %33, %23
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
@False = global i32 0
@True = global i32 0
define i32 @Read(i8* nocapture %0, i32 %1, i32 %2, i32* nocapture %3) {
%5 = mul nsw i32 %2, %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %17, label %7
7: ; preds = %4, %12
%8 = phi i32 [ %13, %12 ], [ %5, %4 ]
%9 = phi i8* [ %15, %12 ], [ %0, %4 ]
%10 = tail call i32 @fread(i8* %9, i32 1, i32 %8, i32* %3)
%11 = icmp slt i32 %10, 1
br i1 %11, label %17, label %12
12: ; preds = %7
%13 = sub nsw i32 %8, %10
%14 = zext i32 %10 to i64
%15 = getelementptr inbounds i8, i8* %9, i64 %14
%16 = icmp eq i32 %13, 0
br i1 %16, label %17, label %7
17: ; preds = %7, %12, %4
%18 = phi i32* [ @True, %4 ], [ @True, %12 ], [ @False, %7 ]
%19 = load i32, i32* %18
ret i32 %19
}