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


x86 assembly (clang, -O0):
<_vRcAT1604_ReadMTZ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6b(%rip),%rsi
mov    $0x24cd,%edx
call   1090 <sprintf@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
call   1080 <iDoRemoteFunc@plt>
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x10(%rbp)
je     11dd <_vRcAT1604_ReadMTZ+0x6d>
mov    -0x10(%rbp),%esi
lea    0xe36(%rip),%rdi
call   1050 <vWriteLogTxt@plt>
jmp    11ff <_vRcAT1604_ReadMTZ+0x8f>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x2,%edi
call   1040 <psGetParaBuf@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
mov    $0x2,%edx
call   1060 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vRcAT1604_ReadMTZ>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x64,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe75(%rip),%rsi
mov    %rax,%rdi
mov    $0x24cd,%edx
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     11c7 <_vRcAT1604_ReadMTZ+0x57>
lea    0xe4d(%rip),%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <vWriteLogTxt@plt>
mov    $0x2,%edi
call   1040 <psGetParaBuf@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x2,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <memcpy@plt>

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

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