#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 scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ CalcMd5(char *, char **, scalar_t__ *);
int /*<<< orphan*/ SendAll(int, char *, scalar_t__);
int /*<<< orphan*/ bzero(char *, scalar_t__);
int /*<<< orphan*/ free(char *);
char *malloc(scalar_t__);
char *readBytes(char *, char *, scalar_t__);
char *readInt(char *, scalar_t__ *);
void DoMd5(int fd, char *data) {
  uint32_t fileNameLen = 0;
  data = readInt(data, &fileNameLen);
  char *name = malloc(fileNameLen + 1);
  bzero(name, fileNameLen + 1);
  data = readBytes(data, name, fileNameLen);
  char *buf = NULL;
  uint32_t sendLen = 0;
  CalcMd5(name, &buf, &sendLen);
  SendAll(fd, buf, sendLen);
  free(buf);
  free(name);
}


x86 assembly (clang, -O0):
<DoMd5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <readInt@plt>
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
call   1080 <bzero@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1060 <readBytes@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1070 <CalcMd5@plt>
mov    -0x4(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1090 <SendAll@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoMd5>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rax
mov    %edi,%r14d
movq   $0x0,0x18(%rsp)
lea    0x18(%rsp),%rsi
mov    %rax,%rdi
call   1040 <readInt@plt>
mov    %rax,%r15
mov    0x18(%rsp),%r12
lea    0x1(%r12),%rbp
mov    %rbp,%rdi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %rbp,%rsi
call   1080 <bzero@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
call   1060 <readBytes@plt>
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <CalcMd5@plt>
mov    0x8(%rsp),%rsi
mov    0x10(%rsp),%rdx
mov    %r14d,%edi
call   1090 <SendAll@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @DoMd5(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
store i32 %0, i32* %3
store i8* %1, i8** %4
store i64 0, i64* %5
%9 = load i8*, i8** %4
%10 = call i8* @readInt(i8* %9, i64* %5)
store i8* %10, i8** %4
%11 = load i64, i64* %5
%12 = add nsw i64 %11, 1
%13 = call i8* @malloc(i64 %12)
store i8* %13, i8** %6
%14 = load i8*, i8** %6
%15 = load i64, i64* %5
%16 = add nsw i64 %15, 1
%17 = call i32 @bzero(i8* %14, i64 %16)
%18 = load i8*, i8** %4
%19 = load i8*, i8** %6
%20 = load i64, i64* %5
%21 = call i8* @readBytes(i8* %18, i8* %19, i64 %20)
store i8* %21, i8** %4
store i8* null, i8** %7
store i64 0, i64* %8
%22 = load i8*, i8** %6
%23 = call i32 @CalcMd5(i8* %22, i8** %7, i64* %8)
%24 = load i32, i32* %3
%25 = load i8*, i8** %7
%26 = load i64, i64* %8
%27 = call i32 @SendAll(i32 %24, i8* %25, i64 %26)
%28 = load i8*, i8** %7
%29 = call i32 @free(i8* %28)
%30 = load i8*, i8** %6
%31 = call i32 @free(i8* %30)
ret void
}

LLVM IR (-O2):
define void @DoMd5(i32 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca i64
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = call i8* @readInt(i8* %1, i64* %3)
%8 = load i64, i64* %3
%9 = add nsw i64 %8, 1
%10 = call i8* @malloc(i64 %9)
%11 = call i32 @bzero(i8* %10, i64 %9)
%12 = call i8* @readBytes(i8* %7, i8* %10, i64 %8)
%13 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%14 = bitcast i64* %5 to i8*
store i64 0, i64* %5
%15 = call i32 @CalcMd5(i8* %10, i8** %4, i64* %5)
%16 = load i8*, i8** %4
%17 = load i64, i64* %5
%18 = call i32 @SendAll(i32 %0, i8* %16, i64 %17)
%19 = load i8*, i8** %4
%20 = call i32 @free(i8* %19)
%21 = call i32 @free(i8* %10)
ret void
}