#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);
char *malloc(int);
int /*<<< orphan*/ memcpy(char *, unsigned char *, int);
unsigned int sprintf(char *, char *, ...);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
void _vRcSLE4428_UpdPSC(unsigned char *sSecurityCode) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(50);
  uiDataLen = sprintf(psFunCall, "%u(b002", 9308);
  memcpy(psFunCall + uiDataLen, sSecurityCode, 2);
  uiDataLen += 2;
  uiDataLen += sprintf(psFunCall + uiDataLen, ")");
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_SLE4428_UpdPSC iDoRemoteFunc ret = %d", uiRet);
  }
}


x86 assembly (clang, -O0):
<_vRcSLE4428_UpdPSC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x32,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x245c,%edx
mov    $0x0,%al
call   1080 <sprintf@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    %rax,%rdi
mov    -0x8(%rbp),%rsi
mov    $0x2,%edx
call   1050 <memcpy@plt>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%eax
add    %rax,%rdi
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1080 <sprintf@plt>
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
call   1070 <iDoRemoteFunc@plt>
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x10(%rbp)
je     1209 <_vRcSLE4428_UpdPSC+0xa9>
mov    -0x10(%rbp),%esi
lea    0xe06(%rip),%rdi
call   1040 <vWriteLogTxt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vRcSLE4428_UpdPSC>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x32,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe85(%rip),%rsi
mov    %rax,%rdi
mov    $0x245c,%edx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %eax,%ebp
mov    %eax,%edi
add    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1050 <memcpy@plt>
lea    0x2(%rbp),%eax
movw   $0x29,(%rbx,%rax,1)
add    $0x3,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x1,%edx
call   1070 <iDoRemoteFunc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
je     11d9 <_vRcSLE4428_UpdPSC+0x79>
lea    0xe3a(%rip),%rdi
mov    %ebp,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <vWriteLogTxt@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%u(b002\00"
@.str.1 = [2 x i8] c")\00"
@.str.2 = [39 x i8] c"_SLE4428_UpdPSC iDoRemoteFunc ret = %d\00"
define void @_vRcSLE4428_UpdPSC(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %2
%6 = call i8* @malloc(i32 50)
store i8* %6, i8** %5
%7 = load i8*, i8** %5
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 9308)
store i32 %8, i32* %3
%9 = load i8*, i8** %5
%10 = load i32, i32* %3
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8*, i8** %2
%14 = call i32 @memcpy(i8* %12, i8* %13, i32 2)
%15 = load i32, i32* %3
%16 = add i32 %15, 2
store i32 %16, i32* %3
%17 = load i8*, i8** %5
%18 = load i32, i32* %3
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = call i32 (i8*, i8*, ...) @sprintf(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = load i32, i32* %3
%23 = add i32 %22, %21
store i32 %23, i32* %3
%24 = load i8*, i8** %5
%25 = load i32, i32* %3
%26 = call i32 @iDoRemoteFunc(i8* %24, i32 %25, i32 1)
store i32 %26, i32* %4
%27 = load i8*, i8** %5
%28 = call i32 @free(i8* %27)
%29 = load i32, i32* %4
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %1
%32 = load i32, i32* %4
%33 = call i32 @vWriteLogTxt(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %31, %1
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"%u(b002\00"
@.str.2 = [39 x i8] c"_SLE4428_UpdPSC iDoRemoteFunc ret = %d\00"
define void @_vRcSLE4428_UpdPSC(i8* %0) {
%2 = tail call dereferenceable_or_null(50) i8* @malloc(i32 50)
%3 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 9308)
%4 = zext i32 %3 to i64
%5 = getelementptr inbounds i8, i8* %2, i64 %4
%6 = tail call i32 @memcpy(i8* %5, i8* %0, i32 2)
%7 = add i32 %3, 2
%8 = zext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %2, i64 %8
%10 = bitcast i8* %9 to i16*
store i16 41, i16* %10
%11 = add i32 %3, 3
%12 = tail call i32 @iDoRemoteFunc(i8* %2, i32 %11, i32 1)
%13 = tail call i32 @free(i8* %2)
%14 = icmp eq i32 %12, 0
br i1 %14, label %17, label %15
15: ; preds = %1
%16 = tail call i32 @vWriteLogTxt(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %17
17: ; preds = %15, %1
ret void
}