#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 */
unsigned char *SHA1(unsigned char *, int, unsigned char *);
int SHA_DIGEST_LENGTH;
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
int getSha1(const unsigned char buf1[SHA_DIGEST_LENGTH],
            const unsigned char buf2[SHA_DIGEST_LENGTH],
            unsigned char sha1Buf[SHA_DIGEST_LENGTH]) {
  int status = 0;
  unsigned char resultBuf[2 * SHA_DIGEST_LENGTH];
  memcpy(resultBuf, buf1, SHA_DIGEST_LENGTH);
  memcpy(resultBuf + SHA_DIGEST_LENGTH, buf2, SHA_DIGEST_LENGTH);
  sha1Buf = SHA1(resultBuf, 2 * SHA_DIGEST_LENGTH, sha1Buf);
  return status;
}


x86 assembly (clang, -O0):
<getSha1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ead(%rip),%rax
movl   $0x0,-0x1c(%rbp)
mov    (%rax),%eax
add    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x38(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rsi
mov    0x2e74(%rip),%rax
mov    (%rax),%edx
call   1030 <memcpy@plt>
mov    -0x38(%rbp),%rdi
mov    0x2e62(%rip),%rax
movslq (%rax),%rax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e51(%rip),%rax
mov    (%rax),%edx
call   1030 <memcpy@plt>
mov    -0x38(%rbp),%rdi
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
shl    $0x1,%esi
mov    -0x18(%rbp),%rdx
call   1040 <SHA1@plt>
mov    %rax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getSha1>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rsi
mov    0x2ead(%rip),%r12
mov    (%r12),%edx
lea    (%rdx,%rdx,1),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
call   1030 <memcpy@plt>
movslq (%r12),%rdx
mov    %rdx,%rdi
add    %rbx,%rdi
mov    %r15,%rsi
call   1030 <memcpy@plt>
mov    (%r12),%esi
add    %esi,%esi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1040 <SHA1@plt>
xor    %eax,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SHA_DIGEST_LENGTH = global i32 0
define i32 @getSha1(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = load i32, i32* @SHA_DIGEST_LENGTH
%11 = zext i32 %10 to i64
%12 = load i32, i32* @SHA_DIGEST_LENGTH
%13 = zext i32 %12 to i64
%14 = load i32, i32* @SHA_DIGEST_LENGTH
%15 = zext i32 %14 to i64
store i32 0, i32* %7
%16 = load i32, i32* @SHA_DIGEST_LENGTH
%17 = mul nsw i32 2, %16
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %8
%20 = alloca i8, i64 %18
store i64 %18, i64* %9
%21 = load i8*, i8** %4
%22 = load i32, i32* @SHA_DIGEST_LENGTH
%23 = call i32 @memcpy(i8* %20, i8* %21, i32 %22)
%24 = load i32, i32* @SHA_DIGEST_LENGTH
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %20, i64 %25
%27 = load i8*, i8** %5
%28 = load i32, i32* @SHA_DIGEST_LENGTH
%29 = call i32 @memcpy(i8* %26, i8* %27, i32 %28)
%30 = load i32, i32* @SHA_DIGEST_LENGTH
%31 = mul nsw i32 2, %30
%32 = load i8*, i8** %6
%33 = call i8* @SHA1(i8* %20, i32 %31, i8* %32)
store i8* %33, i8** %6
%34 = load i32, i32* %7
%35 = load i8*, i8** %8
ret i32 %34
}

LLVM IR (-O2):
@SHA_DIGEST_LENGTH = global i32 0
define i32 @getSha1(i8* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @SHA_DIGEST_LENGTH
%5 = shl nsw i32 %4, 1
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = call i32 @memcpy(i8* %7, i8* %0, i32 %4)
%9 = load i32, i32* @SHA_DIGEST_LENGTH
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %7, i64 %10
%12 = call i32 @memcpy(i8* %11, i8* %1, i32 %9)
%13 = load i32, i32* @SHA_DIGEST_LENGTH
%14 = shl nsw i32 %13, 1
%15 = call i8* @SHA1(i8* %7, i32 %14, i8* %2)
ret i32 0
}