#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*/ printf(char *, ...);
scalar_t__ sha1_wrapper(char *, unsigned char *);
int sha1_print(char *filename) {
  int i;
  unsigned char sum[20];
  if (sha1_wrapper(filename, sum) != 0)
    return (1);
  for (i = 0; i < 20; i++)
    printf("%02x", sum[i]);
  printf("  %s\n", filename);
  return (0);
}


x86 assembly (clang, -O0):
<sha1_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <sha1_wrapper@plt>
cmp    $0x0,%rax
je     114f <sha1_print+0x2f>
movl   $0x1,-0x4(%rbp)
jmp    119e <sha1_print+0x7e>
movl   $0x0,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jge    1185 <sha1_print+0x65>
movslq -0x14(%rbp),%rax
movzbl -0x30(%rbp,%rax,1),%esi
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1156 <sha1_print+0x36>
mov    -0x10(%rbp),%rsi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sha1_print>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
mov    %rsp,%rsi
call   1030 <sha1_wrapper@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1286 <sha1_print+0x166>
movzbl (%rsp),%esi
lea    0xeb4(%rip),%rbx
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x1(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x2(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x3(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x5(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x6(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x7(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x9(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xa(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xb(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xd(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xe(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0xf(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x11(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x12(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl 0x13(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd89(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
@.str.1 = [6 x i8] c" %s\0A\00"
define i32 @sha1_print(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [20 x i8]
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%8 = call i64 @sha1_wrapper(i8* %6, i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %1
store i32 1, i32* %2
br label %28
11: ; preds = %1
store i32 0, i32* %4
br label %12
12: ; preds = %22, %11
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 20
br i1 %14, label %15, label %25
15: ; preds = %12
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %15
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %12
25: ; preds = %12
%26 = load i8*, i8** %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %26)
store i32 0, i32* %2
br label %28
28: ; preds = %25, %10
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
@.str.1 = [6 x i8] c" %s\0A\00"
define i32 @sha1_print(i8* %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = call i64 @sha1_wrapper(i8* %0, i8* %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %87
6: ; preds = %1
%7 = load i8, i8* %3
%8 = zext i8 %7 to i32
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 1
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 2
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 3
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 4
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %24)
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 5
%27 = load i8, i8* %26
%28 = zext i8 %27 to i32
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 6
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 7
%35 = load i8, i8* %34
%36 = zext i8 %35 to i32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 8
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %40)
%42 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 9
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %44)
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 10
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %48)
%50 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 11
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %52)
%54 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 12
%55 = load i8, i8* %54
%56 = zext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %56)
%58 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 13
%59 = load i8, i8* %58
%60 = zext i8 %59 to i32
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %60)
%62 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 14
%63 = load i8, i8* %62
%64 = zext i8 %63 to i32
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %64)
%66 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 15
%67 = load i8, i8* %66
%68 = zext i8 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %68)
%70 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 16
%71 = load i8, i8* %70
%72 = zext i8 %71 to i32
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %72)
%74 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 17
%75 = load i8, i8* %74
%76 = zext i8 %75 to i32
%77 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %76)
%78 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 18
%79 = load i8, i8* %78
%80 = zext i8 %79 to i32
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %80)
%82 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 19
%83 = load i8, i8* %82
%84 = zext i8 %83 to i32
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %84)
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %87
87: ; preds = %1, %6
%88 = phi i32 [ 0, %6 ], [ 1, %1 ]
ret i32 %88
}