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


x86 assembly (clang, -O0):
<_vRcSetLed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
lea    0xe98(%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    0xe80(%rip),%rsi
mov    $0x41a,%edx
movzbl -0x5(%rbp),%r8d
call   1070 <sprintf@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    $0x1,%edx
call   1060 <iDoRemoteFunc@plt>
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x10(%rbp)
je     11d5 <_vRcSetLed+0x85>
mov    -0x10(%rbp),%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1040 <vWriteLogTxt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vRcSetLed>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebx
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1040 <vWriteLogTxt@plt>
mov    $0xc8,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
lea    0xe90(%rip),%rsi
mov    %rax,%rdi
mov    $0x41a,%edx
mov    %ebx,%ecx
mov    %r14d,%r8d
call   1070 <sprintf@plt>
mov    %rbp,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1060 <iDoRemoteFunc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <free@plt>
test   %ebx,%ebx
je     11be <_vRcSetLed+0x6e>
lea    0xe64(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <vWriteLogTxt@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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