#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 UnpckBacpAppEx(unsigned short *, char **, char **, unsigned char **, int *,
                   unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ strcpy(char *, char *);
int UnpckBacpApp(unsigned short *pnFunCode, char *pSrcDev, char *pDestDev,
                 unsigned char *pData, int *pnDataLen, unsigned char *pFrm,
                 int nFrmLen) {
  char *pSrcDevTmp;
  char *pDestDevTmp;
  unsigned char *pDataTmp;
  int nFrmLenInner;
  nFrmLenInner = UnpckBacpAppEx(pnFunCode, &pSrcDevTmp, &pDestDevTmp, &pDataTmp,
                                pnDataLen, pFrm, nFrmLen);
  if (nFrmLenInner > 0) {
    strcpy(pSrcDev, pSrcDevTmp);
    strcpy(pDestDev, pDestDevTmp);
    if (*pnDataLen > 0) {
      memcpy(pData, pDataTmp, *pnDataLen);
    }
  }
  return nFrmLenInner;
}


x86 assembly (clang, -O0):
<UnpckBacpApp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    0x10(%rbp),%eax
lea    -0x38(%rbp),%rsi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
mov    %eax,(%rsp)
call   1040 <UnpckBacpAppEx@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
jle    11c2 <UnpckBacpApp+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rax
cmpl   $0x0,(%rax)
jle    11bd <UnpckBacpApp+0x8d>
mov    -0x20(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x28(%rbp),%rax
mov    (%rax),%edx
call   1050 <memcpy@plt>
jmp    11c2 <UnpckBacpApp+0x92>
mov    -0x4c(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UnpckBacpApp>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    0x50(%rsp),%eax
mov    %eax,(%rsp)
lea    0x18(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
call   1040 <UnpckBacpAppEx@plt>
mov    %eax,%ebp
test   %eax,%eax
jle    1196 <UnpckBacpApp+0x66>
mov    0x18(%rsp),%rsi
mov    %r12,%rdi
call   1030 <strcpy@plt>
mov    0x10(%rsp),%rsi
mov    %r15,%rdi
call   1030 <strcpy@plt>
mov    (%rbx),%edx
test   %edx,%edx
jle    1196 <UnpckBacpApp+0x66>
mov    0x8(%rsp),%rsi
mov    %r14,%rdi
call   1050 <memcpy@plt>
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @UnpckBacpApp(i16* %0, i8* %1, i8* %2, i8* %3, i32* %4, i8* %5, i32 %6) {
%8 = alloca i16*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
store i16* %0, i16** %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i32* %4, i32** %12
store i8* %5, i8** %13
store i32 %6, i32* %14
%19 = load i16*, i16** %8
%20 = load i32*, i32** %12
%21 = load i8*, i8** %13
%22 = load i32, i32* %14
%23 = call i32 @UnpckBacpAppEx(i16* %19, i8** %15, i8** %16, i8** %17, i32* %20, i8* %21, i32 %22)
store i32 %23, i32* %18
%24 = load i32, i32* %18
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %43
26: ; preds = %7
%27 = load i8*, i8** %9
%28 = load i8*, i8** %15
%29 = call i32 @strcpy(i8* %27, i8* %28)
%30 = load i8*, i8** %10
%31 = load i8*, i8** %16
%32 = call i32 @strcpy(i8* %30, i8* %31)
%33 = load i32*, i32** %12
%34 = load i32, i32* %33
%35 = icmp sgt i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %26
%37 = load i8*, i8** %11
%38 = load i8*, i8** %17
%39 = load i32*, i32** %12
%40 = load i32, i32* %39
%41 = call i32 @memcpy(i8* %37, i8* %38, i32 %40)
br label %42
42: ; preds = %36, %26
br label %43
43: ; preds = %42, %7
%44 = load i32, i32* %18
ret i32 %44
}

LLVM IR (-O2):
define i32 @UnpckBacpApp(i16* %0, i8* %1, i8* %2, i8* %3, i32* %4, i8* %5, i32 %6) {
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = bitcast i8** %8 to i8*
%12 = bitcast i8** %9 to i8*
%13 = bitcast i8** %10 to i8*
%14 = call i32 @UnpckBacpAppEx(i16* %0, i8** %8, i8** %9, i8** %10, i32* %4, i8* %5, i32 %6)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %26
16: ; preds = %7
%17 = load i8*, i8** %8
%18 = call i32 @strcpy(i8* %1, i8* %17)
%19 = load i8*, i8** %9
%20 = call i32 @strcpy(i8* %2, i8* %19)
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = load i8*, i8** %10
%25 = call i32 @memcpy(i8* %3, i8* %24, i32 %21)
br label %26
26: ; preds = %16, %23, %7
ret i32 %14
}