#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*/ MD5(char *, size_t, char *);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
size_t strlen(char const *);
void FillMD5Area(uint8_t digest[], uint8_t id, const char passwd[],
                 const uint8_t srcMD5[]) {
  uint8_t msgbuf[128];
  size_t msglen;
  size_t passlen;
  passlen = strlen(passwd);
  msglen = 1 + passlen + 16;
  assert(sizeof(msgbuf) >= msglen);
  msgbuf[0] = id;
  memcpy(msgbuf + 1, passwd, passlen);
  memcpy(msgbuf + 1 + passlen, srcMD5, 16);
  (void)MD5(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   1030 <strlen@plt>
mov    %rax,-0xb0(%rbp)
mov    -0xb0(%rbp),%rax
add    $0x1,%rax
add    $0x10,%rax
mov    %rax,-0xa8(%rbp)
mov    $0x80,%eax
cmp    -0xa8(%rbp),%rax
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x9(%rbp),%al
mov    %al,-0xa0(%rbp)
lea    -0xa0(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rsi
mov    -0xb0(%rbp),%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
add    $0x1,%rdi
add    -0xb0(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
lea    -0xa0(%rbp),%rdi
mov    -0xa8(%rbp),%rsi
mov    -0x8(%rbp),%rdx
call   1060 <MD5@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   1030 <strlen@plt>
mov    %rax,%rbp
lea    0x11(%rax),%r13
xor    %edi,%edi
cmp    $0x81,%r13
setb   %dil
call   1040 <assert@plt>
mov    %r12b,(%rsp)
lea    0x1(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1050 <memcpy@plt>
lea    (%rsp,%rbp,1),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
mov    $0x10,%edx
call   1050 <memcpy@plt>
mov    %rsp,%rdi
mov    %r13,%rsi
mov    %r14,%rdx
call   1060 <MD5@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 i64
%11 = alloca i64
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 i64 @strlen(i8* %12)
store i64 %13, i64* %11
%14 = load i64, i64* %11
%15 = add i64 1, %14
%16 = add i64 %15, 16
store i64 %16, i64* %10
%17 = load i64, i64* %10
%18 = icmp uge i64 128, %17
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i8, i8* %6
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
store i8 %21, i8* %22
%23 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%24 = getelementptr inbounds i8, i8* %23, i64 1
%25 = load i8*, i8** %7
%26 = load i64, i64* %11
%27 = trunc i64 %26 to i32
%28 = call i32 @memcpy(i8* %24, i8* %25, 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 i64, i64* %11
%32 = getelementptr inbounds i8, i8* %30, i64 %31
%33 = load i8*, i8** %8
%34 = call i32 @memcpy(i8* %32, i8* %33, i32 16)
%35 = getelementptr inbounds [128 x i8], [128 x i8]* %9, i64 0, i64 0
%36 = load i64, i64* %10
%37 = load i8*, i8** %5
%38 = call i32 @MD5(i8* %35, i64 %36, i8* %37)
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 i64 @strlen(i8* dereferenceable(1) %2)
%8 = add i64 %7, 17
%9 = icmp ult i64 %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 = trunc i64 %7 to i32
%14 = call i32 @memcpy(i8* %12, i8* %2, i32 %13)
%15 = getelementptr inbounds i8, i8* %12, i64 %7
%16 = call i32 @memcpy(i8* %15, i8* %3, i32 16)
%17 = call i32 @MD5(i8* %6, i64 %8, i8* %0)
ret void
}