#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;
  (void)(*((unsigned int *)(p)) = (c->Nl), (p) += 4, c->Nl);
  (void)(*((unsigned int *)(p)) = (c->Nh), (p) += 4, c->Nh);
  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);
    ll = (c)->B;
    (void)(*((unsigned int *)((md))) = (ll), ((md)) += 4, ll);
    ll = (c)->C;
    (void)(*((unsigned int *)((md))) = (ll), ((md)) += 4, ll);
    ll = (c)->D;
    (void)(*((unsigned int *)((md))) = (ll), ((md)) += 4, ll);
  } 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 1
%63 = load i32, i32* %62
%64 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%65 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %64, i32 0, i32 2
%66 = load i32, i32* %65
%67 = load i8*, i8** %5
%68 = bitcast i8* %67 to i32*
store i32 %66, i32* %68
%69 = load i8*, i8** %5
%70 = getelementptr inbounds i8, i8* %69, i64 4
store i8* %70, i8** %5
%71 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%72 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %71, i32 0, i32 2
%73 = load i32, i32* %72
%74 = load i32, i32* @MD4_CBLOCK
%75 = load i8*, i8** %5
%76 = sext i32 %74 to i64
%77 = sub i64 0, %76
%78 = getelementptr inbounds i8, i8* %75, i64 %77
store i8* %78, i8** %5
%79 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%80 = load i8*, i8** %5
%81 = call i32 @md4_block_data_order(%struct.TYPE_4__* %79, i8* %80, i32 1)
%82 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%83 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %82, i32 0, i32 0
store i64 0, i64* %83
%84 = load i8*, i8** %5
%85 = load i32, i32* @MD4_CBLOCK
%86 = call i32 @memset(i8* %84, i32 0, i32 %85)
br label %87
87: ; preds = %38
%88 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%89 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %88, i32 0, i32 3
%90 = load i64, i64* %89
store i64 %90, i64* %7
%91 = load i64, i64* %7
%92 = trunc i64 %91 to i32
%93 = load i8*, i8** %3
%94 = bitcast i8* %93 to i32*
store i32 %92, i32* %94
%95 = load i8*, i8** %3
%96 = getelementptr inbounds i8, i8* %95, i64 4
store i8* %96, i8** %3
%97 = load i64, i64* %7
%98 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%99 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %98, i32 0, i32 4
%100 = load i64, i64* %99
store i64 %100, i64* %7
%101 = load i64, i64* %7
%102 = trunc i64 %101 to i32
%103 = load i8*, i8** %3
%104 = bitcast i8* %103 to i32*
store i32 %102, i32* %104
%105 = load i8*, i8** %3
%106 = getelementptr inbounds i8, i8* %105, i64 4
store i8* %106, i8** %3
%107 = load i64, i64* %7
%108 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%109 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %108, i32 0, i32 5
%110 = load i64, i64* %109
store i64 %110, i64* %7
%111 = load i64, i64* %7
%112 = trunc i64 %111 to i32
%113 = load i8*, i8** %3
%114 = bitcast i8* %113 to i32*
store i32 %112, i32* %114
%115 = load i8*, i8** %3
%116 = getelementptr inbounds i8, i8* %115, i64 4
store i8* %116, i8** %3
%117 = load i64, i64* %7
%118 = load %struct.TYPE_4__*, %struct.TYPE_4__** %4
%119 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %118, i32 0, i32 6
%120 = load i64, i64* %119
store i64 %120, i64* %7
%121 = load i64, i64* %7
%122 = trunc i64 %121 to i32
%123 = load i8*, i8** %3
%124 = bitcast i8* %123 to i32*
store i32 %122, i32* %124
%125 = load i8*, i8** %3
%126 = getelementptr inbounds i8, i8* %125, i64 4
store i8* %126, i8** %3
%127 = load i64, i64* %7
br label %128
128: ; preds = %87
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
}