#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);
unsigned char iGetParaInt(int /*<<< orphan*/);
char *malloc(int);
unsigned int sprintf(char *, char *, int, unsigned char, unsigned char);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
unsigned char _ucRcAT102_EraseNonApp(unsigned char ucWordAddr,
                                     unsigned char ucWordNum) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(512);
  uiDataLen = sprintf(psFunCall, "%u(%u,%u)", 9107, ucWordAddr, ucWordNum);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_AT102_EraseNonApp iDoRemoteFunc ret = %d", uiRet);
    return 1;
  }
  return iGetParaInt(0);
}


x86 assembly (clang, -O0):
<_ucRcAT102_EraseNonApp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    $0x200,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x2(%rbp),%al
lea    0xe70(%rip),%rsi
mov    $0x2393,%edx
movzbl %al,%ecx
movzbl -0x3(%rbp),%r8d
call   1080 <sprintf@plt>
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1070 <iDoRemoteFunc@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0xc(%rbp)
je     11e4 <_ucRcAT102_EraseNonApp+0x84>
mov    -0xc(%rbp),%esi
lea    0xe34(%rip),%rdi
call   1050 <vWriteLogTxt@plt>
movb   $0x1,-0x1(%rbp)
jmp    11ee <_ucRcAT102_EraseNonApp+0x8e>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ucRcAT102_EraseNonApp>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebx
mov    $0x200,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
lea    0xe83(%rip),%rsi
mov    %rax,%rdi
mov    $0x2393,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1080 <sprintf@plt>
mov    %rbp,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1070 <iDoRemoteFunc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <free@plt>
test   %ebx,%ebx
je     11c1 <_ucRcAT102_EraseNonApp+0x61>
lea    0xe57(%rip),%rdi
mov    %ebx,%esi
call   1050 <vWriteLogTxt@plt>
mov    $0x1,%al
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %edi,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <iGetParaInt@plt>

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

LLVM IR (-O2):
@.str = [10 x i8] c"%u(%u,%u)\00"
@.str.1 = [42 x i8] c"_AT102_EraseNonApp iDoRemoteFunc ret = %d\00"
define zeroext i8 @_ucRcAT102_EraseNonApp(i8 zeroext %0, i8 zeroext %1) {
%3 = tail call dereferenceable_or_null(512) i8* @malloc(i32 512)
%4 = tail call i32 @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 9107, i8 zeroext %0, i8 zeroext %1)
%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 ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %5)
br label %12
10: ; preds = %2
%11 = tail call zeroext i8 @iGetParaInt(i32 0)
br label %12
12: ; preds = %10, %8
%13 = phi i8 [ 1, %8 ], [ %11, %10 ]
ret i8 %13
}