#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*/ uint64_t;

/* Variables and functions */
int file_check_integrity_hash(char const *, unsigned char const *);
int file_check_integrity_size(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int file_check_integrity(const char *path, uint64_t fsize,
                         const unsigned char *fhash) {
  int retval;
  retval = file_check_integrity_size(path, fsize);
  if (retval != 0) {
    fprintf(stderr, "file_check_integrity_size failed\n");
    return -1;
  }
  retval = file_check_integrity_hash(path, fhash);
  if (retval != 0) {
    fprintf(stderr, "file_check_integrity_hash failed\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<file_check_integrity>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <file_check_integrity_size@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     117d <file_check_integrity+0x4d>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
lea    0xe94(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bf <file_check_integrity+0x8f>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <file_check_integrity_hash@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11b8 <file_check_integrity+0x88>
mov    0x2e42(%rip),%rax
mov    (%rax),%edi
lea    0xe7b(%rip),%rsi
call   1040 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bf <file_check_integrity+0x8f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_check_integrity>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rdi,%rbx
call   1030 <file_check_integrity_size@plt>
test   %eax,%eax
je     114c <file_check_integrity+0x1c>
lea    0xeb6(%rip),%rsi
jmp    1162 <file_check_integrity+0x32>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <file_check_integrity_hash@plt>
test   %eax,%eax
je     117d <file_check_integrity+0x4d>
lea    0xec0(%rip),%rsi
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
call   1040 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
jmp    1175 <file_check_integrity+0x45>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [34 x i8] c"file_check_integrity_size failed\0A\00"
@.str.1 = [34 x i8] c"file_check_integrity_hash failed\0A\00"
define i32 @file_check_integrity(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = call i32 @file_check_integrity_size(i8* %9, i32 %10)
store i32 %11, i32* %8
%12 = load i32, i32* %8
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %27
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = load i8*, i8** %7
%20 = call i32 @file_check_integrity_hash(i8* %18, i8* %19)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %4
br label %27
26: ; preds = %17
store i32 0, i32* %4
br label %27
27: ; preds = %26, %23, %14
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [34 x i8] c"file_check_integrity_size failed\0A\00"
@.str.1 = [34 x i8] c"file_check_integrity_hash failed\0A\00"
define i32 @file_check_integrity(i8* %0, i32 %1, i8* %2) {
%4 = tail call i32 @file_check_integrity_size(i8* %0, i32 %1)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %3
%7 = tail call i32 @file_check_integrity_hash(i8* %0, i8* %2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %6, %3
%10 = phi i8* [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), %6 ]
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* %10)
br label %13
13: ; preds = %9, %6
%14 = phi i32 [ 0, %6 ], [ -1, %9 ]
ret i32 %14
}