#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 int iGetParaInt(int /*<<< orphan*/);
char *malloc(int);
scalar_t__ psGetParaBuf(int);
unsigned int sprintf(char *, char *, int, unsigned int);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
unsigned int _uiRcMagGet(unsigned int uiTrackNo, unsigned char *pszBuffer) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(200);
  uiDataLen = sprintf(psFunCall, "%u(%u,s000)", 1011, uiTrackNo);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_uiRcMagGet iDoRemoteFunc ret = %d", uiRet);
    return 1;
  }
  uiRet = iGetParaInt(0);
  if (uiRet == 0) {
    strcpy((char *)pszBuffer, (char *)psGetParaBuf(3));
  }
  return uiRet;
}


x86 assembly (clang, -O0):
<_uiRcMagGet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xc8,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%ecx
lea    0xe55(%rip),%rsi
mov    $0x3f3,%edx
call   10a0 <sprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x1,%edx
call   1090 <iDoRemoteFunc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x18(%rbp)
je     11fa <_uiRcMagGet+0x7a>
mov    -0x18(%rbp),%esi
lea    0xe23(%rip),%rdi
call   1070 <vWriteLogTxt@plt>
movl   $0x1,-0x4(%rbp)
jmp    1232 <_uiRcMagGet+0xb2>
xor    %edi,%edi
call   1050 <iGetParaInt@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    122c <_uiRcMagGet+0xac>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x3,%edi
call   1060 <psGetParaBuf@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_uiRcMagGet>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
mov    $0xc8,%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
lea    0xe60(%rip),%rsi
mov    %rax,%rdi
mov    $0x3f3,%edx
mov    %ebx,%ecx
call   10a0 <sprintf@plt>
mov    $0x1,%r15d
mov    %rbp,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1090 <iDoRemoteFunc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <free@plt>
test   %ebx,%ebx
je     11e2 <_uiRcMagGet+0x62>
lea    0xe33(%rip),%rdi
mov    %ebx,%esi
call   1070 <vWriteLogTxt@plt>
jmp    1208 <_uiRcMagGet+0x88>
xor    %edi,%edi
call   1050 <iGetParaInt@plt>
mov    %eax,%r15d
test   %eax,%eax
jne    1208 <_uiRcMagGet+0x88>
mov    $0x3,%edi
call   1060 <psGetParaBuf@plt>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [12 x i8] c"%u(%u,s000)\00"
@.str.1 = [35 x i8] c"_uiRcMagGet iDoRemoteFunc ret = %d\00"
define i32 @_uiRcMagGet(i32 %0, i8* %1) {
%3 = tail call dereferenceable_or_null(200) i8* @malloc(i32 200)
%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 1011, i32 %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 ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %5)
br label %17
10: ; preds = %2
%11 = tail call i32 @iGetParaInt(i32 0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = tail call i64 @psGetParaBuf(i32 3)
%15 = inttoptr i64 %14 to i8*
%16 = tail call i32 @strcpy(i8* %1, i8* %15)
br label %17
17: ; preds = %10, %13, %8
%18 = phi i32 [ 1, %8 ], [ 0, %13 ], [ %11, %10 ]
ret i32 %18
}