#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*/ h2net(unsigned int, unsigned char *, int);
int /*<<< orphan*/ md5_sum(unsigned char *, int, unsigned char *);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
void hash(unsigned char *pwd, unsigned char *id, unsigned char *chaldata,
          int chlen, unsigned int seq, unsigned char *mda, unsigned char md) {
  unsigned char pbuf[80];
  int blen, n, i;
  blen = 0;
  n = 16;
  memcpy(&pbuf[blen], pwd, n);
  blen += n;
  n = 4;
  memcpy(&pbuf[blen], id, n);
  blen += n;
  memcpy(&pbuf[blen], chaldata, chlen);
  blen += chlen;
  n = 4;
  h2net(seq, &pbuf[blen], n);
  blen += n;
  n = 16;
  memcpy(&pbuf[blen], pwd, n);
  blen += n;
  if (md == 0x01)
    i = 2;
  else
    i = 5;
  md5_sum(pbuf, blen, mda);
}


x86 assembly (clang, -O0):
<hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    0x10(%rbp),%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
movl   $0x0,-0x84(%rbp)
movl   $0x10,-0x88(%rbp)
movslq -0x84(%rbp),%rax
lea    -0x80(%rbp),%rdi
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x88(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x88(%rbp),%eax
add    -0x84(%rbp),%eax
mov    %eax,-0x84(%rbp)
movl   $0x4,-0x88(%rbp)
movslq -0x84(%rbp),%rax
lea    -0x80(%rbp),%rdi
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x88(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x88(%rbp),%eax
add    -0x84(%rbp),%eax
mov    %eax,-0x84(%rbp)
movslq -0x84(%rbp),%rax
lea    -0x80(%rbp),%rdi
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x1c(%rbp),%eax
add    -0x84(%rbp),%eax
mov    %eax,-0x84(%rbp)
movl   $0x4,-0x88(%rbp)
mov    -0x20(%rbp),%edi
movslq -0x84(%rbp),%rax
lea    -0x80(%rbp),%rsi
add    %rax,%rsi
mov    -0x88(%rbp),%edx
call   1040 <h2net@plt>
mov    -0x88(%rbp),%eax
add    -0x84(%rbp),%eax
mov    %eax,-0x84(%rbp)
movl   $0x10,-0x88(%rbp)
movslq -0x84(%rbp),%rax
lea    -0x80(%rbp),%rdi
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    -0x88(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x88(%rbp),%eax
add    -0x84(%rbp),%eax
mov    %eax,-0x84(%rbp)
movzbl 0x10(%rbp),%eax
cmp    $0x1,%eax
jne    1287 <hash+0x157>
movl   $0x2,-0x8c(%rbp)
jmp    1291 <hash+0x161>
movl   $0x5,-0x8c(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%esi
mov    -0x28(%rbp),%rdx
call   1030 <md5_sum@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hash>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,0x8(%rsp)
mov    %r8d,%r12d
mov    %ecx,%ebp
mov    %rdx,%r13
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
lea    0x20(%rsp),%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
lea    0x24(%rsp),%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1050 <memcpy@plt>
movslq %ebp,%rbp
lea    (%r15,%rbp,1),%rsi
add    $0x14,%rsi
mov    %r12d,%edi
mov    $0x4,%edx
call   1040 <h2net@plt>
lea    (%r15,%rbp,1),%rdi
add    $0x18,%rdi
mov    %rbx,%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
add    $0x28,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
mov    0x8(%rsp),%rdx
call   1030 <md5_sum@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @hash(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i8* %5, i8 zeroext %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i8
%15 = alloca [80 x i8]
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
store i8* %0, i8** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i8* %5, i8** %13
store i8 %6, i8* %14
store i32 0, i32* %16
store i32 16, i32* %17
%19 = load i32, i32* %16
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 %20
%22 = load i8*, i8** %8
%23 = load i32, i32* %17
%24 = call i32 @memcpy(i8* %21, i8* %22, i32 %23)
%25 = load i32, i32* %17
%26 = load i32, i32* %16
%27 = add nsw i32 %26, %25
store i32 %27, i32* %16
store i32 4, i32* %17
%28 = load i32, i32* %16
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 %29
%31 = load i8*, i8** %9
%32 = load i32, i32* %17
%33 = call i32 @memcpy(i8* %30, i8* %31, i32 %32)
%34 = load i32, i32* %17
%35 = load i32, i32* %16
%36 = add nsw i32 %35, %34
store i32 %36, i32* %16
%37 = load i32, i32* %16
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 %38
%40 = load i8*, i8** %10
%41 = load i32, i32* %11
%42 = call i32 @memcpy(i8* %39, i8* %40, i32 %41)
%43 = load i32, i32* %11
%44 = load i32, i32* %16
%45 = add nsw i32 %44, %43
store i32 %45, i32* %16
store i32 4, i32* %17
%46 = load i32, i32* %12
%47 = load i32, i32* %16
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 %48
%50 = load i32, i32* %17
%51 = call i32 @h2net(i32 %46, i8* %49, i32 %50)
%52 = load i32, i32* %17
%53 = load i32, i32* %16
%54 = add nsw i32 %53, %52
store i32 %54, i32* %16
store i32 16, i32* %17
%55 = load i32, i32* %16
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 %56
%58 = load i8*, i8** %8
%59 = load i32, i32* %17
%60 = call i32 @memcpy(i8* %57, i8* %58, i32 %59)
%61 = load i32, i32* %17
%62 = load i32, i32* %16
%63 = add nsw i32 %62, %61
store i32 %63, i32* %16
%64 = load i8, i8* %14
%65 = zext i8 %64 to i32
%66 = icmp eq i32 %65, 1
br i1 %66, label %67, label %68
67: ; preds = %7
store i32 2, i32* %18
br label %69
68: ; preds = %7
store i32 5, i32* %18
br label %69
69: ; preds = %68, %67
%70 = getelementptr inbounds [80 x i8], [80 x i8]* %15, i64 0, i64 0
%71 = load i32, i32* %16
%72 = load i8*, i8** %13
%73 = call i32 @md5_sum(i8* %70, i32 %71, i8* %72)
ret void
}

LLVM IR (-O2):
define void @hash(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4, i8* %5, i8 zeroext %6) {
%8 = alloca [80 x i8]
%9 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 0
%10 = call i32 @memcpy(i8* %9, i8* %0, i32 16)
%11 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 16
%12 = call i32 @memcpy(i8* %11, i8* %1, i32 4)
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 20
%14 = call i32 @memcpy(i8* %13, i8* %2, i32 %3)
%15 = add nsw i32 %3, 20
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 %16
%18 = call i32 @h2net(i32 %4, i8* %17, i32 4)
%19 = add nsw i32 %3, 24
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [80 x i8], [80 x i8]* %8, i64 0, i64 %20
%22 = call i32 @memcpy(i8* %21, i8* %0, i32 16)
%23 = add nsw i32 %3, 40
%24 = call i32 @md5_sum(i8* %9, i32 %23, i8* %5)
ret void
}