#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 *, unsigned int);
void _vRcSetCardVoltage(unsigned int uiVoltage) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(50);
  uiDataLen = sprintf(psFunCall, "%u(%u)", 1052, uiVoltage);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("vSetCardVoltage iDoRemoteFunc ret = %d", uiRet);
  }
}


x86 assembly (clang, -O0):
<_vRcSetCardVoltage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x32,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x4(%rbp),%ecx
lea    0xe89(%rip),%rsi
mov    $0x41c,%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     11ba <_vRcSetCardVoltage+0x6a>
mov    -0xc(%rbp),%esi
lea    0xe52(%rip),%rdi
call   1040 <vWriteLogTxt@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_vRcSetCardVoltage>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x32,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xe97(%rip),%rsi
mov    %rax,%rdi
mov    $0x41c,%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     11a9 <_vRcSetCardVoltage+0x59>
lea    0xe6b(%rip),%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <vWriteLogTxt@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%u(%u)\00"
@.str.1 = [39 x i8] c"vSetCardVoltage iDoRemoteFunc ret = %d\00"
define void @_vRcSetCardVoltage(i32 %0) {
%2 = tail call dereferenceable_or_null(50) i8* @malloc(i32 50)
%3 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 1052, i32 %0)
%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 ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0), i32 %4)
br label %9
9: ; preds = %7, %1
ret void
}