#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*/ uint32_t;
struct CRYPTO_HASH_CTX {
  int dummy;
};
typedef int /*<<< orphan*/ EVP_MD_CTX;

/* Variables and functions */
scalar_t__ EVP_DigestUpdate(int /*<<< orphan*/ *, void const *,
                            int /*<<< orphan*/);
int /*<<< orphan*/ ssh_set_error(char *);
int crypto_sha2_update(struct CRYPTO_HASH_CTX *crypto_ctx, const void *data,
                       uint32_t len) {
  EVP_MD_CTX *ctx = ((EVP_MD_CTX *)(crypto_ctx));
  if (EVP_DigestUpdate(ctx, data, len) == 0) {
    ssh_set_error("error updating sha2 hash");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<crypto_sha2_update>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <EVP_DigestUpdate@plt>
cmp    $0x0,%rax
jne    116d <crypto_sha2_update+0x4d>
lea    0xea4(%rip),%rdi
call   1040 <ssh_set_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1174 <crypto_sha2_update+0x54>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crypto_sha2_update>:
push   %rax
call   1030 <EVP_DigestUpdate@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1132 <crypto_sha2_update+0x12>
pop    %rcx
ret
lea    0xec7(%rip),%rdi
call   1040 <ssh_set_error@plt>
mov    $0xffffffff,%eax
pop    %rcx
ret

LLVM IR (-O0):
%struct.CRYPTO_HASH_CTX = type { i32 }
@.str = [25 x i8] c"error updating sha2 hash\00"
define i32 @crypto_sha2_update(%struct.CRYPTO_HASH_CTX* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.CRYPTO_HASH_CTX*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
store %struct.CRYPTO_HASH_CTX* %0, %struct.CRYPTO_HASH_CTX** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load %struct.CRYPTO_HASH_CTX*, %struct.CRYPTO_HASH_CTX** %5
%10 = bitcast %struct.CRYPTO_HASH_CTX* %9 to i32*
store i32* %10, i32** %8
%11 = load i32*, i32** %8
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = call i64 @EVP_DigestUpdate(i32* %11, i8* %12, i32 %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = call i32 @ssh_set_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %19
18: ; preds = %3
store i32 0, i32* %4
br label %19
19: ; preds = %18, %16
%20 = load i32, i32* %4
ret i32 %20
}

LLVM IR (-O2):
%struct.CRYPTO_HASH_CTX = type { i32 }
@.str = [25 x i8] c"error updating sha2 hash\00"
define i32 @crypto_sha2_update(%struct.CRYPTO_HASH_CTX* %0, i8* %1, i32 %2) {
%4 = getelementptr %struct.CRYPTO_HASH_CTX, %struct.CRYPTO_HASH_CTX* %0, i64 0, i32 0
%5 = tail call i64 @EVP_DigestUpdate(i32* %4, i8* %1, i32 %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %3
%8 = tail call i32 @ssh_set_error(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %3, %7
%10 = phi i32 [ -1, %7 ], [ 0, %3 ]
ret i32 %10
}