#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 */
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  size_t num;
  unsigned int Nl;
  unsigned int Nh;
  unsigned long A;
  unsigned long B;
  unsigned long C;
  unsigned long D;
  scalar_t__ data;
};
typedef TYPE_1__ MD4_CTX;

/* Variables and functions */
int MD4_CBLOCK;
int /*<<< orphan*/ md4_block_data_order(TYPE_1__ *, unsigned char *, int);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int MD4_Final(unsigned char *md, MD4_CTX *c) {
  unsigned char *p = (unsigned char *)c->data;
  size_t n = c->num;
  p[n] = 0x80;
  n++;
  if (n > (MD4_CBLOCK - 8)) {
    memset(p + n, 0, MD4_CBLOCK - n);
    n = 0;
    md4_block_data_order(c, p, 1);
  }
  memset(p + n, 0, MD4_CBLOCK - 8 - n);
  p += MD4_CBLOCK - 8;
  (*((unsigned int *)(p)) = (c->Nl), (p) += 4);
  (*((unsigned int *)(p)) = (c->Nh), (p) += 4);
  p -= MD4_CBLOCK;
  md4_block_data_order(c, p, 1);
  c->num = 0;
  memset(p, 0, MD4_CBLOCK);
  do {
    unsigned long ll;
    ll = (c)->A;
    (void)(*((unsigned int *)((md))) = (ll), ((md)) += 4);
    ll = (c)->B;
    (void)(*((unsigned int *)((md))) = (ll), ((md)) += 4);
    ll = (c)->C;
    (void)(*((unsigned int *)((md))) = (ll), ((md)) += 4);
    ll = (c)->D;
    (void)(*((unsigned int *)((md))) = (ll), ((md)) += 4);
  } while (0);
  return 1;
}


x86 assembly (clang, -O0):
<MD4_Final>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x80,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2e7e(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x8,%ecx
movslq %ecx,%rcx
cmp    %rcx,%rax
jbe    11b4 <MD4_Final+0x94>
mov    -0x18(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    0x2e5e(%rip),%rax
movslq (%rax),%rax
sub    -0x20(%rbp),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1030 <md4_block_data_order@plt>
mov    -0x18(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    0x2e25(%rip),%rax
mov    (%rax),%eax
sub    $0x8,%eax
cltq
sub    -0x20(%rbp),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    0x2e0a(%rip),%rax
mov    (%rax),%ecx
sub    $0x8,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    0x2dbe(%rip),%rax
mov    (%rax),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1030 <md4_block_data_order@plt>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rdi
mov    0x2d81(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x8(%rbp)
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MD4_Final>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r12
mov    %rdi,%r14
mov    (%rsi),%rbx
mov    0x30(%rsi),%r15
movb   $0x80,(%r15,%rbx,1)
add    $0x1,%rbx
mov    0x2ea2(%rip),%r13
movslq 0x0(%r13),%rax
lea    -0x8(%rax),%rdx
cmp    %rdx,%rbx
jbe    117b <MD4_Final+0x5b>
lea    (%r15,%rbx,1),%rdi
sub    %ebx,%eax
xor    %ebx,%ebx
xor    %esi,%esi
mov    %eax,%edx
call   1040 <memset@plt>
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <md4_block_data_order@plt>
mov    0x0(%r13),%edx
add    $0xfffffff8,%edx
lea    (%r15,%rbx,1),%rdi
sub    %ebx,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movslq 0x0(%r13),%rax
mov    0x8(%r12),%ecx
mov    %ecx,-0x8(%rax,%r15,1)
lea    (%rax,%r15,1),%rbx
add    $0xfffffffffffffffc,%rbx
mov    0xc(%r12),%ecx
mov    %ecx,-0x4(%rax,%r15,1)
movslq 0x0(%r13),%rax
sub    %rax,%rbx
add    $0x4,%rbx
mov    %r12,%rdi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <md4_block_data_order@plt>
movq   $0x0,(%r12)
mov    0x0(%r13),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
movdqu 0x10(%r12),%xmm0
pshufd $0xe8,%xmm0,%xmm0
movq   %xmm0,(%r14)
movdqu 0x20(%r12),%xmm0
pshufd $0xe8,%xmm0,%xmm0
movq   %xmm0,0x8(%r14)
mov    $0x1,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i64, i32, i32, i64, i64, i64, i64, i64 }
@MD4_CBLOCK = global i32 0
define i32 @MD4_Final(i8* %0, %struct.TYPE_4__* %1) {
%3 = alloca i8*
%4 = alloca %struct.TYPE_4__*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i8* %0, i8** %3
store %struct.TYPE_4__* %1, %struct.TYPE_4__** %4
%8 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%9 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %8, i32 0, i32 7
%10 = load i64, i64* %9
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %5
%12 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 0
%14 = load i64, i64* %13
store i64 %14, i64* %6
%15 = load i8*, i8** %5
%16 = load i64, i64* %6
%17 = getelementptr inbounds i8, i8* %15, i64 %16
store i8 -128, i8* %17
%18 = load i64, i64* %6
%19 = add i64 %18, 1
store i64 %19, i64* %6
%20 = load i64, i64* %6
%21 = load i32, i32* @MD4_CBLOCK
%22 = sub nsw i32 %21, 8
%23 = sext i32 %22 to i64
%24 = icmp ugt i64 %20, %23
br i1 %24, label %25, label %38
25: ; preds = %2
%26 = load i8*, i8** %5
%27 = load i64, i64* %6
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = load i32, i32* @MD4_CBLOCK
%30 = sext i32 %29 to i64
%31 = load i64, i64* %6
%32 = sub i64 %30, %31
%33 = trunc i64 %32 to i32
%34 = call i32 @memset(i8* %28, i32 0, i32 %33)
store i64 0, i64* %6
%35 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%36 = load i8*, i8** %5
%37 = call i32 @md4_block_data_order(%struct.TYPE_4__* %35, i8* %36, i32 1)
br label %38
38: ; preds = %25, %2
%39 = load i8*, i8** %5
%40 = load i64, i64* %6
%41 = getelementptr inbounds i8, i8* %39, i64 %40
%42 = load i32, i32* @MD4_CBLOCK
%43 = sub nsw i32 %42, 8
%44 = sext i32 %43 to i64
%45 = load i64, i64* %6
%46 = sub i64 %44, %45
%47 = trunc i64 %46 to i32
%48 = call i32 @memset(i8* %41, i32 0, i32 %47)
%49 = load i32, i32* @MD4_CBLOCK
%50 = sub nsw i32 %49, 8
%51 = load i8*, i8** %5
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds i8, i8* %51, i64 %52
store i8* %53, i8** %5
%54 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%55 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %54, i32 0, i32 1
%56 = load i32, i32* %55
%57 = load i8*, i8** %5
%58 = bitcast i8* %57 to i32*
store i32 %56, i32* %58
%59 = load i8*, i8** %5
%60 = getelementptr inbounds i8, i8* %59, i64 4
store i8* %60, i8** %5
%61 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%62 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %61, i32 0, i32 2
%63 = load i32, i32* %62
%64 = load i8*, i8** %5
%65 = bitcast i8* %64 to i32*
store i32 %63, i32* %65
%66 = load i8*, i8** %5
%67 = getelementptr inbounds i8, i8* %66, i64 4
store i8* %67, i8** %5
%68 = load i32, i32* @MD4_CBLOCK
%69 = load i8*, i8** %5
%70 = sext i32 %68 to i64
%71 = sub i64 0, %70
%72 = getelementptr inbounds i8, i8* %69, i64 %71
store i8* %72, i8** %5
%73 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%74 = load i8*, i8** %5
%75 = call i32 @md4_block_data_order(%struct.TYPE_4__* %73, i8* %74, i32 1)
%76 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%77 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %76, i32 0, i32 0
store i64 0, i64* %77
%78 = load i8*, i8** %5
%79 = load i32, i32* @MD4_CBLOCK
%80 = call i32 @memset(i8* %78, i32 0, i32 %79)
br label %81
81: ; preds = %38
%82 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%83 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %82, i32 0, i32 3
%84 = load i64, i64* %83
store i64 %84, i64* %7
%85 = load i64, i64* %7
%86 = trunc i64 %85 to i32
%87 = load i8*, i8** %3
%88 = bitcast i8* %87 to i32*
store i32 %86, i32* %88
%89 = load i8*, i8** %3
%90 = getelementptr inbounds i8, i8* %89, i64 4
store i8* %90, i8** %3
%91 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%92 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %91, i32 0, i32 4
%93 = load i64, i64* %92
store i64 %93, i64* %7
%94 = load i64, i64* %7
%95 = trunc i64 %94 to i32
%96 = load i8*, i8** %3
%97 = bitcast i8* %96 to i32*
store i32 %95, i32* %97
%98 = load i8*, i8** %3
%99 = getelementptr inbounds i8, i8* %98, i64 4
store i8* %99, i8** %3
%100 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%101 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %100, i32 0, i32 5
%102 = load i64, i64* %101
store i64 %102, i64* %7
%103 = load i64, i64* %7
%104 = trunc i64 %103 to i32
%105 = load i8*, i8** %3
%106 = bitcast i8* %105 to i32*
store i32 %104, i32* %106
%107 = load i8*, i8** %3
%108 = getelementptr inbounds i8, i8* %107, i64 4
store i8* %108, i8** %3
%109 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%110 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %109, i32 0, i32 6
%111 = load i64, i64* %110
store i64 %111, i64* %7
%112 = load i64, i64* %7
%113 = trunc i64 %112 to i32
%114 = load i8*, i8** %3
%115 = bitcast i8* %114 to i32*
store i32 %113, i32* %115
%116 = load i8*, i8** %3
%117 = getelementptr inbounds i8, i8* %116, i64 4
store i8* %117, i8** %3
br label %118
118: ; preds = %81
ret i32 1
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i64, i32, i32, i64, i64, i64, i64, i64 }
@MD4_CBLOCK = global i32 0
define i32 @MD4_Final(i8* nocapture writeonly %0, %struct.TYPE_4__* %1) {
%3 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 7
%4 = load i64, i64* %3
%5 = inttoptr i64 %4 to i8*
%6 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 0
%7 = load i64, i64* %6
%8 = getelementptr inbounds i8, i8* %5, i64 %7
store i8 -128, i8* %8
%9 = add i64 %7, 1
%10 = load i32, i32* @MD4_CBLOCK
%11 = add nsw i32 %10, -8
%12 = sext i32 %11 to i64
%13 = icmp ugt i64 %9, %12
br i1 %13, label %14, label %22
14: ; preds = %2
%15 = getelementptr inbounds i8, i8* %5, i64 %9
%16 = trunc i64 %9 to i32
%17 = sub i32 %10, %16
%18 = tail call i32 @memset(i8* %15, i32 0, i32 %17)
%19 = tail call i32 @md4_block_data_order(%struct.TYPE_4__* %1, i8* %5, i32 1)
%20 = load i32, i32* @MD4_CBLOCK
%21 = add nsw i32 %20, -8
br label %22
22: ; preds = %14, %2
%23 = phi i32 [ %21, %14 ], [ %11, %2 ]
%24 = phi i64 [ 0, %14 ], [ %9, %2 ]
%25 = getelementptr inbounds i8, i8* %5, i64 %24
%26 = trunc i64 %24 to i32
%27 = sub i32 %23, %26
%28 = tail call i32 @memset(i8* %25, i32 0, i32 %27)
%29 = load i32, i32* @MD4_CBLOCK
%30 = add nsw i32 %29, -8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %5, i64 %31
%33 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 1
%34 = load i32, i32* %33
%35 = bitcast i8* %32 to i32*
store i32 %34, i32* %35
%36 = getelementptr inbounds i8, i8* %32, i64 4
%37 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 2
%38 = load i32, i32* %37
%39 = bitcast i8* %36 to i32*
store i32 %38, i32* %39
%40 = getelementptr inbounds i8, i8* %36, i64 4
%41 = load i32, i32* @MD4_CBLOCK
%42 = sext i32 %41 to i64
%43 = sub nsw i64 0, %42
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = tail call i32 @md4_block_data_order(%struct.TYPE_4__* %1, i8* %44, i32 1)
store i64 0, i64* %6
%46 = load i32, i32* @MD4_CBLOCK
%47 = tail call i32 @memset(i8* %44, i32 0, i32 %46)
%48 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 3
%49 = bitcast i64* %48 to <2 x i64>*
%50 = load <2 x i64>, <2 x i64>* %49
%51 = trunc <2 x i64> %50 to <2 x i32>
%52 = bitcast i8* %0 to <2 x i32>*
store <2 x i32> %51, <2 x i32>* %52
%53 = getelementptr inbounds i8, i8* %0, i64 8
%54 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %1, i64 0, i32 5
%55 = bitcast i64* %54 to <2 x i64>*
%56 = load <2 x i64>, <2 x i64>* %55
%57 = trunc <2 x i64> %56 to <2 x i32>
%58 = bitcast i8* %53 to <2 x i32>*
store <2 x i32> %57, <2 x i32>* %58
ret i32 1
}