#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int sha1_file(char *, unsigned char *);
int /*<<< orphan*/ stderr;
int sha1_wrapper(char *filename, unsigned char *sum) {
  int ret = sha1_file(filename, sum);
  if (ret == 1)
    fprintf(stderr, "failed to open: %s\n", filename);
  if (ret == 2)
    fprintf(stderr, "failed to read: %s\n", filename);
  return (ret);
}


x86 assembly (clang, -O0):
<sha1_wrapper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <sha1_file@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x1,-0x14(%rbp)
jne    1163 <sha1_wrapper+0x43>
mov    0x2e8f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xea2(%rip),%rsi
call   1040 <fprintf@plt>
cmpl   $0x2,-0x14(%rbp)
jne    1186 <sha1_wrapper+0x66>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe93(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sha1_wrapper>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <sha1_file@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
je     1140 <sha1_wrapper+0x20>
cmp    $0x2,%ebp
jne    1158 <sha1_wrapper+0x38>
lea    0xed6(%rip),%rsi
jmp    1147 <sha1_wrapper+0x27>
lea    0xeb9(%rip),%rsi
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"failed to open: %s\0A\00"
@.str.1 = [20 x i8] c"failed to read: %s\0A\00"
define i32 @sha1_wrapper(i8* %0, i8* %1) {
%3 = tail call i32 @sha1_file(i8* %0, i8* %1)
switch i32 %3, label %9 [
i32 1, label %5
i32 2, label %4
]
4: ; preds = %2
br label %5
5: ; preds = %2, %4
%6 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), %2 ]
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* %6, i8* %0)
br label %9
9: ; preds = %5, %2
ret i32 %3
}