#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 char iGetParaInt(int /*<<< orphan*/);
char *malloc(int);
unsigned int sprintf(char *, char *, int, unsigned long, unsigned char,
                     unsigned char, unsigned char);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
unsigned char _ucRcAsyncOpen(unsigned long ulBaud, unsigned char ucParity,
                             unsigned char ucBits, unsigned char ucStop) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(100);
  uiDataLen = sprintf(psFunCall, "%u(%lu,%u,%u,%u)", 1016, ulBaud, ucParity,
                      ucBits, ucStop);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen, 1);
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_ucRcAsyncOpen iDoRemoteFunc ret = %d", uiRet);
    return 2;
  }
  return iGetParaInt(0);
}


x86 assembly (clang, -O0):
<_ucRcAsyncOpen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %sil,%dl
mov    %rdi,-0x10(%rbp)
mov    %dl,-0x11(%rbp)
mov    %cl,-0x12(%rbp)
mov    %al,-0x13(%rbp)
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x11(%rbp),%r8b
mov    -0x12(%rbp),%al
lea    0xe60(%rip),%rsi
mov    $0x3f8,%edx
movzbl %r8b,%r8d
movzbl %al,%r9d
movzbl -0x13(%rbp),%eax
mov    %eax,(%rsp)
call   1080 <sprintf@plt>
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   1070 <iDoRemoteFunc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x1c(%rbp)
je     11fb <_ucRcAsyncOpen+0x9b>
mov    -0x1c(%rbp),%esi
lea    0xe24(%rip),%rdi
call   1050 <vWriteLogTxt@plt>
movb   $0x2,-0x1(%rbp)
jmp    1205 <_ucRcAsyncOpen+0xa5>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
mov    %al,-0x1(%rbp)
movzbl -0x1(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_ucRcAsyncOpen>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r12
mov    $0x64,%edi
call   1060 <malloc@plt>
mov    %rax,%rbp
mov    %ebx,(%rsp)
lea    0xe72(%rip),%rsi
mov    %rax,%rdi
mov    $0x3f8,%edx
mov    %r12,%rcx
mov    %r15d,%r8d
mov    %r14d,%r9d
call   1080 <sprintf@plt>
mov    %rbp,%rdi
mov    %eax,%esi
mov    $0x1,%edx
call   1070 <iDoRemoteFunc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <free@plt>
test   %ebx,%ebx
je     11de <_ucRcAsyncOpen+0x7e>
lea    0xe49(%rip),%rdi
mov    %ebx,%esi
call   1050 <vWriteLogTxt@plt>
mov    $0x2,%al
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <iGetParaInt@plt>

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

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