#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*/ free(char *);
unsigned int iDoRemoteFunc(unsigned char *, unsigned int, int);
char *malloc(int);
int /*<<< orphan*/ memcpy(unsigned char *, int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ psGetParaBuf(int);
unsigned int sprintf(char *, char *, int, unsigned char, unsigned int,
                     unsigned int);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
void _vRcAT1604_ReadAZ(unsigned char Area, unsigned int Addr, unsigned int Len,
                       unsigned char *DataBuf) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(100);
  uiDataLen = sprintf(psFunCall, "%u(%u,%u,%u,b000)", 9407, Area, Addr, Len);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 2);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_AT1604_ReadAZ iDoRemoteFunc ret = %d", uiRet);
    return;
  }
  memcpy(DataBuf, psGetParaBuf(5), Len);
}


x86 assembly (clang, -O0):
<_vRcAT1604_ReadAZ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1(%rbp),%al
mov    -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r9d
lea    0xe54(%rip),%rsi
mov    $0x24bf,%edx
movzbl %al,%ecx
call   1090 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x2,%edx
call   1080 <iDoRemoteFunc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x20(%rbp)
je     11f7 <_vRcAT1604_ReadAZ+0x87>
mov    -0x20(%rbp),%esi
lea    0xe25(%rip),%rdi
call   1050 <vWriteLogTxt@plt>
jmp    1217 <_vRcAT1604_ReadAZ+0xa7>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x5,%edi
call   1040 <psGetParaBuf@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
mov    -0xc(%rbp),%edx
call   1060 <memcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vRcAT1604_ReadAZ>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%r12d
mov    %edi,%ebp
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe69(%rip),%rsi
mov    %rax,%rdi
mov    $0x24bf,%edx
mov    %ebp,%ecx
mov    %r12d,%r8d
mov    %r15d,%r9d
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x2,%edx
call   1080 <iDoRemoteFunc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
je     11df <_vRcAT1604_ReadAZ+0x6f>
lea    0xe42(%rip),%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <vWriteLogTxt@plt>
mov    $0x5,%edi
call   1040 <psGetParaBuf@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %r15d,%edx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <memcpy@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"%u(%u,%u,%u,b000)\00"
@.str.1 = [38 x i8] c"_AT1604_ReadAZ iDoRemoteFunc ret = %d\00"
define void @_vRcAT1604_ReadAZ(i8 zeroext %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8 %0, i8* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%12 = call i8* @malloc(i32 100)
store i8* %12, i8** %11
%13 = load i8*, i8** %11
%14 = load i8, i8* %5
%15 = load i32, i32* %6
%16 = load i32, i32* %7
%17 = call i32 @sprintf(i8* %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 9407, i8 zeroext %14, i32 %15, i32 %16)
store i32 %17, i32* %9
%18 = load i8*, i8** %11
%19 = load i32, i32* %9
%20 = call i32 @iDoRemoteFunc(i8* %18, i32 %19, i32 2)
store i32 %20, i32* %10
%21 = load i8*, i8** %11
%22 = call i32 @free(i8* %21)
%23 = load i32, i32* %10
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %4
%26 = load i32, i32* %10
%27 = call i32 @vWriteLogTxt(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %33
28: ; preds = %4
%29 = load i8*, i8** %8
%30 = call i32 @psGetParaBuf(i32 5)
%31 = load i32, i32* %7
%32 = call i32 @memcpy(i8* %29, i32 %30, i32 %31)
br label %33
33: ; preds = %28, %25
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"%u(%u,%u,%u,b000)\00"
@.str.1 = [38 x i8] c"_AT1604_ReadAZ iDoRemoteFunc ret = %d\00"
define void @_vRcAT1604_ReadAZ(i8 zeroext %0, i32 %1, i32 %2, i8* %3) {
%5 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%6 = tail call i32 @sprintf(i8* dereferenceable(1) %5, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32 9407, i8 zeroext %0, i32 %1, i32 %2)
%7 = tail call i32 @iDoRemoteFunc(i8* %5, i32 %6, i32 2)
%8 = tail call i32 @free(i8* %5)
%9 = icmp eq i32 %7, 0
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = tail call i32 @vWriteLogTxt(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %7)
br label %15
12: ; preds = %4
%13 = tail call i32 @psGetParaBuf(i32 5)
%14 = tail call i32 @memcpy(i8* %3, i32 %13, i32 %2)
br label %15
15: ; preds = %12, %10
ret void
}