#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);
int /*<<< orphan*/ memcpy(unsigned char *, int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ psGetParaBuf(int);
unsigned int sprintf(char *, char *, int);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
unsigned int _uiRcMifCard(unsigned char *psSerialNo) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(20);
  uiDataLen = sprintf(psFunCall, "%u(b000)", 2001);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_uiRcMifCard iDoRemoteFunc ret = %d", uiRet);
    return 0;
  }
  uiRet = iGetParaInt(0);
  if (uiRet > 0)
    memcpy(psSerialNo, psGetParaBuf(2), uiRet);
  return uiRet;
}


x86 assembly (clang, -O0):
<_uiRcMifCard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x14,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe5b(%rip),%rsi
mov    $0x7d1,%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     11f4 <_uiRcMifCard+0x74>
mov    -0x18(%rbp),%esi
lea    0xe26(%rip),%rdi
call   1060 <vWriteLogTxt@plt>
movl   $0x0,-0x4(%rbp)
jmp    122e <_uiRcMifCard+0xae>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jbe    1228 <_uiRcMifCard+0xa8>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x2,%edi
call   1050 <psGetParaBuf@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0x18(%rbp),%edx
call   1070 <memcpy@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_uiRcMifCard>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x14,%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
lea    0xe65(%rip),%rsi
mov    %rax,%rdi
mov    $0x7d1,%edx
call   10a0 <sprintf@plt>
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     11d7 <_uiRcMifCard+0x57>
lea    0xe3d(%rip),%rdi
mov    %ebx,%esi
call   1060 <vWriteLogTxt@plt>
xor    %ebp,%ebp
jmp    11fe <_uiRcMifCard+0x7e>
xor    %ebp,%ebp
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
test   %eax,%eax
je     11fe <_uiRcMifCard+0x7e>
mov    %eax,%ebx
mov    $0x2,%edi
call   1050 <psGetParaBuf@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebx,%edx
call   1070 <memcpy@plt>
mov    %ebx,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [9 x i8] c"%u(b000)\00"
@.str.1 = [36 x i8] c"_uiRcMifCard iDoRemoteFunc ret = %d\00"
define i32 @_uiRcMifCard(i8* %0) {
%2 = tail call dereferenceable_or_null(20) i8* @malloc(i32 20)
%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 2001)
%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 ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %4)
br label %15
9: ; preds = %1
%10 = tail call i32 @iGetParaInt(i32 0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = tail call i32 @psGetParaBuf(i32 2)
%14 = tail call i32 @memcpy(i8* %0, i32 %13, i32 %10)
br label %15
15: ; preds = %9, %12, %7
%16 = phi i32 [ 0, %7 ], [ %10, %12 ], [ 0, %9 ]
ret i32 %16
}