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

/* Variables and functions */
int /*<<< orphan*/ EVP_DigestFinal(int /*<<< orphan*/ *, unsigned char *,
                                   unsigned int *);
int /*<<< orphan*/ EVP_DigestInit(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ EVP_DigestUpdate(int /*<<< orphan*/ *, char const *, size_t);
int /*<<< orphan*/ EVP_MD_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_MD_CTX_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EVP_MD_CTX_new();
int /*<<< orphan*/ EVP_MD_size(int /*<<< orphan*/);
int /*<<< orphan*/ EVP_sha1();
char *oauth_body_hash_encode(size_t, unsigned char *);
scalar_t__ xcalloc(int /*<<< orphan*/, int);
char *oauth_body_hash_data(size_t length, const char *data) {
  EVP_MD_CTX *ctx;
  size_t len = 0;
  unsigned char *md;
  md = (unsigned char *)xcalloc(EVP_MD_size(EVP_sha1()), sizeof(unsigned char));
  ctx = EVP_MD_CTX_new();
  EVP_MD_CTX_init(ctx);
  EVP_DigestInit(ctx, EVP_sha1());
  EVP_DigestUpdate(ctx, data, length);
  EVP_DigestFinal(ctx, md, (unsigned int *)&len);
  EVP_MD_CTX_free(ctx);
  return oauth_body_hash_encode(len, md);
}


x86 assembly (clang, -O0):
<oauth_body_hash_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1050 <EVP_sha1@plt>
mov    %eax,%edi
call   1030 <EVP_MD_size@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10c0 <xcalloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   10a0 <EVP_MD_CTX_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1090 <EVP_MD_CTX_init@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1050 <EVP_sha1@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1060 <EVP_DigestInit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1080 <EVP_DigestUpdate@plt>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   10b0 <EVP_DigestFinal@plt>
mov    -0x18(%rbp),%rdi
call   1040 <EVP_MD_CTX_free@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1070 <oauth_body_hash_encode@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<oauth_body_hash_data>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
movq   $0x0,(%rsp)
xor    %eax,%eax
call   1050 <EVP_sha1@plt>
mov    %eax,%edi
call   1030 <EVP_MD_size@plt>
mov    %eax,%edi
mov    $0x1,%esi
call   10c0 <xcalloc@plt>
mov    %rax,%r12
xor    %eax,%eax
call   10a0 <EVP_MD_CTX_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1090 <EVP_MD_CTX_init@plt>
xor    %eax,%eax
call   1050 <EVP_sha1@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <EVP_DigestInit@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1080 <EVP_DigestUpdate@plt>
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
call   10b0 <EVP_DigestFinal@plt>
mov    %rbx,%rdi
call   1040 <EVP_MD_CTX_free@plt>
mov    (%rsp),%rdi
mov    %r12,%rsi
call   1070 <oauth_body_hash_encode@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8* @oauth_body_hash_data(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i64
%7 = alloca i8*
store i64 %0, i64* %3
store i8* %1, i8** %4
store i64 0, i64* %6
%8 = call i32 (...) @EVP_sha1()
%9 = call i32 @EVP_MD_size(i32 %8)
%10 = call i64 @xcalloc(i32 %9, i32 1)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %7
%12 = call i32* (...) @EVP_MD_CTX_new()
store i32* %12, i32** %5
%13 = load i32*, i32** %5
%14 = call i32 @EVP_MD_CTX_init(i32* %13)
%15 = load i32*, i32** %5
%16 = call i32 (...) @EVP_sha1()
%17 = call i32 @EVP_DigestInit(i32* %15, i32 %16)
%18 = load i32*, i32** %5
%19 = load i8*, i8** %4
%20 = load i64, i64* %3
%21 = call i32 @EVP_DigestUpdate(i32* %18, i8* %19, i64 %20)
%22 = load i32*, i32** %5
%23 = load i8*, i8** %7
%24 = bitcast i64* %6 to i32*
%25 = call i32 @EVP_DigestFinal(i32* %22, i8* %23, i32* %24)
%26 = load i32*, i32** %5
%27 = call i32 @EVP_MD_CTX_free(i32* %26)
%28 = load i64, i64* %6
%29 = load i8*, i8** %7
%30 = call i8* @oauth_body_hash_encode(i64 %28, i8* %29)
ret i8* %30
}

LLVM IR (-O2):
define i8* @oauth_body_hash_data(i64 %0, i8* %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%5 = tail call i32 (...) @EVP_sha1()
%6 = tail call i32 @EVP_MD_size(i32 %5)
%7 = tail call i64 @xcalloc(i32 %6, i32 1)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32* (...) @EVP_MD_CTX_new()
%10 = tail call i32 @EVP_MD_CTX_init(i32* %9)
%11 = tail call i32 (...) @EVP_sha1()
%12 = tail call i32 @EVP_DigestInit(i32* %9, i32 %11)
%13 = tail call i32 @EVP_DigestUpdate(i32* %9, i8* %1, i64 %0)
%14 = bitcast i64* %3 to i32*
%15 = call i32 @EVP_DigestFinal(i32* %9, i8* %8, i32* %14)
%16 = call i32 @EVP_MD_CTX_free(i32* %9)
%17 = load i64, i64* %3
%18 = call i8* @oauth_body_hash_encode(i64 %17, i8* %8)
ret i8* %18
}