#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*/, int);
int /*<<< orphan*/ psGetParaBuf(int);
unsigned int sprintf(char *, char *, int, unsigned char);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
void _vRcAT102_ReadAZ(unsigned char ucArea, unsigned char *psAZ) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(50);
  uiDataLen = sprintf(psFunCall, "%u(%u,b000)", 9119, ucArea);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_AT102_ReadAZ iDoRemoteFunc ret = %d", uiRet);
    return;
  }
  memcpy(psAZ, psGetParaBuf(3), 64);
}


x86 assembly (clang, -O0):
<_vRcAT102_ReadAZ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x32,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe65(%rip),%rsi
mov    $0x239f,%edx
movzbl -0x1(%rbp),%ecx
call   1090 <sprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x1,%edx
call   1080 <iDoRemoteFunc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x18(%rbp)
je     11e7 <_vRcAT102_ReadAZ+0x77>
mov    -0x18(%rbp),%esi
lea    0xe2f(%rip),%rdi
call   1050 <vWriteLogTxt@plt>
jmp    1209 <_vRcAT102_ReadAZ+0x99>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x3,%edi
call   1040 <psGetParaBuf@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    $0x40,%edx
call   1060 <memcpy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vRcAT102_ReadAZ>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %edi,%ebp
mov    $0x32,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe73(%rip),%rsi
mov    %rax,%rdi
mov    $0x239f,%edx
mov    %ebp,%ecx
call   1090 <sprintf@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1080 <iDoRemoteFunc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
je     11cb <_vRcAT102_ReadAZ+0x5b>
lea    0xe4c(%rip),%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <vWriteLogTxt@plt>
mov    $0x3,%edi
call   1040 <psGetParaBuf@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x40,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <memcpy@plt>

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

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