#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*/ freeCommands(char **, unsigned int);
unsigned int handleMessages(void *, unsigned char, char *, char **,
                            unsigned int *, unsigned int *, unsigned int **,
                            void **);
unsigned int startNonBlockingBatch(void *, char **, unsigned int,
                                   unsigned int *);
unsigned int startHandleMessages(void *handle, char *messages,
                                 unsigned char actionType,
                                 unsigned int *resultsLength,
                                 unsigned int **results, void **rulesBinding,
                                 unsigned int *replyCount) {
  char *commands[10000];
  unsigned int commandCount = 0;
  unsigned int result =
      handleMessages(handle, actionType, messages, commands, &commandCount,
                     resultsLength, results, rulesBinding);
  if (result != 0 && result != 201) {
    freeCommands(commands, commandCount);
    return result;
  }
  unsigned int batchResult =
      startNonBlockingBatch(*rulesBinding, commands, commandCount, replyCount);
  if (batchResult != 0) {
    return batchResult;
  }
  return result;
}


x86 assembly (clang, -O0):
<startHandleMessages>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138e0,%rsp
mov    %dl,%al
mov    0x10(%rbp),%rdx
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
movl   $0x0,-0x138c4(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x19(%rbp),%sil
mov    -0x18(%rbp),%rdx
lea    -0x138c0(%rbp),%rcx
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%r10
mov    -0x38(%rbp),%rax
lea    -0x138c4(%rbp),%r8
movzbl %sil,%esi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <handleMessages@plt>
mov    %eax,-0x138c8(%rbp)
cmpl   $0x0,-0x138c8(%rbp)
je     11dd <startHandleMessages+0xad>
cmpl   $0xc9,-0x138c8(%rbp)
je     11dd <startHandleMessages+0xad>
lea    -0x138c0(%rbp),%rdi
mov    -0x138c4(%rbp),%esi
call   1050 <freeCommands@plt>
mov    -0x138c8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1224 <startHandleMessages+0xf4>
mov    -0x38(%rbp),%rax
mov    (%rax),%rdi
lea    -0x138c0(%rbp),%rsi
mov    -0x138c4(%rbp),%edx
mov    0x10(%rbp),%rcx
call   1030 <startNonBlockingBatch@plt>
mov    %eax,-0x138cc(%rbp)
cmpl   $0x0,-0x138cc(%rbp)
je     121b <startHandleMessages+0xeb>
mov    -0x138cc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1224 <startHandleMessages+0xf4>
mov    -0x138c8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x138e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<startHandleMessages>:
push   %r14
push   %rbx
sub    $0x13898,%rsp
mov    %r9,%r14
mov    %r8,%rax
mov    %rcx,%r9
mov    %rsi,%rbx
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %edx,%esi
mov    %rbx,%rdx
push   %r14
push   %rax
call   1040 <handleMessages@plt>
add    $0x10,%rsp
mov    %eax,%ebx
test   %eax,%eax
je     1177 <startHandleMessages+0x47>
cmp    $0xc9,%ebx
jne    1197 <startHandleMessages+0x67>
mov    0x138b0(%rsp),%rcx
mov    (%r14),%rdi
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%rsi
call   1030 <startNonBlockingBatch@plt>
test   %eax,%eax
cmovne %eax,%ebx
jmp    11a5 <startHandleMessages+0x75>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1050 <freeCommands@plt>
mov    %ebx,%eax
add    $0x13898,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @startHandleMessages(i8* %0, i8* %1, i8 zeroext %2, i32* %3, i32** %4, i8** %5, i32* %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8
%12 = alloca i32*
%13 = alloca i32**
%14 = alloca i8**
%15 = alloca i32*
%16 = alloca [10000 x i8*]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i8* %0, i8** %9
store i8* %1, i8** %10
store i8 %2, i8* %11
store i32* %3, i32** %12
store i32** %4, i32*** %13
store i8** %5, i8*** %14
store i32* %6, i32** %15
store i32 0, i32* %17
%20 = load i8*, i8** %9
%21 = load i8, i8* %11
%22 = load i8*, i8** %10
%23 = getelementptr inbounds [10000 x i8*], [10000 x i8*]* %16, i64 0, i64 0
%24 = load i32*, i32** %12
%25 = load i32**, i32*** %13
%26 = load i8**, i8*** %14
%27 = call i32 @handleMessages(i8* %20, i8 zeroext %21, i8* %22, i8** %23, i32* %17, i32* %24, i32** %25, i8** %26)
store i32 %27, i32* %18
%28 = load i32, i32* %18
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %7
%31 = load i32, i32* %18
%32 = icmp ne i32 %31, 201
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = getelementptr inbounds [10000 x i8*], [10000 x i8*]* %16, i64 0, i64 0
%35 = load i32, i32* %17
%36 = call i32 @freeCommands(i8** %34, i32 %35)
%37 = load i32, i32* %18
store i32 %37, i32* %8
br label %51
38: ; preds = %30, %7
%39 = load i8**, i8*** %14
%40 = load i8*, i8** %39
%41 = getelementptr inbounds [10000 x i8*], [10000 x i8*]* %16, i64 0, i64 0
%42 = load i32, i32* %17
%43 = load i32*, i32** %15
%44 = call i32 @startNonBlockingBatch(i8* %40, i8** %41, i32 %42, i32* %43)
store i32 %44, i32* %19
%45 = load i32, i32* %19
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %38
%48 = load i32, i32* %19
store i32 %48, i32* %8
br label %51
49: ; preds = %38
%50 = load i32, i32* %18
store i32 %50, i32* %8
br label %51
51: ; preds = %49, %47, %33
%52 = load i32, i32* %8
ret i32 %52
}

LLVM IR (-O2):
define i32 @startHandleMessages(i8* %0, i8* %1, i8 zeroext %2, i32* %3, i32** %4, i8** %5, i32* %6) {
%8 = alloca [10000 x i8*]
%9 = alloca i32
%10 = bitcast [10000 x i8*]* %8 to i8*
%11 = bitcast i32* %9 to i8*
store i32 0, i32* %9
%12 = getelementptr inbounds [10000 x i8*], [10000 x i8*]* %8, i64 0, i64 0
%13 = call i32 @handleMessages(i8* %0, i8 zeroext %2, i8* %1, i8** %12, i32* %9, i32* %3, i32** %4, i8** %5)
switch i32 %13, label %14 [
i32 201, label %17
i32 0, label %17
]
14: ; preds = %7
%15 = load i32, i32* %9
%16 = call i32 @freeCommands(i8** %12, i32 %15)
br label %23
17: ; preds = %7, %7
%18 = load i8*, i8** %5
%19 = load i32, i32* %9
%20 = call i32 @startNonBlockingBatch(i8* %18, i8** %12, i32 %19, i32* %6)
%21 = icmp eq i32 %20, 0
%22 = select i1 %21, i32 %13, i32 %20
br label %23
23: ; preds = %17, %14
%24 = phi i32 [ %13, %14 ], [ %22, %17 ]
ret i32 %24
}