#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);
char *malloc(int);
unsigned int sprintf(char *, char *, int);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
unsigned int _uiRcSDSCGetSCIOType(unsigned int *puiSCIOType) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(100);
  uiDataLen = sprintf(psFunCall, "%u(0)", 5029);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_uiRcSDSCGetSCIOType iDoRemoteFunc ret = %d", uiRet);
    return 99;
  }
  if (iGetParaInt(0) == 0) {
    *puiSCIOType = iGetParaInt(2);
  }
  return iGetParaInt(0);
}


x86 assembly (clang, -O0):
<_uiRcSDSCGetSCIOType>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x13a5,%edx
call   1080 <sprintf@plt>
mov    %eax,-0x14(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    $0x1,%edx
call   1070 <iDoRemoteFunc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x18(%rbp)
je     11d4 <_uiRcSDSCGetSCIOType+0x74>
mov    -0x18(%rbp),%esi
lea    0xe43(%rip),%rdi
call   1050 <vWriteLogTxt@plt>
movl   $0x63,-0x4(%rbp)
jmp    1200 <_uiRcSDSCGetSCIOType+0xa0>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
cmp    $0x0,%eax
jne    11f6 <_uiRcSDSCGetSCIOType+0x96>
mov    $0x2,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_uiRcSDSCGetSCIOType>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe85(%rip),%rsi
mov    %rax,%rdi
mov    $0x13a5,%edx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1070 <iDoRemoteFunc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
je     11bd <_uiRcSDSCGetSCIOType+0x5d>
lea    0xe5a(%rip),%rdi
mov    %ebp,%esi
call   1050 <vWriteLogTxt@plt>
mov    $0x63,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
test   %eax,%eax
jne    11d5 <_uiRcSDSCGetSCIOType+0x75>
mov    $0x2,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,(%r14)
xor    %edi,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <iGetParaInt@plt>

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

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