#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);
int /*<<< orphan*/ memcpy(unsigned char *, int /*<<< orphan*/, unsigned int);
int /*<<< orphan*/ psGetParaBuf(int);
unsigned int sprintf(char *, char *, int, unsigned long);
int /*<<< orphan*/ vWriteLogTxt(char *, unsigned int);
unsigned int _uiRcFingerprintRecv(unsigned char *psOut, unsigned int *puiOutLen,
                                  unsigned long ulTimeOutMs) {
  unsigned int uiDataLen, uiRet;
  char *psFunCall = malloc(100);
  uiDataLen = sprintf(psFunCall, "%u(b000,0,%lu)", 4005, ulTimeOutMs);
  uiRet = iDoRemoteFunc((unsigned char *)psFunCall, uiDataLen,
                        1 + (unsigned int)(ulTimeOutMs / 1000L));
  free(psFunCall);
  if (uiRet) {
    vWriteLogTxt("_uiRcFingerprintRecv iDoRemoteFunc ret = %d", uiRet);
    return 99;
  }
  if (iGetParaInt(0) == 0) {
    *puiOutLen = iGetParaInt(3);
    memcpy(psOut, psGetParaBuf(2), *puiOutLen);
  }
  return iGetParaInt(0);
}


x86 assembly (clang, -O0):
<_uiRcFingerprintRecv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rcx
lea    0xe4f(%rip),%rsi
mov    $0xfa5,%edx
call   10a0 <sprintf@plt>
mov    %eax,-0x24(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rax
mov    $0x3e8,%ecx
xor    %edx,%edx
div    %rcx
mov    %eax,%edx
add    $0x1,%edx
call   1090 <iDoRemoteFunc@plt>
mov    %eax,-0x28(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x28(%rbp)
je     120e <_uiRcFingerprintRecv+0x8e>
mov    -0x28(%rbp),%esi
lea    0xe12(%rip),%rdi
call   1060 <vWriteLogTxt@plt>
movl   $0x63,-0x4(%rbp)
jmp    125d <_uiRcFingerprintRecv+0xdd>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
cmp    $0x0,%eax
jne    1253 <_uiRcFingerprintRecv+0xd3>
mov    $0x3,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x2,%edi
call   1050 <psGetParaBuf@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
call   1070 <memcpy@plt>
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_uiRcFingerprintRecv>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbp
mov    %rsi,%r15
mov    %rdi,%r14
mov    $0x64,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
lea    0xe5c(%rip),%rsi
mov    %rax,%rdi
mov    $0xfa5,%edx
mov    %rbp,%rcx
call   10a0 <sprintf@plt>
mov    %eax,%esi
shr    $0x3,%rbp
movabs $0x20c49ba5e353f7cf,%rcx
9b c4 20
mov    %rbp,%rax
mul    %rcx
shr    $0x4,%rdx
add    $0x1,%edx
mov    %rbx,%rdi
call   1090 <iDoRemoteFunc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
test   %ebp,%ebp
je     1205 <_uiRcFingerprintRecv+0x85>
lea    0xe21(%rip),%rdi
mov    %ebp,%esi
call   1060 <vWriteLogTxt@plt>
mov    $0x63,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %edi,%edi
call   1040 <iGetParaInt@plt>
test   %eax,%eax
jne    1234 <_uiRcFingerprintRecv+0xb4>
mov    $0x3,%edi
call   1040 <iGetParaInt@plt>
mov    %eax,(%r15)
mov    $0x2,%edi
call   1050 <psGetParaBuf@plt>
mov    (%r15),%edx
mov    %r14,%rdi
mov    %eax,%esi
call   1070 <memcpy@plt>
xor    %edi,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <iGetParaInt@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"%u(b000,0,%lu)\00"
@.str.1 = [44 x i8] c"_uiRcFingerprintRecv iDoRemoteFunc ret = %d\00"
define i32 @_uiRcFingerprintRecv(i8* %0, i32* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
store i8* %0, i8** %5
store i32* %1, i32** %6
store i64 %2, i64* %7
%11 = call i8* @malloc(i32 100)
store i8* %11, i8** %10
%12 = load i8*, i8** %10
%13 = load i64, i64* %7
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 4005, i64 %13)
store i32 %14, i32* %8
%15 = load i8*, i8** %10
%16 = load i32, i32* %8
%17 = load i64, i64* %7
%18 = udiv i64 %17, 1000
%19 = trunc i64 %18 to i32
%20 = add i32 1, %19
%21 = call i32 @iDoRemoteFunc(i8* %15, i32 %16, i32 %20)
store i32 %21, i32* %9
%22 = load i8*, i8** %10
%23 = call i32 @free(i8* %22)
%24 = load i32, i32* %9
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %3
%27 = load i32, i32* %9
%28 = call i32 @vWriteLogTxt(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %27)
store i32 99, i32* %4
br label %42
29: ; preds = %3
%30 = call i32 @iGetParaInt(i32 0)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %40
32: ; preds = %29
%33 = call i32 @iGetParaInt(i32 3)
%34 = load i32*, i32** %6
store i32 %33, i32* %34
%35 = load i8*, i8** %5
%36 = call i32 @psGetParaBuf(i32 2)
%37 = load i32*, i32** %6
%38 = load i32, i32* %37
%39 = call i32 @memcpy(i8* %35, i32 %36, i32 %38)
br label %40
40: ; preds = %32, %29
%41 = call i32 @iGetParaInt(i32 0)
store i32 %41, i32* %4
br label %42
42: ; preds = %40, %26
%43 = load i32, i32* %4
ret i32 %43
}

LLVM IR (-O2):
@.str = [15 x i8] c"%u(b000,0,%lu)\00"
@.str.1 = [44 x i8] c"_uiRcFingerprintRecv iDoRemoteFunc ret = %d\00"
define i32 @_uiRcFingerprintRecv(i8* %0, i32* nocapture %1, i64 %2) {
%4 = tail call dereferenceable_or_null(100) i8* @malloc(i32 100)
%5 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 4005, i64 %2)
%6 = udiv i64 %2, 1000
%7 = trunc i64 %6 to i32
%8 = add i32 %7, 1
%9 = tail call i32 @iDoRemoteFunc(i8* %4, i32 %5, i32 %8)
%10 = tail call i32 @free(i8* %4)
%11 = icmp eq i32 %9, 0
br i1 %11, label %14, label %12
12: ; preds = %3
%13 = tail call i32 @vWriteLogTxt(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %24
14: ; preds = %3
%15 = tail call i32 @iGetParaInt(i32 0)
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = tail call i32 @iGetParaInt(i32 3)
store i32 %18, i32* %1
%19 = tail call i32 @psGetParaBuf(i32 2)
%20 = load i32, i32* %1
%21 = tail call i32 @memcpy(i8* %0, i32 %19, i32 %20)
br label %22
22: ; preds = %17, %14
%23 = tail call i32 @iGetParaInt(i32 0)
br label %24
24: ; preds = %22, %12
%25 = phi i32 [ 99, %12 ], [ %23, %22 ]
ret i32 %25
}