#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);
int iGetParaInt(int /*<<< orphan*/);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *psGetParaBuf(int);
unsigned int sprintf(char *, char *, ...);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
int iRcTSFID_RUDLL_GetDeviceInfo(char fpflag[3], char firmver[10],
                                 char deviceinfo[10]) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(100);
  uiDataLen = sprintf(psFunCall, "%u(b003", 4111);
  memcpy(psFunCall + uiDataLen, fpflag, 3);
  uiDataLen += 3;
  uiDataLen += sprintf(psFunCall + uiDataLen, ",b000,b000)");
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("iRcTSFID_RUDLL_GetDeviceInfo iDoRemoteFunc ret = %d", uiRet);
    return 99;
  }
  if (iGetParaInt(0) == 0) {
    memcpy(firmver, psGetParaBuf(3), 10);
    memcpy(deviceinfo, psGetParaBuf(4), 10);
  }
  return iGetParaInt(0);
}


x86 assembly (clang, -O0):
<iRcTSFID_RUDLL_GetDeviceInfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe53(%rip),%rsi
mov    $0x100f,%edx
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    $0x3,%edx
call   1070 <memcpy@plt>
mov    -0x24(%rbp),%eax
add    $0x3,%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%eax
add    %rax,%rdi
lea    0xe1a(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    $0x1,%edx
call   1090 <iDoRemoteFunc@plt>
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x28(%rbp)
je     123d <iRcTSFID_RUDLL_GetDeviceInfo+0xbd>
mov    -0x28(%rbp),%esi
lea    0xde8(%rip),%rdi
call   1060 <vWriteLogTxt@plt>
movl   $0x63,-0x4(%rbp)
jmp    129d <iRcTSFID_RUDLL_GetDeviceInfo+0x11d>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
cmp    $0x0,%eax
jne    1293 <iRcTSFID_RUDLL_GetDeviceInfo+0x113>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    $0x3,%edi
call   1050 <psGetParaBuf@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rsi
mov    $0xa,%edx
call   1070 <memcpy@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x4,%edi
call   1050 <psGetParaBuf@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
mov    $0xa,%edx
call   1070 <memcpy@plt>
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):
<iRcTSFID_RUDLL_GetDeviceInfo>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xe5b(%rip),%rsi
mov    %rax,%rdi
mov    $0x100f,%edx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %eax,%ebp
mov    %eax,%edi
add    %rbx,%rdi
mov    %r12,%rsi
mov    $0x3,%edx
call   1070 <memcpy@plt>
lea    0x3(%rbp),%eax
movabs $0x30622c303030622c,%rcx
2c 62 30
mov    %rcx,(%rbx,%rax,1)
movl   $0x293030,0x8(%rbx,%rax,1)
add    $0xe,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1090 <iDoRemoteFunc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
je     121d <iRcTSFID_RUDLL_GetDeviceInfo+0x9d>
lea    0xe0c(%rip),%rdi
mov    %ebp,%esi
call   1060 <vWriteLogTxt@plt>
mov    $0x63,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
test   %eax,%eax
jne    125c <iRcTSFID_RUDLL_GetDeviceInfo+0xdc>
mov    $0x3,%edi
call   1050 <psGetParaBuf@plt>
mov    %r15,%rdi
mov    %rax,%rsi
mov    $0xa,%edx
call   1070 <memcpy@plt>
mov    $0x4,%edi
call   1050 <psGetParaBuf@plt>
mov    %r14,%rdi
mov    %rax,%rsi
mov    $0xa,%edx
call   1070 <memcpy@plt>
xor    %edi,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <iGetParaInt@plt>

LLVM IR (-O0):
@.str = [8 x i8] c"%u(b003\00"
@.str.1 = [12 x i8] c",b000,b000)\00"
@.str.2 = [52 x i8] c"iRcTSFID_RUDLL_GetDeviceInfo iDoRemoteFunc ret = %d\00"
define i32 @iRcTSFID_RUDLL_GetDeviceInfo(i8* %0, i8* %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 = call i32 (i8*, i8*, ...) @sprintf(i8* %12, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 4111)
store i32 %13, i32* %8
%14 = load i8*, i8** %10
%15 = load i32, i32* %8
%16 = zext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8*, i8** %5
%19 = call i32 @memcpy(i8* %17, i8* %18, i32 3)
%20 = load i32, i32* %8
%21 = add i32 %20, 3
store i32 %21, i32* %8
%22 = load i8*, i8** %10
%23 = load i32, i32* %8
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %8
%28 = add i32 %27, %26
store i32 %28, i32* %8
%29 = load i8*, i8** %10
%30 = load i32, i32* %8
%31 = call i32 @iDoRemoteFunc(i8* %29, i32 %30, i32 1)
store i32 %31, i32* %9
%32 = load i8*, i8** %10
%33 = call i32 @free(i8* %32)
%34 = load i32, i32* %9
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %3
%37 = load i32, i32* %9
%38 = call i32 @vWriteLogTxt(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %37)
store i32 99, i32* %4
br label %51
39: ; preds = %3
%40 = call i32 @iGetParaInt(i32 0)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %49
42: ; preds = %39
%43 = load i8*, i8** %6
%44 = call i8* @psGetParaBuf(i32 3)
%45 = call i32 @memcpy(i8* %43, i8* %44, i32 10)
%46 = load i8*, i8** %7
%47 = call i8* @psGetParaBuf(i32 4)
%48 = call i32 @memcpy(i8* %46, i8* %47, i32 10)
br label %49
49: ; preds = %42, %39
%50 = call i32 @iGetParaInt(i32 0)
store i32 %50, i32* %4
br label %51
51: ; preds = %49, %36
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@.str = [8 x i8] c"%u(b003\00"
@.str.1 = [12 x i8] c",b000,b000)\00"
@.str.2 = [52 x i8] c"iRcTSFID_RUDLL_GetDeviceInfo iDoRemoteFunc ret = %d\00"
define i32 @iRcTSFID_RUDLL_GetDeviceInfo(i8* %0, i8* %1, i8* %2) {
%4 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%5 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 4111)
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds i8, i8* %4, i64 %6
%8 = tail call i32 @memcpy(i8* %7, i8* %0, i32 3)
%9 = add i32 %5, 3
%10 = zext i32 %9 to i64
%11 = getelementptr inbounds i8, i8* %4, i64 %10
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 dereferenceable(12) %11, i8* align 1 dereferenceable(12) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 12, i1 false)
%12 = add i32 %5, 14
%13 = tail call i32 @iDoRemoteFunc(i8* %4, i32 %12, i32 1)
%14 = tail call i32 @free(i8* %4)
%15 = icmp eq i32 %13, 0
br i1 %15, label %18, label %16
16: ; preds = %3
%17 = tail call i32 @vWriteLogTxt(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %28
18: ; preds = %3
%19 = tail call i32 @iGetParaInt(i32 0)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = tail call i8* @psGetParaBuf(i32 3)
%23 = tail call i32 @memcpy(i8* %1, i8* %22, i32 10)
%24 = tail call i8* @psGetParaBuf(i32 4)
%25 = tail call i32 @memcpy(i8* %2, i8* %24, i32 10)
br label %26
26: ; preds = %21, %18
%27 = tail call i32 @iGetParaInt(i32 0)
br label %28
28: ; preds = %26, %16
%29 = phi i32 [ 99, %16 ], [ %27, %26 ]
ret i32 %29
}