#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);
int /*<<< orphan*/ memcpy(char *, void *, unsigned int);
unsigned int sprintf(char *, char *, unsigned int, ...);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
unsigned char _ucRcAsyncSendBuf(void *pBuf, unsigned int uiLen) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(1024);
  uiDataLen = sprintf(psFunCall, "%u(b%03u", 1022, uiLen);
  memcpy(psFunCall + uiDataLen, pBuf, uiLen);
  uiDataLen += uiLen;
  uiDataLen += sprintf(psFunCall + uiDataLen, ",%u)", uiLen);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_ucRcAsyncSendBuf iDoRemoteFunc ret = %d", uiRet);
    return 1;
  }
  return iGetParaInt(0);
}


x86 assembly (clang, -O0):
<_ucRcAsyncSendBuf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%ecx
lea    0xe65(%rip),%rsi
mov    $0x3fe,%edx
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%eax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1060 <memcpy@plt>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%eax
add    %rax,%rdi
mov    -0x14(%rbp),%edx
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   1080 <iDoRemoteFunc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x1c(%rbp)
je     1229 <_ucRcAsyncSendBuf+0xb9>
mov    -0x1c(%rbp),%esi
lea    0xdf3(%rip),%rdi
call   1050 <vWriteLogTxt@plt>
movb   $0x1,-0x1(%rbp)
jmp    1233 <_ucRcAsyncSendBuf+0xc3>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ucRcAsyncSendBuf>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%r14
mov    $0x400,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe6f(%rip),%rsi
mov    %rax,%rdi
mov    $0x3fe,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %eax,%ebp
mov    %eax,%edi
add    %rbx,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1060 <memcpy@plt>
add    %r15d,%ebp
lea    (%rbx,%rbp,1),%rdi
lea    0xe46(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1090 <sprintf@plt>
add    %eax,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1080 <iDoRemoteFunc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
je     1207 <_ucRcAsyncSendBuf+0x97>
lea    0xe1b(%rip),%rdi
mov    %ebp,%esi
call   1050 <vWriteLogTxt@plt>
mov    $0x1,%al
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <iGetParaInt@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%u(b%03u\00"
@.str.1 = [5 x i8] c",%u)\00"
@.str.2 = [41 x i8] c"_ucRcAsyncSendBuf iDoRemoteFunc ret = %d\00"
define zeroext i8 @_ucRcAsyncSendBuf(i8* %0, i32 %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
%9 = call i8* @malloc(i32 1024)
store i8* %9, i8** %8
%10 = load i8*, i8** %8
%11 = load i32, i32* %5
%12 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1022, i32 %11)
store i32 %12, i32* %6
%13 = load i8*, i8** %8
%14 = load i32, i32* %6
%15 = zext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8*, i8** %4
%18 = load i32, i32* %5
%19 = call i32 @memcpy(i8* %16, i8* %17, i32 %18)
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = add i32 %21, %20
store i32 %22, i32* %6
%23 = load i8*, i8** %8
%24 = load i32, i32* %6
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i32, i32* %5
%28 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %6
%30 = add i32 %29, %28
store i32 %30, i32* %6
%31 = load i8*, i8** %8
%32 = load i32, i32* %6
%33 = call i32 @iDoRemoteFunc(i8* %31, i32 %32, i32 1)
store i32 %33, i32* %7
%34 = load i8*, i8** %8
%35 = call i32 @free(i8* %34)
%36 = load i32, i32* %7
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %2
%39 = load i32, i32* %7
%40 = call i32 @vWriteLogTxt(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %39)
store i8 1, i8* %3
br label %43
41: ; preds = %2
%42 = call zeroext i8 @iGetParaInt(i32 0)
store i8 %42, i8* %3
br label %43
43: ; preds = %41, %38
%44 = load i8, i8* %3
ret i8 %44
}

LLVM IR (-O2):
@.str = [9 x i8] c"%u(b%03u\00"
@.str.1 = [5 x i8] c",%u)\00"
@.str.2 = [41 x i8] c"_ucRcAsyncSendBuf iDoRemoteFunc ret = %d\00"
define zeroext i8 @_ucRcAsyncSendBuf(i8* %0, i32 %1) {
%3 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%4 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1022, i32 %1)
%5 = zext i32 %4 to i64
%6 = getelementptr inbounds i8, i8* %3, i64 %5
%7 = tail call i32 @memcpy(i8* %6, i8* %0, i32 %1)
%8 = add i32 %4, %1
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %3, i64 %9
%11 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) %10, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%12 = add i32 %11, %8
%13 = tail call i32 @iDoRemoteFunc(i8* %3, i32 %12, i32 1)
%14 = tail call i32 @free(i8* %3)
%15 = icmp eq i32 %13, 0
br i1 %15, label %18, label %16
16: ; preds = %2
%17 = tail call i32 @vWriteLogTxt(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %20
18: ; preds = %2
%19 = tail call zeroext i8 @iGetParaInt(i32 0)
br label %20
20: ; preds = %18, %16
%21 = phi i8 [ 1, %16 ], [ %19, %18 ]
ret i8 %21
}