#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 get_file_hash(char const *, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
void hash_task(const char *filename) {
  int res;
  char hash[33];
  memset(hash, 0, 33);
  printf("Computing hash for %s...\n", filename);
  res = get_file_hash(filename, hash);
  if (res == 0)
    printf("  hash: %s\n", hash);
  else
    printf("  ERR: hash failed\n");
}


x86 assembly (clang, -O0):
<hash_task>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rsi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <get_file_hash@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    118f <hash_task+0x5f>
lea    -0x30(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    119d <hash_task+0x6d>
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash_task>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rdi,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1060 <memset@plt>
lea    0xe9d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <get_file_hash@plt>
test   %eax,%eax
je     118a <hash_task+0x4a>
lea    0xea3(%rip),%rdi
call   1040 <puts@plt>
jmp    119b <hash_task+0x5b>
lea    0xe89(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [26 x i8] c"Computing hash for %s...\0A\00"
@.str.1 = [12 x i8] c" hash: %s\0A\00"
@.str.2 = [20 x i8] c" ERR: hash failed\0A\00"
define void @hash_task(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [33 x i8]
store i8* %0, i8** %2
%5 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 33)
%7 = load i8*, i8** %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = load i8*, i8** %2
%10 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%11 = call i32 @get_file_hash(i8* %9, i8* %10)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %1
%15 = getelementptr inbounds [33 x i8], [33 x i8]* %4, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %19
17: ; preds = %1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"Computing hash for %s...\0A\00"
@.str.1 = [12 x i8] c" hash: %s\0A\00"
@str = [19 x i8] c" ERR: hash failed\00"
define void @hash_task(i8* %0) {
%2 = alloca [33 x i8]
%3 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 33)
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = call i32 @get_file_hash(i8* %0, i8* %3)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %3)
br label %12
10: ; preds = %1
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %12
12: ; preds = %10, %8
ret void
}