signed int Read_Component(char *Filename, unsigned char *Frame,
                          signed int Width, signed int Height) {
  signed int Size;
  signed int Bytes_Read;
  signed int Infile;
  Size = Width * Height;
  Infile = open(Filename, 0 | 0);
  if ((signed int)(Infile == 0) < 0) {
    printf("ERROR: unable to open reference filename (%s)\n", Filename);
    return -1;
  }
  signed long int return_value_read$1;
  return_value_read$1 = read(Infile, (void *)Frame, (unsigned long int)Size);
  Bytes_Read = (signed int)return_value_read$1;
  if (!(Bytes_Read == Size))
    printf("was able to read only %d bytes of %d of file %s\n", Bytes_Read,
           Size, Filename);
  close(Infile);
  return 0;
}


x86 assembly (clang, -O0):
<Read_Component>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1060 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
jge    11a3 <Read_Component+0x63>
mov    -0x10(%rbp),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f7 <Read_Component+0xb7>
mov    -0x2c(%rbp),%edi
mov    -0x18(%rbp),%rsi
movslq -0x24(%rbp),%rdx
mov    $0x0,%al
call   1050 <read@plt>
cltq
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     11e6 <Read_Component+0xa6>
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rcx
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    $0x0,%al
call   1040 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Read_Component>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%r14
imul   %ecx,%ebx
xor    %esi,%esi
xor    %eax,%eax
call   1060 <open@plt>
mov    %eax,%r12d
movslq %ebx,%rbp
mov    %eax,%edi
mov    %r15,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1050 <read@plt>
cmp    %ebp,%eax
je     118a <Read_Component+0x4a>
lea    0xe84(%rip),%rdi
mov    %eax,%esi
mov    %ebx,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r12d,%edi
xor    %eax,%eax
call   1040 <close@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"ERROR: unable to open reference filename (%s)\0A\00"
@.str.1 = [49 x i8] c"was able to read only %d bytes of %d of file %s\0A\00"
define i32 @Read_Component(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
store i8* %0, i8** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = mul nsw i32 %14, %15
store i32 %16, i32* %10
%17 = load i8*, i8** %6
%18 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* %17, i32 0)
store i32 %18, i32* %12
%19 = load i32, i32* %12
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %4
%24 = load i8*, i8** %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i8* %24)
store i32 -1, i32* %5
br label %46
26: ; preds = %4
%27 = load i32, i32* %12
%28 = load i8*, i8** %7
%29 = load i32, i32* %10
%30 = sext i32 %29 to i64
%31 = call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i64, ...)*)(i32 %27, i8* %28, i64 %30)
%32 = sext i32 %31 to i64
store i64 %32, i64* %13
%33 = load i64, i64* %13
%34 = trunc i64 %33 to i32
store i32 %34, i32* %11
%35 = load i32, i32* %11
%36 = load i32, i32* %10
%37 = icmp eq i32 %35, %36
br i1 %37, label %43, label %38
38: ; preds = %26
%39 = load i32, i32* %11
%40 = load i32, i32* %10
%41 = load i8*, i8** %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %39, i32 %40, i8* %41)
br label %43
43: ; preds = %38, %26
%44 = load i32, i32* %12
%45 = call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %44)
store i32 0, i32* %5
br label %46
46: ; preds = %43, %23
%47 = load i32, i32* %5
ret i32 %47
}

LLVM IR (-O2):
@.str.1 = [49 x i8] c"was able to read only %d bytes of %d of file %s\0A\00"
define i32 @Read_Component(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = mul nsw i32 %3, %2
%6 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @open to i32 (i8*, i32, ...)*)(i8* %0, i32 0)
%7 = sext i32 %5 to i64
%8 = tail call i32 (i32, i8*, i64, ...) bitcast (i32 (...)* @read to i32 (i32, i8*, i64, ...)*)(i32 %6, i8* %1, i64 %7)
%9 = icmp eq i32 %8, %5
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.1, i64 0, i64 0), i32 %8, i32 %5, i8* %0)
br label %12
12: ; preds = %10, %4
%13 = tail call i32 (i32, ...) bitcast (i32 (...)* @close to i32 (i32, ...)*)(i32 %6)
ret i32 0
}