#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);
unsigned int sprintf(char *, char *, int, unsigned int);
int /*<<< orphan*/ vWriteLogTxt(char *, ...);
void _vRcSetUart(unsigned int uiPortNo) {
  unsigned int uiDataLen, uiRet;
  vWriteLogTxt("_vRcSetUart");
  char *psFunCall = malloc(200);
  uiDataLen = sprintf(psFunCall, "%u(%u)", 1051, uiPortNo);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_vRcSetUart iDoRemoteFunc ret = %d", uiRet);
  }
}


x86 assembly (clang, -O0):
<_vRcSetUart>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <vWriteLogTxt@plt>
mov    $0xc8,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%ecx
lea    0xe87(%rip),%rsi
mov    $0x41b,%edx
call   1070 <sprintf@plt>
mov    %eax,-0x8(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1060 <iDoRemoteFunc@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0xc(%rbp)
je     11ca <_vRcSetUart+0x7a>
mov    -0xc(%rbp),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <vWriteLogTxt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vRcSetUart>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
lea    0xea4(%rip),%rdi
xor    %eax,%eax
call   1040 <vWriteLogTxt@plt>
mov    $0xc8,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe95(%rip),%rsi
mov    %rax,%rdi
mov    $0x41b,%edx
mov    %ebp,%ecx
call   1070 <sprintf@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <iDoRemoteFunc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
je     11b9 <_vRcSetUart+0x69>
lea    0xe69(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <vWriteLogTxt@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"_vRcSetUart\00"
@.str.1 = [7 x i8] c"%u(%u)\00"
@.str.2 = [35 x i8] c"_vRcSetUart iDoRemoteFunc ret = %d\00"
define void @_vRcSetUart(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
store i32 %0, i32* %2
%6 = call i32 (i8*, ...) @vWriteLogTxt(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%7 = call i8* @malloc(i32 200)
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = load i32, i32* %2
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1051, i32 %9)
store i32 %10, i32* %3
%11 = load i8*, i8** %5
%12 = load i32, i32* %3
%13 = call i32 @iDoRemoteFunc(i8* %11, i32 %12, i32 1)
store i32 %13, i32* %4
%14 = load i8*, i8** %5
%15 = call i32 @free(i8* %14)
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %1
%19 = load i32, i32* %4
%20 = call i32 (i8*, ...) @vWriteLogTxt(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %1
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"_vRcSetUart\00"
@.str.1 = [7 x i8] c"%u(%u)\00"
@.str.2 = [35 x i8] c"_vRcSetUart iDoRemoteFunc ret = %d\00"
define void @_vRcSetUart(i32 %0) {
%2 = tail call i32 (i8*, ...) @vWriteLogTxt(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = tail call dereferenceable_or_null(200) i8* @malloc(i32 200)
%4 = tail call i32 @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 1051, i32 %0)
%5 = tail call i32 @iDoRemoteFunc(i8* %3, i32 %4, i32 1)
%6 = tail call i32 @free(i8* %3)
%7 = icmp eq i32 %5, 0
br i1 %7, label %10, label %8
8: ; preds = %1
%9 = tail call i32 (i8*, ...) @vWriteLogTxt(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 %5)
br label %10
10: ; preds = %8, %1
ret void
}