#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 handleMessage(void *, int /*<<< orphan*/ *, char *, unsigned char,
                           char **, unsigned int *, void **);
unsigned int startNonBlockingBatch(void *, char **, unsigned int,
                                   unsigned int *);
unsigned int startHandleMessage(void *handle, char *message,
                                unsigned char actionType, void **rulesBinding,
                                unsigned int *replyCount) {
  char *commands[10000];
  unsigned int commandCount = 0;
  unsigned int result = handleMessage(handle, NULL, message, actionType,
                                      commands, &commandCount, 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):
<startHandleMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138d0,%rsp
mov    %dl,%al
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
movl   $0x0,-0x138b4(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x19(%rbp),%cl
lea    -0x138b0(%rbp),%r8
mov    -0x28(%rbp),%rax
xor    %esi,%esi
lea    -0x138b4(%rbp),%r9
movzbl %cl,%ecx
mov    %rax,(%rsp)
call   1030 <handleMessage@plt>
mov    %eax,-0x138b8(%rbp)
cmpl   $0x0,-0x138b8(%rbp)
je     11c8 <startHandleMessage+0x98>
cmpl   $0xc9,-0x138b8(%rbp)
je     11c8 <startHandleMessage+0x98>
lea    -0x138b0(%rbp),%rdi
mov    -0x138b4(%rbp),%esi
call   1050 <freeCommands@plt>
mov    -0x138b8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120f <startHandleMessage+0xdf>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
lea    -0x138b0(%rbp),%rsi
mov    -0x138b4(%rbp),%edx
mov    -0x30(%rbp),%rcx
call   1040 <startNonBlockingBatch@plt>
mov    %eax,-0x138bc(%rbp)
cmpl   $0x0,-0x138bc(%rbp)
je     1206 <startHandleMessage+0xd6>
mov    -0x138bc(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    120f <startHandleMessage+0xdf>
mov    -0x138b8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x138d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<startHandleMessage>:
push   %rbp
push   %r14
push   %rbx
sub    $0x13890,%rsp
mov    %r8,%r14
mov    %rcx,%rbx
mov    %edx,%ecx
mov    %rsi,%rdx
movl   $0x0,0xc(%rsp)
mov    %rbx,(%rsp)
lea    0x10(%rsp),%r8
lea    0xc(%rsp),%r9
xor    %esi,%esi
call   1030 <handleMessage@plt>
mov    %eax,%ebp
test   %eax,%eax
je     1171 <startHandleMessage+0x41>
cmp    $0xc9,%ebp
jne    118c <startHandleMessage+0x5c>
mov    (%rbx),%rdi
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%rsi
mov    %r14,%rcx
call   1040 <startNonBlockingBatch@plt>
test   %eax,%eax
cmovne %eax,%ebp
jmp    119a <startHandleMessage+0x6a>
mov    0xc(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1050 <freeCommands@plt>
mov    %ebp,%eax
add    $0x13890,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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