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

/* Variables and functions */
int /*<<< orphan*/ SHA1_Init(int /*<<< orphan*/ *);
scalar_t__ Sha1Digest(char *, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  SHA_CTX c;
  if (argc == 3) {
    SHA1_Init(&c);
    if (Sha1Digest(argv[1], argv[2], &c)) {
      printf("digest error\n");
    }
  } else {
    printf("usage: prog name, message file name, digest file name");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    118d <main+0x5d>
lea    -0x14(%rbp),%rdi
call   1050 <SHA1_Init@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <Sha1Digest@plt>
cmp    $0x0,%rax
je     1188 <main+0x58>
lea    0xe7d(%rip),%rdi
call   1040 <printf@plt>
jmp    1199 <main+0x69>
lea    0xe7a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x3,%edi
jne    117c <main+0x3c>
mov    %rsi,%rbx
lea    0x4(%rsp),%r14
mov    %r14,%rdi
call   1060 <SHA1_Init@plt>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
mov    %r14,%rdx
call   1030 <Sha1Digest@plt>
test   %rax,%rax
je     1188 <main+0x48>
lea    0xec1(%rip),%rdi
call   1040 <puts@plt>
jmp    1188 <main+0x48>
lea    0xe7d(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [14 x i8] c"digest error\0A\00"
@.str.1 = [54 x i8] c"usage: prog name, message file name, digest file name\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 3
br i1 %8, label %9, label %22
9: ; preds = %2
%10 = call i32 @SHA1_Init(i32* %6)
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i64 @Sha1Digest(i8* %13, i8* %16, i32* %6)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %9
%20 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %9
br label %24
22: ; preds = %2
%23 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %21
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [54 x i8] c"usage: prog name, message file name, digest file name\00"
@str = [13 x i8] c"digest error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 3
br i1 %5, label %6, label %16
6: ; preds = %2
%7 = call i32 @SHA1_Init(i32* %3)
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = call i64 @Sha1Digest(i8* %9, i8* %11, i32* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %6
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %18
16: ; preds = %2
%17 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %6, %14, %16
ret i32 0
}