#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*/ EVP_sha1();
int /*<<< orphan*/ HMAC(int /*<<< orphan*/, unsigned char const *, size_t,
                        unsigned char const *, size_t, unsigned char *,
                        unsigned int *);
unsigned int SHA_DIGEST_LENGTH;
int hmac_sha1_generate(unsigned char *hash, const unsigned char *text,
                       size_t text_len, const unsigned char *key,
                       size_t key_len) {
  unsigned int md_len = SHA_DIGEST_LENGTH;
  if (!HMAC(EVP_sha1(), key, key_len, text, text_len, hash, &md_len)) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<hmac_sha1_generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    $0x0,%al
call   1030 <EVP_sha1@plt>
mov    %eax,%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x10(%rbp),%r9
lea    -0x34(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <HMAC@plt>
cmp    $0x0,%eax
jne    1187 <hmac_sha1_generate+0x67>
movl   $0xffffffff,-0x4(%rbp)
jmp    118e <hmac_sha1_generate+0x6e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hmac_sha1_generate>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r14
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
mov    0x2ea5(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
xor    %eax,%eax
call   1030 <EVP_sha1@plt>
lea    0xc(%rsp),%rcx
mov    %rcx,(%rsp)
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r15,%r8
mov    %r13,%r9
call   1040 <HMAC@plt>
cmp    $0x1,%eax
sbb    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SHA_DIGEST_LENGTH = global i32 0
define i32 @hmac_sha1_generate(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i64 %2, i64* %9
store i8* %3, i8** %10
store i64 %4, i64* %11
%13 = load i32, i32* @SHA_DIGEST_LENGTH
store i32 %13, i32* %12
%14 = call i32 (...) @EVP_sha1()
%15 = load i8*, i8** %10
%16 = load i64, i64* %11
%17 = load i8*, i8** %8
%18 = load i64, i64* %9
%19 = load i8*, i8** %7
%20 = call i32 @HMAC(i32 %14, i8* %15, i64 %16, i8* %17, i64 %18, i8* %19, i32* %12)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %5
store i32 -1, i32* %6
br label %24
23: ; preds = %5
store i32 0, i32* %6
br label %24
24: ; preds = %23, %22
%25 = load i32, i32* %6
ret i32 %25
}

LLVM IR (-O2):
@SHA_DIGEST_LENGTH = global i32 0
define i32 @hmac_sha1_generate(i8* %0, i8* %1, i64 %2, i8* %3, i64 %4) {
%6 = alloca i32
%7 = bitcast i32* %6 to i8*
%8 = load i32, i32* @SHA_DIGEST_LENGTH
store i32 %8, i32* %6
%9 = tail call i32 (...) @EVP_sha1()
%10 = call i32 @HMAC(i32 %9, i8* %3, i64 %4, i8* %1, i64 %2, i8* %0, i32* %6)
%11 = icmp eq i32 %10, 0
%12 = sext i1 %11 to i32
ret i32 %12
}