unsigned int
_uiRcSDSCTransmit(unsigned char *psCommand, unsigned int uiCommandLen,
                  unsigned int uiTimeOutMode, unsigned char *psOutData,
                  unsigned int *puiOutDataLen, unsigned int *puiCosState) {
  unsigned int uiDataLen;
  int iRet;
  unsigned int uiTimeout;
  char *psFunCall = malloc(1024);
  uiDataLen = sprintf(psFunCall, "%u(b%03u", 5026, uiCommandLen);
  memcpy(psFunCall + uiDataLen, psCommand, uiCommandLen);
  uiDataLen += uiCommandLen;
  uiDataLen += sprintf(psFunCall + uiDataLen, ",%u,%u,b000,%u,0)", uiCommandLen,
                       uiTimeOutMode, *puiOutDataLen);
  uiTimeout = 5;
  if (uiTimeOutMode)
    uiTimeout = 46;
  iRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, uiTimeout);
  free(psFunCall);
  if (iRet == -2)
    return 9;
  if (iRet) {
    vWriteLogTxt("_uiRcSDSCTransmit iDoRemoteFunc ret = %d", iRet);
    return 1;
  }
  iRet = iGetParaInt(0);
  vWriteLogTxt("_uiRcSDSCTransmit iRet = %d", iRet);
  if (iRet != 0)
    return 1;
  uiDataLen = iGetParaInt(6);
  *puiOutDataLen = uiDataLen;
  *puiCosState = iGetParaInt(7);
  memcpy(psOutData, psGetParaBuf(5), uiDataLen);
  vWriteLogTxt("_uiRcSDSCTransmit success!!");
  return (0);
}


x86 assembly (clang, -O0):
<_uiRcSDSCTransmit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    $0x400,%edi
call   1080 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x14(%rbp),%ecx
lea    0xe46(%rip),%rsi
mov    $0x13a2,%edx
mov    $0x0,%al
call   10a0 <sprintf@plt>
mov    %eax,-0x34(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x34(%rbp),%eax
add    %rax,%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%eax
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    -0x14(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x34(%rbp),%eax
add    %rax,%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    (%rax),%r8d
lea    0xe01(%rip),%rsi
mov    $0x0,%al
call   10a0 <sprintf@plt>
add    -0x34(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x5,-0x3c(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     122d <_uiRcSDSCTransmit+0xad>
movl   $0x2e,-0x3c(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x34(%rbp),%esi
mov    -0x3c(%rbp),%edx
mov    $0x0,%al
call   1090 <iDoRemoteFunc@plt>
mov    %eax,-0x38(%rbp)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0xfffffffe,-0x38(%rbp)
jne    1260 <_uiRcSDSCTransmit+0xe0>
movl   $0x9,-0x4(%rbp)
jmp    1320 <_uiRcSDSCTransmit+0x1a0>
cmpl   $0x0,-0x38(%rbp)
je     1287 <_uiRcSDSCTransmit+0x107>
mov    -0x38(%rbp),%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1060 <vWriteLogTxt@plt>
movl   $0x1,-0x4(%rbp)
jmp    1320 <_uiRcSDSCTransmit+0x1a0>
xor    %edi,%edi
mov    $0x0,%al
call   1040 <iGetParaInt@plt>
mov    %eax,-0x38(%rbp)
mov    -0x38(%rbp),%esi
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1060 <vWriteLogTxt@plt>
cmpl   $0x0,-0x38(%rbp)
je     12ba <_uiRcSDSCTransmit+0x13a>
movl   $0x1,-0x4(%rbp)
jmp    1320 <_uiRcSDSCTransmit+0x1a0>
mov    $0x6,%edi
mov    $0x0,%al
call   1040 <iGetParaInt@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x7,%edi
mov    $0x0,%al
call   1040 <iGetParaInt@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    $0x5,%edi
mov    $0x0,%al
call   1050 <psGetParaBuf@plt>
mov    -0x50(%rbp),%rdi
movslq %eax,%rsi
mov    -0x34(%rbp),%eax
mov    %eax,%edx
call   1070 <memcpy@plt>
lea    0xd4e(%rip),%rdi
mov    $0x0,%al
call   1060 <vWriteLogTxt@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_uiRcSDSCTransmit>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,%r12
mov    %rcx,0x10(%rsp)
mov    %edx,%r13d
mov    %esi,%ebp
mov    %rdi,%r15
mov    $0x400,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xe49(%rip),%rsi
mov    %rax,%rdi
mov    $0x13a2,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   10a0 <sprintf@plt>
mov    %eax,%r14d
mov    %eax,%edi
add    %rbx,%rdi
mov    %ebp,%edx
mov    %r15,%rsi
call   1070 <memcpy@plt>
add    %ebp,%r14d
lea    (%r14,%rbx,1),%rdi
mov    (%r12),%r8d
lea    0xe1d(%rip),%rsi
mov    %ebp,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   10a0 <sprintf@plt>
add    %eax,%r14d
test   %r13d,%r13d
mov    $0x5,%eax
mov    $0x2e,%edx
cmove  %eax,%edx
mov    %rbx,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1090 <iDoRemoteFunc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
cmp    $0xfffffffe,%ebp
je     12a1 <_uiRcSDSCTransmit+0x121>
test   %ebp,%ebp
jne    12a8 <_uiRcSDSCTransmit+0x128>
xor    %edi,%edi
xor    %eax,%eax
call   1040 <iGetParaInt@plt>
mov    %eax,%ebx
lea    0xe07(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <vWriteLogTxt@plt>
mov    $0x1,%eax
test   %ebx,%ebx
jne    12bd <_uiRcSDSCTransmit+0x13d>
mov    $0x6,%edi
xor    %eax,%eax
call   1040 <iGetParaInt@plt>
mov    %eax,%ebx
mov    %eax,(%r12)
mov    $0x7,%edi
xor    %eax,%eax
call   1040 <iGetParaInt@plt>
mov    0x8(%rsp),%rcx
mov    %eax,(%rcx)
mov    $0x5,%edi
xor    %eax,%eax
call   1050 <psGetParaBuf@plt>
movslq %eax,%rsi
mov    %ebx,%edx
mov    0x10(%rsp),%rdi
call   1070 <memcpy@plt>
lea    0xdca(%rip),%rdi
xor    %eax,%eax
call   1060 <vWriteLogTxt@plt>
xor    %eax,%eax
jmp    12bd <_uiRcSDSCTransmit+0x13d>
mov    $0x9,%eax
jmp    12bd <_uiRcSDSCTransmit+0x13d>
lea    0xd6c(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <vWriteLogTxt@plt>
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%u(b%03u\00"
@.str.1 = [18 x i8] c",%u,%u,b000,%u,0)\00"
@.str.2 = [41 x i8] c"_uiRcSDSCTransmit iDoRemoteFunc ret = %d\00"
@.str.3 = [28 x i8] c"_uiRcSDSCTransmit iRet = %d\00"
@.str.4 = [28 x i8] c"_uiRcSDSCTransmit success!!\00"
define i32 @_uiRcSDSCTransmit(i8* %0, i32 %1, i32 %2, i8* %3, i32* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i8*
store i8* %0, i8** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i8* %3, i8** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
%18 = call i8* @malloc(i64 1024)
store i8* %18, i8** %17
%19 = load i8*, i8** %17
%20 = load i32, i32* %9
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %19, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 5026, i32 %20)
store i32 %21, i32* %14
%22 = load i8*, i8** %17
%23 = load i32, i32* %14
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8, i8* %22, i64 %24
%26 = load i8*, i8** %8
%27 = load i32, i32* %9
%28 = zext i32 %27 to i64
%29 = load i32, i32* %9
%30 = load i32, i32* %14
%31 = add i32 %30, %29
store i32 %31, i32* %14
%32 = load i8*, i8** %17
%33 = load i32, i32* %14
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i32, i32* %9
%37 = load i32, i32* %10
%38 = load i32*, i32** %12
%39 = load i32, i32* %38
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %36, i32 %37, i32 %39)
%41 = load i32, i32* %14
%42 = add i32 %41, %40
store i32 %42, i32* %14
store i32 5, i32* %16
%43 = load i32, i32* %10
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %6
store i32 46, i32* %16
br label %46
46: ; preds = %45, %6
%47 = load i8*, i8** %17
%48 = load i32, i32* %14
%49 = load i32, i32* %16
%50 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @iDoRemoteFunc to i32 (i8*, i32, i32, ...)*)(i8* %47, i32 %48, i32 %49)
store i32 %50, i32* %15
%51 = load i8*, i8** %17
%52 = load i32, i32* %15
%53 = icmp eq i32 %52, -2
br i1 %53, label %54, label %55
54: ; preds = %46
store i32 9, i32* %7
br label %81
55: ; preds = %46
%56 = load i32, i32* %15
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %55
%59 = load i32, i32* %15
%60 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @vWriteLogTxt to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %59)
store i32 1, i32* %7
br label %81
61: ; preds = %55
%62 = call i32 (i32, ...) bitcast (i32 (...)* @iGetParaInt to i32 (i32, ...)*)(i32 0)
store i32 %62, i32* %15
%63 = load i32, i32* %15
%64 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @vWriteLogTxt to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %63)
%65 = load i32, i32* %15
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %61
store i32 1, i32* %7
br label %81
68: ; preds = %61
%69 = call i32 (i32, ...) bitcast (i32 (...)* @iGetParaInt to i32 (i32, ...)*)(i32 6)
store i32 %69, i32* %14
%70 = load i32, i32* %14
%71 = load i32*, i32** %12
store i32 %70, i32* %71
%72 = call i32 (i32, ...) bitcast (i32 (...)* @iGetParaInt to i32 (i32, ...)*)(i32 7)
%73 = load i32*, i32** %13
store i32 %72, i32* %73
%74 = load i8*, i8** %11
%75 = call i32 (i32, ...) bitcast (i32 (...)* @psGetParaBuf to i32 (i32, ...)*)(i32 5)
%76 = sext i32 %75 to i64
%77 = inttoptr i64 %76 to i8*
%78 = load i32, i32* %14
%79 = zext i32 %78 to i64
%80 = call i32 (i8*, ...) bitcast (i32 (...)* @vWriteLogTxt to i32 (i8*, ...)*)(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %7
br label %81
81: ; preds = %68, %67, %58, %54
%82 = load i32, i32* %7
ret i32 %82
}

LLVM IR (-O2):
@.str = [9 x i8] c"%u(b%03u\00"
@.str.1 = [18 x i8] c",%u,%u,b000,%u,0)\00"
@.str.2 = [41 x i8] c"_uiRcSDSCTransmit iDoRemoteFunc ret = %d\00"
@.str.3 = [28 x i8] c"_uiRcSDSCTransmit iRet = %d\00"
@.str.4 = [28 x i8] c"_uiRcSDSCTransmit success!!\00"
define i32 @_uiRcSDSCTransmit(i8* nocapture %0, i32 %1, i32 %2, i8* nocapture writeonly %3, i32* nocapture %4, i32* nocapture writeonly %5) {
%7 = tail call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%8 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %7, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 5026, i32 %1)
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %7, i64 %9
%11 = zext i32 %1 to i64
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %10, i8* align 1 %0, i64 %11, i1 false)
%12 = add i32 %8, %1
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %7, i64 %13
%15 = load i32, i32* %4
%16 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2, i32 %15)
%17 = add i32 %16, %12
%18 = icmp eq i32 %2, 0
%19 = select i1 %18, i32 5, i32 46
%20 = tail call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @iDoRemoteFunc to i32 (i8*, i32, i32, ...)*)(i8* %7, i32 %17, i32 %19)
tail call void @free(i8* %7)
switch i32 %20, label %21 [
i32 -2, label %35
i32 0, label %23
]
21: ; preds = %6
%22 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @vWriteLogTxt to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %35
23: ; preds = %6
%24 = tail call i32 (i32, ...) bitcast (i32 (...)* @iGetParaInt to i32 (i32, ...)*)(i32 0)
%25 = tail call i32 (i8*, i32, ...) bitcast (i32 (...)* @vWriteLogTxt to i32 (i8*, i32, ...)*)(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = icmp eq i32 %24, 0
br i1 %26, label %27, label %35
27: ; preds = %23
%28 = tail call i32 (i32, ...) bitcast (i32 (...)* @iGetParaInt to i32 (i32, ...)*)(i32 6)
store i32 %28, i32* %4
%29 = tail call i32 (i32, ...) bitcast (i32 (...)* @iGetParaInt to i32 (i32, ...)*)(i32 7)
store i32 %29, i32* %5
%30 = tail call i32 (i32, ...) bitcast (i32 (...)* @psGetParaBuf to i32 (i32, ...)*)(i32 5)
%31 = sext i32 %30 to i64
%32 = inttoptr i64 %31 to i8*
%33 = zext i32 %28 to i64
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %3, i8* align 1 %32, i64 %33, i1 false)
%34 = tail call i32 (i8*, ...) bitcast (i32 (...)* @vWriteLogTxt to i32 (i8*, ...)*)(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %35
35: ; preds = %23, %6, %27, %21
%36 = phi i32 [ 1, %21 ], [ 0, %27 ], [ 9, %6 ], [ 1, %23 ]
ret i32 %36
}