#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 */
typedef char uint8_t;
typedef int /*<<< orphan*/ msgbuf;

/* Variables and functions */
int /*<<< orphan*/ MD5Calc(char *, int, char *);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int strlen(char const *);
void FillMD5Area(uint8_t digest[], uint8_t id, const char passwd[],
                 const uint8_t srcMD5[]) {
  uint8_t msgbuf[128];
  int passlen = strlen(passwd);
  int msglen = 1 + passlen + 16;
  assert(sizeof(msgbuf) >= msglen);
  msgbuf[0] = id;
  memcpy(msgbuf + 1, passwd, passlen);
  memcpy(msgbuf + 1 + passlen, srcMD5, 16);
  MD5Calc(msgbuf, msglen, digest);
}


x86 assembly (clang, -O0):
<FillMD5Area>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xa4(%rbp)
mov    -0xa4(%rbp),%eax
add    $0x1,%eax
add    $0x10,%eax
mov    %eax,-0xa8(%rbp)
movslq -0xa8(%rbp),%rcx
mov    $0x80,%eax
cmp    %rcx,%rax
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x9(%rbp),%al
mov    %al,-0xa0(%rbp)
lea    -0xa0(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
mov    -0xa4(%rbp),%edx
call   1060 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
add    $0x1,%rdi
movslq -0xa4(%rbp),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1060 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
mov    -0xa8(%rbp),%esi
mov    -0x8(%rbp),%rdx
call   1030 <MD5Calc@plt>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FillMD5Area>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %rcx,%r15
mov    %rdx,%rbx
mov    %esi,%r12d
mov    %rdi,%r14
mov    %rdx,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0x11(%rbp),%r13d
xor    %edi,%edi
cmp    $0x81,%r13d
setb   %dil
call   1050 <assert@plt>
mov    %r12b,(%rsp)
lea    0x1(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1060 <memcpy@plt>
movslq %ebp,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1060 <memcpy@plt>
mov    %rsp,%rdi
mov    %r13d,%esi
mov    %r14,%rdx
call   1030 <MD5Calc@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @FillMD5Area(i8* %0, i8 signext %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [128 x i8]
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i8 %1, i8* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%12 = load i8*, i8** %7
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %10
%14 = load i32, i32* %10
%15 = add nsw i32 1, %14
%16 = add nsw i32 %15, 16
store i32 %16, i32* %11
%17 = load i32, i32* %11
%18 = sext i32 %17 to i64
%19 = icmp uge i64 128, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i8, i8* %6
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
store i8 %22, i8* %23
%24 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8*, i8** %7
%27 = load i32, i32* %10
%28 = call i32 @memcpy(i8* %25, i8* %26, i32 %27)
%29 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = load i32, i32* %10
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8*, i8** %8
%35 = call i32 @memcpy(i8* %33, i8* %34, i32 16)
%36 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%37 = load i32, i32* %11
%38 = load i8*, i8** %5
%39 = call i32 @MD5Calc(i8* %36, i32 %37, i8* %38)
ret void
}

LLVM IR (-O2):
define void @FillMD5Area(i8* %0, i8 signext %1, i8* %2, i8* %3) {
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%7 = tail call i32 @strlen(i8* %2)
%8 = add nsw i32 %7, 17
%9 = icmp ult i32 %8, 129
%10 = zext i1 %9 to i32
%11 = tail call i32 @assert(i32 %10)
store i8 %1, i8* %6
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 1
%13 = call i32 @memcpy(i8* %12, i8* %2, i32 %7)
%14 = sext i32 %7 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = call i32 @memcpy(i8* %15, i8* %3, i32 16)
%17 = call i32 @MD5Calc(i8* %6, i32 %8, i8* %0)
ret void
}