#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 *, scalar_t__, int);
scalar_t__ psGetParaBuf(int);
unsigned int sprintf(char *, char *, int);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
void _vRcAT1608_OpenCard(unsigned char *RstData) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(50);
  uiDataLen = sprintf(psFunCall, "%u(b000)", 9501);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_AT1608_OpenCard iDoRemoteFunc ret = %d", uiRet);
    return;
  }
  memcpy(RstData, psGetParaBuf(2) + 1, 4);
}


x86 assembly (clang, -O0):
<_vRcAT1608_OpenCard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x32,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe6b(%rip),%rsi
mov    $0x251d,%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 <_vRcAT1608_OpenCard+0x6d>
mov    -0x10(%rbp),%esi
lea    0xe36(%rip),%rdi
call   1050 <vWriteLogTxt@plt>
jmp    1204 <_vRcAT1608_OpenCard+0x94>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    $0x2,%edi
call   1040 <psGetParaBuf@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
mov    $0x4,%edx
call   1060 <memcpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vRcAT1608_OpenCard>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x32,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
lea    0xe75(%rip),%rsi
mov    %rax,%rdi
mov    $0x251d,%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 <_vRcAT1608_OpenCard+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>
lea    0x1(%rax),%rsi
mov    %r14,%rdi
mov    $0x4,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <memcpy@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%u(b000)\00"
@.str.1 = [40 x i8] c"_AT1608_OpenCard iDoRemoteFunc ret = %d\00"
define void @_vRcAT1608_OpenCard(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
%6 = call i8* @malloc(i32 50)
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 9501)
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 ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %17)
br label %24
19: ; preds = %1
%20 = load i8*, i8** %2
%21 = call i64 @psGetParaBuf(i32 2)
%22 = add nsw i64 %21, 1
%23 = call i32 @memcpy(i8* %20, i64 %22, i32 4)
br label %24
24: ; preds = %19, %16
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%u(b000)\00"
@.str.1 = [40 x i8] c"_AT1608_OpenCard iDoRemoteFunc ret = %d\00"
define void @_vRcAT1608_OpenCard(i8* %0) {
%2 = tail call dereferenceable_or_null(50) i8* @malloc(i32 50)
%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 9501)
%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 ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %4)
br label %13
9: ; preds = %1
%10 = tail call i64 @psGetParaBuf(i32 2)
%11 = add nsw i64 %10, 1
%12 = tail call i32 @memcpy(i8* %0, i64 %11, i32 4)
br label %13
13: ; preds = %9, %7
ret void
}