#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);
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 _uiRcSDSCResetCard(unsigned char *psAtr, unsigned int *puiAtrLen) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(100);
  uiDataLen = sprintf(psFunCall, "%u(b000, 0)", 5024);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 5);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_uiRcSDSCResetCard iDoRemoteFunc ret = %d", uiRet);
    return 99;
  }
  if (iGetParaInt(0) == 0) {
    memcpy(psAtr, psGetParaBuf(2), iGetParaInt(3));
    *puiAtrLen = iGetParaInt(3);
  }
  return iGetParaInt(0);
}


x86 assembly (clang, -O0):
<_uiRcSDSCResetCard>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xe57(%rip),%rsi
mov    $0x13a0,%edx
call   10a0 <sprintf@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0x5,%edx
call   1090 <iDoRemoteFunc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x20(%rbp)
je     11f8 <_uiRcSDSCResetCard+0x78>
mov    -0x20(%rbp),%esi
lea    0xe25(%rip),%rdi
call   1060 <vWriteLogTxt@plt>
movl   $0x63,-0x4(%rbp)
jmp    1251 <_uiRcSDSCResetCard+0xd1>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
cmp    $0x0,%eax
jne    1247 <_uiRcSDSCResetCard+0xc7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x2,%edi
call   1050 <psGetParaBuf@plt>
mov    %eax,-0x2c(%rbp)
mov    $0x3,%edi
call   1040 <iGetParaInt@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    $0x3,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_uiRcSDSCResetCard>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xe5f(%rip),%rsi
mov    %rax,%rdi
mov    $0x13a0,%edx
call   10a0 <sprintf@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x5,%edx
call   1090 <iDoRemoteFunc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
je     11e9 <_uiRcSDSCResetCard+0x69>
lea    0xe3a(%rip),%rdi
mov    %ebp,%esi
call   1060 <vWriteLogTxt@plt>
mov    $0x63,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
test   %eax,%eax
jne    1223 <_uiRcSDSCResetCard+0xa3>
mov    $0x2,%edi
call   1050 <psGetParaBuf@plt>
mov    %eax,%ebx
mov    $0x3,%edi
call   1040 <iGetParaInt@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    $0x3,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,(%r14)
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <iGetParaInt@plt>

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

LLVM IR (-O2):
@.str = [12 x i8] c"%u(b000, 0)\00"
@.str.1 = [42 x i8] c"_uiRcSDSCResetCard iDoRemoteFunc ret = %d\00"
define i32 @_uiRcSDSCResetCard(i8* %0, i32* nocapture writeonly %1) {
%3 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%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 5024)
%5 = tail call i32 @iDoRemoteFunc(i8* %3, i32 %4, i32 5)
%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 %20
10: ; preds = %2
%11 = tail call i32 @iGetParaInt(i32 0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = tail call i32 @psGetParaBuf(i32 2)
%15 = tail call i32 @iGetParaInt(i32 3)
%16 = tail call i32 @memcpy(i8* %0, i32 %14, i32 %15)
%17 = tail call i32 @iGetParaInt(i32 3)
store i32 %17, i32* %1
br label %18
18: ; preds = %13, %10
%19 = tail call i32 @iGetParaInt(i32 0)
br label %20
20: ; preds = %18, %8
%21 = phi i32 [ 99, %8 ], [ %19, %18 ]
ret i32 %21
}