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

/* Variables and functions */
int calcsum(int /*<<< orphan*/ *, size_t, void *, size_t,
            int /*<<< orphan*/ const *, size_t, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int pgpv_digest_memory(uint8_t *data, size_t size, void *mem, size_t cc,
                       const uint8_t *hashed, size_t hashsize, int doarmor) {
  if (hashed == NULL || data == NULL || mem == NULL) {
    fprintf(stderr, "no hashed data provided\n");
    return 0;
  }
  return calcsum(data, size, mem, cc, hashed, hashsize, doarmor);
}


x86 assembly (clang, -O0):
<pgpv_digest_memory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1164 <pgpv_digest_memory+0x44>
cmpq   $0x0,-0x10(%rbp)
je     1164 <pgpv_digest_memory+0x44>
cmpq   $0x0,-0x20(%rbp)
jne    1185 <pgpv_digest_memory+0x65>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
lea    0xe8c(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11ab <pgpv_digest_memory+0x8b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    -0x38(%rbp),%r9
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <calcsum@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pgpv_digest_memory>:
test   %rdx,%rdx
je     1134 <pgpv_digest_memory+0x14>
test   %rdi,%rdi
je     1134 <pgpv_digest_memory+0x14>
test   %r8,%r8
je     1134 <pgpv_digest_memory+0x14>
jmp    1040 <calcsum@plt>
push   %rax
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
lea    0xebb(%rip),%rsi
call   1030 <fprintf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [25 x i8] c"no hashed data provided\0A\00"
define i32 @pgpv_digest_memory(i32* %0, i64 %1, i8* %2, i64 %3, i32* %4, i64 %5, i32 %6) {
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i64
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i32*
%14 = alloca i64
%15 = alloca i32
store i32* %0, i32** %9
store i64 %1, i64* %10
store i8* %2, i8** %11
store i64 %3, i64* %12
store i32* %4, i32** %13
store i64 %5, i64* %14
store i32 %6, i32* %15
%16 = load i32*, i32** %13
%17 = icmp eq i32* %16, null
br i1 %17, label %24, label %18
18: ; preds = %7
%19 = load i32*, i32** %9
%20 = icmp eq i32* %19, null
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = load i8*, i8** %11
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %27
24: ; preds = %21, %18, %7
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %36
27: ; preds = %21
%28 = load i32*, i32** %9
%29 = load i64, i64* %10
%30 = load i8*, i8** %11
%31 = load i64, i64* %12
%32 = load i32*, i32** %13
%33 = load i64, i64* %14
%34 = load i32, i32* %15
%35 = call i32 @calcsum(i32* %28, i64 %29, i8* %30, i64 %31, i32* %32, i64 %33, i32 %34)
store i32 %35, i32* %8
br label %36
36: ; preds = %27, %24
%37 = load i32, i32* %8
ret i32 %37
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"no hashed data provided\0A\00"
define i32 @pgpv_digest_memory(i32* %0, i64 %1, i8* %2, i64 %3, i32* %4, i64 %5, i32 %6) {
%8 = icmp eq i32* %4, null
%9 = icmp eq i32* %0, null
%10 = or i1 %9, %8
%11 = icmp eq i8* %2, null
%12 = or i1 %11, %10
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %18
16: ; preds = %7
%17 = tail call i32 @calcsum(i32* %0, i64 %1, i8* %2, i64 %3, i32* %4, i64 %5, i32 %6)
br label %18
18: ; preds = %16, %13
%19 = phi i32 [ 0, %13 ], [ %17, %16 ]
ret i32 %19
}