#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*/ copy4(unsigned char *, unsigned int);
int /*<<< orphan*/ copy64(unsigned int *, unsigned char *);
int /*<<< orphan*/ mdfour64(unsigned int *, unsigned int *, unsigned int *,
                            unsigned int *, unsigned int *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
void mdfour(unsigned char *out, unsigned char *in, int n) {
  unsigned char buf[128];
  unsigned int M[16];
  unsigned int b = n * 8;
  int i;
  unsigned int A = 0x67452301;
  unsigned int B = 0xefcdab89;
  unsigned int C = 0x98badcfe;
  unsigned int D = 0x10325476;
  while (n > 64) {
    copy64(M, in);
    mdfour64(M, &A, &B, &C, &D);
    in += 64;
    n -= 64;
  }
  for (i = 0; i < 128; i++)
    buf[i] = 0;
  memcpy(buf, in, n);
  buf[n] = 0x80;
  if (n <= 55) {
    copy4(buf + 56, b);
    copy64(M, buf);
    mdfour64(M, &A, &B, &C, &D);
  } else {
    copy4(buf + 120, b);
    copy64(M, buf);
    mdfour64(M, &A, &B, &C, &D);
    copy64(M, buf + 64);
    mdfour64(M, &A, &B, &C, &D);
  }
  for (i = 0; i < 128; i++)
    buf[i] = 0;
  copy64(M, buf);
  copy4(out, A);
  copy4(out + 4, B);
  copy4(out + 8, C);
  copy4(out + 12, D);
  A = B = C = D = 0;
}


x86 assembly (clang, -O0):
<mdfour>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x3,%eax
mov    %eax,-0xe4(%rbp)
movl   $0x67452301,-0xec(%rbp)
23 45 67
movl   $0xefcdab89,-0xf0(%rbp)
ab cd ef
movl   $0x98badcfe,-0xf4(%rbp)
dc ba 98
movl   $0x10325476,-0xf8(%rbp)
54 32 10
cmpl   $0x40,-0x14(%rbp)
jle    11e6 <mdfour+0xa6>
lea    -0xe0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <copy64@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xec(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
lea    -0xf4(%rbp),%rcx
lea    -0xf8(%rbp),%r8
call   1050 <mdfour64@plt>
mov    -0x10(%rbp),%rax
add    $0x40,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x40,%eax
mov    %eax,-0x14(%rbp)
jmp    118a <mdfour+0x4a>
movl   $0x0,-0xe8(%rbp)
cmpl   $0x80,-0xe8(%rbp)
jge    1223 <mdfour+0xe3>
movslq -0xe8(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    11f0 <mdfour+0xb0>
lea    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <memcpy@plt>
movslq -0x14(%rbp),%rax
movb   $0x80,-0xa0(%rbp,%rax,1)
80
cmpl   $0x37,-0x14(%rbp)
jg     12a2 <mdfour+0x162>
lea    -0xa0(%rbp),%rdi
add    $0x38,%rdi
mov    -0xe4(%rbp),%esi
call   1040 <copy4@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1030 <copy64@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xec(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
lea    -0xf4(%rbp),%rcx
lea    -0xf8(%rbp),%r8
call   1050 <mdfour64@plt>
jmp    1332 <mdfour+0x1f2>
lea    -0xa0(%rbp),%rdi
add    $0x78,%rdi
mov    -0xe4(%rbp),%esi
call   1040 <copy4@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1030 <copy64@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xec(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
lea    -0xf4(%rbp),%rcx
lea    -0xf8(%rbp),%r8
call   1050 <mdfour64@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
add    $0x40,%rsi
call   1030 <copy64@plt>
lea    -0xe0(%rbp),%rdi
lea    -0xec(%rbp),%rsi
lea    -0xf0(%rbp),%rdx
lea    -0xf4(%rbp),%rcx
lea    -0xf8(%rbp),%r8
call   1050 <mdfour64@plt>
movl   $0x0,-0xe8(%rbp)
cmpl   $0x80,-0xe8(%rbp)
jge    136f <mdfour+0x22f>
movslq -0xe8(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
mov    -0xe8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe8(%rbp)
jmp    133c <mdfour+0x1fc>
lea    -0xe0(%rbp),%rdi
lea    -0xa0(%rbp),%rsi
call   1030 <copy64@plt>
mov    -0x8(%rbp),%rdi
mov    -0xec(%rbp),%esi
call   1040 <copy4@plt>
mov    -0x8(%rbp),%rdi
add    $0x4,%rdi
mov    -0xf0(%rbp),%esi
call   1040 <copy4@plt>
mov    -0x8(%rbp),%rdi
add    $0x8,%rdi
mov    -0xf4(%rbp),%esi
call   1040 <copy4@plt>
mov    -0x8(%rbp),%rdi
add    $0xc,%rdi
mov    -0xf8(%rbp),%esi
call   1040 <copy4@plt>
movl   $0x0,-0xf8(%rbp)
movl   $0x0,-0xf4(%rbp)
movl   $0x0,-0xf0(%rbp)
movl   $0x0,-0xec(%rbp)
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mdfour>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rsi,%rbx
mov    %rdi,0x18(%rsp)
movl   $0x67452301,0x10(%rsp)
67
movl   $0xefcdab89,0xc(%rsp)
ef
movl   $0x98badcfe,0x8(%rsp)
98
movl   $0x10325476,0x4(%rsp)
10
cmp    $0x41,%edx
mov    %edx,0x14(%rsp)
jl     11d9 <mdfour+0x99>
lea    0xa0(%rsp),%rbp
lea    0x8(%rsp),%r14
lea    0x4(%rsp),%r12
mov    %edx,%r13d
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <copy64@plt>
mov    %rbp,%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
mov    %r14,%rcx
mov    %r12,%r8
call   1050 <mdfour64@plt>
add    $0x40,%rbx
lea    -0x40(%r13),%r15d
cmp    $0x80,%r13d
mov    %r15d,%r13d
ja     11a0 <mdfour+0x60>
jmp    11dc <mdfour+0x9c>
mov    %edx,%r15d
mov    0x14(%rsp),%ebp
shl    $0x3,%ebp
xorps  %xmm0,%xmm0
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
lea    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1060 <memcpy@plt>
movslq %r15d,%rax
movb   $0x80,0x20(%rsp,%rax,1)
cmp    $0x38,%eax
jge    124c <mdfour+0x10c>
lea    0x58(%rsp),%rdi
mov    %ebp,%esi
call   1040 <copy4@plt>
lea    0xa0(%rsp),%rdi
lea    0x20(%rsp),%rsi
jmp    1294 <mdfour+0x154>
lea    0x98(%rsp),%rdi
mov    %ebp,%esi
call   1040 <copy4@plt>
lea    0xa0(%rsp),%rbx
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <copy64@plt>
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rbx,%rdi
call   1050 <mdfour64@plt>
lea    0x60(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <copy64@plt>
lea    0xa0(%rsp),%rbx
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %rbx,%rdi
call   1050 <mdfour64@plt>
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x80(%rsp)
movaps %xmm0,0x90(%rsp)
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <copy64@plt>
mov    0x10(%rsp),%esi
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <copy4@plt>
lea    0x4(%rbx),%rdi
mov    0xc(%rsp),%esi
call   1040 <copy4@plt>
lea    0x8(%rbx),%rdi
mov    0x8(%rsp),%esi
call   1040 <copy4@plt>
add    $0xc,%rbx
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
call   1040 <copy4@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @mdfour(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [128 x i8]
%8 = alloca [16 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%15 = load i32, i32* %6
%16 = mul nsw i32 %15, 8
store i32 %16, i32* %9
store i32 1732584193, i32* %11
store i32 -271733879, i32* %12
store i32 -1732584194, i32* %13
store i32 271733878, i32* %14
br label %17
17: ; preds = %20, %3
%18 = load i32, i32* %6
%19 = icmp sgt i32 %18, 64
br i1 %19, label %20, label %30
20: ; preds = %17
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%22 = load i8*, i8** %5
%23 = call i32 @copy64(i32* %21, i8* %22)
%24 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%25 = call i32 @mdfour64(i32* %24, i32* %11, i32* %12, i32* %13, i32* %14)
%26 = load i8*, i8** %5
%27 = getelementptr inbounds i8, i8* %26, i64 64
store i8* %27, i8** %5
%28 = load i32, i32* %6
%29 = sub nsw i32 %28, 64
store i32 %29, i32* %6
br label %17
30: ; preds = %17
store i32 0, i32* %10
br label %31
31: ; preds = %38, %30
%32 = load i32, i32* %10
%33 = icmp slt i32 %32, 128
br i1 %33, label %34, label %41
34: ; preds = %31
%35 = load i32, i32* %10
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 %36
store i8 0, i8* %37
br label %38
38: ; preds = %34
%39 = load i32, i32* %10
%40 = add nsw i32 %39, 1
store i32 %40, i32* %10
br label %31
41: ; preds = %31
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%43 = load i8*, i8** %5
%44 = load i32, i32* %6
%45 = call i32 @memcpy(i8* %42, i8* %43, i32 %44)
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 %47
store i8 -128, i8* %48
%49 = load i32, i32* %6
%50 = icmp sle i32 %49, 55
br i1 %50, label %51, label %61
51: ; preds = %41
%52 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%53 = getelementptr inbounds i8, i8* %52, i64 56
%54 = load i32, i32* %9
%55 = call i32 @copy4(i8* %53, i32 %54)
%56 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%57 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%58 = call i32 @copy64(i32* %56, i8* %57)
%59 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%60 = call i32 @mdfour64(i32* %59, i32* %11, i32* %12, i32* %13, i32* %14)
br label %77
61: ; preds = %41
%62 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%63 = getelementptr inbounds i8, i8* %62, i64 120
%64 = load i32, i32* %9
%65 = call i32 @copy4(i8* %63, i32 %64)
%66 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%67 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%68 = call i32 @copy64(i32* %66, i8* %67)
%69 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%70 = call i32 @mdfour64(i32* %69, i32* %11, i32* %12, i32* %13, i32* %14)
%71 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%72 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%73 = getelementptr inbounds i8, i8* %72, i64 64
%74 = call i32 @copy64(i32* %71, i8* %73)
%75 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%76 = call i32 @mdfour64(i32* %75, i32* %11, i32* %12, i32* %13, i32* %14)
br label %77
77: ; preds = %61, %51
store i32 0, i32* %10
br label %78
78: ; preds = %85, %77
%79 = load i32, i32* %10
%80 = icmp slt i32 %79, 128
br i1 %80, label %81, label %88
81: ; preds = %78
%82 = load i32, i32* %10
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 %83
store i8 0, i8* %84
br label %85
85: ; preds = %81
%86 = load i32, i32* %10
%87 = add nsw i32 %86, 1
store i32 %87, i32* %10
br label %78
88: ; preds = %78
%89 = getelementptr inbounds [16 x i32], [16 x i32]* %8, i64 0, i64 0
%90 = getelementptr inbounds [128 x i8], [128 x i8]* %7, i64 0, i64 0
%91 = call i32 @copy64(i32* %89, i8* %90)
%92 = load i8*, i8** %4
%93 = load i32, i32* %11
%94 = call i32 @copy4(i8* %92, i32 %93)
%95 = load i8*, i8** %4
%96 = getelementptr inbounds i8, i8* %95, i64 4
%97 = load i32, i32* %12
%98 = call i32 @copy4(i8* %96, i32 %97)
%99 = load i8*, i8** %4
%100 = getelementptr inbounds i8, i8* %99, i64 8
%101 = load i32, i32* %13
%102 = call i32 @copy4(i8* %100, i32 %101)
%103 = load i8*, i8** %4
%104 = getelementptr inbounds i8, i8* %103, i64 12
%105 = load i32, i32* %14
%106 = call i32 @copy4(i8* %104, i32 %105)
store i32 0, i32* %14
store i32 0, i32* %13
store i32 0, i32* %12
store i32 0, i32* %11
ret void
}

LLVM IR (-O2):
define void @mdfour(i8* %0, i8* %1, i32 %2) {
%4 = alloca [128 x i8]
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%6 = alloca [16 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%12 = bitcast [16 x i32]* %6 to i8*
%13 = shl nsw i32 %2, 3
%14 = bitcast i32* %7 to i8*
store i32 1732584193, i32* %7
%15 = bitcast i32* %8 to i8*
store i32 -271733879, i32* %8
%16 = bitcast i32* %9 to i8*
store i32 -1732584194, i32* %9
%17 = bitcast i32* %10 to i8*
store i32 271733878, i32* %10
%18 = icmp sgt i32 %2, 64
br i1 %18, label %19, label %21
19: ; preds = %3
%20 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
br label %28
21: ; preds = %28, %3
%22 = phi i32 [ %2, %3 ], [ %34, %28 ]
%23 = phi i8* [ %1, %3 ], [ %33, %28 ]
%24 = call i32 @memcpy(i8* %11, i8* %23, i32 %22)
%25 = sext i32 %22 to i64
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 %25
store i8 -128, i8* %26
%27 = icmp slt i32 %22, 56
br i1 %27, label %36, label %41
28: ; preds = %19, %28
%29 = phi i8* [ %1, %19 ], [ %33, %28 ]
%30 = phi i32 [ %2, %19 ], [ %34, %28 ]
%31 = call i32 @copy64(i32* %20, i8* %29)
%32 = call i32 @mdfour64(i32* %20, i32* %7, i32* %8, i32* %9, i32* %10)
%33 = getelementptr inbounds i8, i8* %29, i64 64
%34 = add nsw i32 %30, -64
%35 = icmp ugt i32 %30, 128
br i1 %35, label %28, label %21
36: ; preds = %21
%37 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 56
%38 = call i32 @copy4(i8* %37, i32 %13)
%39 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%40 = call i32 @copy64(i32* %39, i8* %11)
br label %49
41: ; preds = %21
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 120
%43 = call i32 @copy4(i8* %42, i32 %13)
%44 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%45 = call i32 @copy64(i32* %44, i8* %11)
%46 = call i32 @mdfour64(i32* %44, i32* %7, i32* %8, i32* %9, i32* %10)
%47 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 64
%48 = call i32 @copy64(i32* %44, i8* %47)
br label %49
49: ; preds = %41, %36
%50 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%51 = call i32 @mdfour64(i32* %50, i32* %7, i32* %8, i32* %9, i32* %10)
%52 = getelementptr inbounds [16 x i32], [16 x i32]* %6, i64 0, i64 0
%53 = call i32 @copy64(i32* %52, i8* %11)
%54 = load i32, i32* %7
%55 = call i32 @copy4(i8* %0, i32 %54)
%56 = getelementptr inbounds i8, i8* %0, i64 4
%57 = load i32, i32* %8
%58 = call i32 @copy4(i8* %56, i32 %57)
%59 = getelementptr inbounds i8, i8* %0, i64 8
%60 = load i32, i32* %9
%61 = call i32 @copy4(i8* %59, i32 %60)
%62 = getelementptr inbounds i8, i8* %0, i64 12
%63 = load i32, i32* %10
%64 = call i32 @copy4(i8* %62, i32 %63)
ret void
}