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

/* Variables and functions */
int /*<<< orphan*/ build_sha256_sum(char *, unsigned char *);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ free(unsigned char *);
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
unsigned char *check_sha256_sum(char *filename, unsigned char *hash) {
  unsigned char *ascii = NULL;
  ascii = (unsigned char *)calloc(65, sizeof(unsigned char));
  if (ascii == NULL) {
    return hash;
  }
  build_sha256_sum(filename, ascii);
  if (memcmp(ascii, hash, 64) == 0) {
    free(ascii);
    return NULL;
  } else {
    return ascii;
  }
}


x86 assembly (clang, -O0):
<check_sha256_sum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x41,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1183 <check_sha256_sum+0x43>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ca <check_sha256_sum+0x8a>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <build_sha256_sum@plt>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x40,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
jne    11c2 <check_sha256_sum+0x82>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11ca <check_sha256_sum+0x8a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_sha256_sum>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x41,%edi
mov    $0x1,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     1190 <check_sha256_sum+0x50>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %rax,%rsi
call   1030 <build_sha256_sum@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x40,%edx
call   1050 <memcmp@plt>
mov    %rbx,%r14
test   %rax,%rax
jne    1190 <check_sha256_sum+0x50>
mov    %rbx,%rdi
call   1040 <free@plt>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @check_sha256_sum(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* null, i8** %6
%7 = call i64 @calloc(i32 65, i32 1)
%8 = inttoptr i64 %7 to i8*
store i8* %8, i8** %6
%9 = load i8*, i8** %6
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = load i8*, i8** %5
store i8* %12, i8** %3
br label %26
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = load i8*, i8** %6
%16 = call i32 @build_sha256_sum(i8* %14, i8* %15)
%17 = load i8*, i8** %6
%18 = load i8*, i8** %5
%19 = call i64 @memcmp(i8* %17, i8* %18, i32 64)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %13
%22 = load i8*, i8** %6
%23 = call i32 @free(i8* %22)
store i8* null, i8** %3
br label %26
24: ; preds = %13
%25 = load i8*, i8** %6
store i8* %25, i8** %3
br label %26
26: ; preds = %24, %21, %11
%27 = load i8*, i8** %3
ret i8* %27
}

LLVM IR (-O2):
define i8* @check_sha256_sum(i8* %0, i8* %1) {
%3 = tail call i64 @calloc(i32 65, i32 1)
%4 = inttoptr i64 %3 to i8*
%5 = icmp eq i64 %3, 0
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = tail call i32 @build_sha256_sum(i8* %0, i8* %4)
%8 = tail call i64 @memcmp(i8* %4, i8* %1, i32 64)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 @free(i8* %4)
br label %12
12: ; preds = %6, %2, %10
%13 = phi i8* [ null, %10 ], [ %1, %2 ], [ %4, %6 ]
ret i8* %13
}