#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*/, int);
int /*<<< orphan*/ psGetParaBuf(int);
unsigned int sprintf(char *, char *, int, unsigned char, unsigned char);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
unsigned int _uiRcMifReadBlock(unsigned char ucSecNo, unsigned char ucBlock,
                               unsigned char *psData) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(100);
  uiDataLen = sprintf(psFunCall, "%u(%u,%u,b000)", 2006, ucSecNo, ucBlock);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_uiRcMifReadBlock iDoRemoteFunc ret = %d", uiRet);
    return 1;
  }
  uiRet = iGetParaInt(0);
  if (uiRet == 0)
    memcpy(psData, psGetParaBuf(4), 16);
  return uiRet;
}


x86 assembly (clang, -O0):
<_uiRcMifReadBlock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x5(%rbp)
mov    %al,-0x6(%rbp)
mov    %rdx,-0x10(%rbp)
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x5(%rbp),%al
lea    0xe4c(%rip),%rsi
mov    $0x7d6,%edx
movzbl %al,%ecx
movzbl -0x6(%rbp),%r8d
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     120b <_uiRcMifReadBlock+0x8b>
mov    -0x18(%rbp),%esi
lea    0xe15(%rip),%rdi
call   1060 <vWriteLogTxt@plt>
movl   $0x1,-0x4(%rbp)
jmp    1247 <_uiRcMifReadBlock+0xc7>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jne    1241 <_uiRcMifReadBlock+0xc1>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x4,%edi
call   1050 <psGetParaBuf@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    $0x10,%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):
<_uiRcMifReadBlock>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%r15d
mov    %edi,%ebx
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,%rbp
lea    0xe5d(%rip),%rsi
mov    %rax,%rdi
mov    $0x7d6,%edx
mov    %ebx,%ecx
mov    %r15d,%r8d
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     11e8 <_uiRcMifReadBlock+0x68>
lea    0xe30(%rip),%rdi
mov    %ebx,%esi
call   1060 <vWriteLogTxt@plt>
jmp    1212 <_uiRcMifReadBlock+0x92>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,%r15d
test   %eax,%eax
jne    1212 <_uiRcMifReadBlock+0x92>
mov    $0x4,%edi
call   1050 <psGetParaBuf@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    $0x10,%edx
call   1070 <memcpy@plt>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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