#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 int /*<<< orphan*/ uint64_t;
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ SendAll(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ TryCreateFile(char *, char *, int /*<<< orphan*/, char **,
                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *, char *, int /*<<< orphan*/);
char *read64Int(char *, int /*<<< orphan*/ *);
char *readString(char *, char **);
void DoCreate(int fd, char *data) {
  char *fileName = NULL;
  data = readString(data, &fileName);
  char *md5 = NULL;
  data = readString(data, &md5);
  uint64_t size = 0;
  data = read64Int(data, &size);
  char *buf = NULL;
  uint32_t sendLen = 0;
  printf("job.c DoCreate!!!, fileName: %s, md5: %s, size: %lu\n", fileName, md5,
         size);
  TryCreateFile(fileName, md5, size, &buf, &sendLen);
  SendAll(fd, buf, sendLen);
  free(buf);
  free(fileName);
  free(md5);
}


x86 assembly (clang, -O0):
<DoCreate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <readString@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <readString@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <read64Int@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    0xe26(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
call   1070 <TryCreateFile@plt>
mov    -0x4(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1080 <SendAll@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<DoCreate>:
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rax
mov    %edi,%ebx
movq   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %rax,%rdi
call   1060 <readString@plt>
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1060 <readString@plt>
movl   $0x0,(%rsp)
mov    %rsp,%rsi
mov    %rax,%rdi
call   1050 <read64Int@plt>
movq   $0x0,0x18(%rsp)
movl   $0x0,0x4(%rsp)
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
mov    (%rsp),%ecx
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
mov    0x10(%rsp),%rdi
mov    0x8(%rsp),%rsi
mov    (%rsp),%edx
lea    0x18(%rsp),%rcx
lea    0x4(%rsp),%r8
call   1070 <TryCreateFile@plt>
mov    0x18(%rsp),%rsi
mov    0x4(%rsp),%edx
mov    %ebx,%edi
call   1080 <SendAll@plt>
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [53 x i8] c"job.c DoCreate!!!, fileName: %s, md5: %s, size: %lu\0A\00"
define void @DoCreate(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i8* null, i8** %5
%10 = load i8*, i8** %4
%11 = call i8* @readString(i8* %10, i8** %5)
store i8* %11, i8** %4
store i8* null, i8** %6
%12 = load i8*, i8** %4
%13 = call i8* @readString(i8* %12, i8** %6)
store i8* %13, i8** %4
store i32 0, i32* %7
%14 = load i8*, i8** %4
%15 = call i8* @read64Int(i8* %14, i32* %7)
store i8* %15, i8** %4
store i8* null, i8** %8
store i32 0, i32* %9
%16 = load i8*, i8** %5
%17 = load i8*, i8** %6
%18 = load i32, i32* %7
%19 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i32 %18)
%20 = load i8*, i8** %5
%21 = load i8*, i8** %6
%22 = load i32, i32* %7
%23 = call i32 @TryCreateFile(i8* %20, i8* %21, i32 %22, i8** %8, i32* %9)
%24 = load i32, i32* %3
%25 = load i8*, i8** %8
%26 = load i32, i32* %9
%27 = call i32 @SendAll(i32 %24, i8* %25, i32 %26)
%28 = load i8*, i8** %8
%29 = call i32 @free(i8* %28)
%30 = load i8*, i8** %5
%31 = call i32 @free(i8* %30)
%32 = load i8*, i8** %6
%33 = call i32 @free(i8* %32)
ret void
}

LLVM IR (-O2):
@.str = [53 x i8] c"job.c DoCreate!!!, fileName: %s, md5: %s, size: %lu\0A\00"
define void @DoCreate(i32 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%9 = call i8* @readString(i8* %1, i8** %3)
%10 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%11 = call i8* @readString(i8* %9, i8** %4)
%12 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%13 = call i8* @read64Int(i8* %11, i32* %5)
%14 = bitcast i8** %6 to i8*
store i8* null, i8** %6
%15 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%16 = load i8*, i8** %3
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i32 %18)
%20 = load i8*, i8** %3
%21 = load i8*, i8** %4
%22 = load i32, i32* %5
%23 = call i32 @TryCreateFile(i8* %20, i8* %21, i32 %22, i8** %6, i32* %7)
%24 = load i8*, i8** %6
%25 = load i32, i32* %7
%26 = call i32 @SendAll(i32 %0, i8* %24, i32 %25)
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
%29 = load i8*, i8** %3
%30 = call i32 @free(i8* %29)
%31 = load i8*, i8** %4
%32 = call i32 @free(i8* %31)
ret void
}