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


x86 assembly (clang, -O0):
<executeHandleMessages>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138e0,%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)
movq   $0x0,-0x138c0(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x19(%rbp),%sil
mov    -0x18(%rbp),%rdx
lea    -0x138b0(%rbp),%rcx
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%r10
lea    -0x138b4(%rbp),%r8
lea    -0x138c0(%rbp),%rax
movzbl %sil,%esi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <handleMessages@plt>
mov    %eax,-0x138c4(%rbp)
cmpl   $0x0,-0x138c4(%rbp)
je     11e3 <executeHandleMessages+0xb3>
cmpl   $0xc9,-0x138c4(%rbp)
je     11e3 <executeHandleMessages+0xb3>
lea    -0x138b0(%rbp),%rdi
mov    -0x138b4(%rbp),%esi
call   1050 <freeCommands@plt>
mov    -0x138c4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1226 <executeHandleMessages+0xf6>
mov    -0x138c0(%rbp),%rdi
lea    -0x138b0(%rbp),%rsi
mov    -0x138b4(%rbp),%edx
call   1030 <executeBatch@plt>
mov    %eax,-0x138c8(%rbp)
cmpl   $0x0,-0x138c8(%rbp)
je     121d <executeHandleMessages+0xed>
mov    -0x138c8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1226 <executeHandleMessages+0xf6>
mov    -0x138c4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x138e0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executeHandleMessages>:
push   %rbx
sub    $0x13890,%rsp
mov    %r8,%rax
mov    %rcx,%r9
mov    %rsi,%rbx
movl   $0x0,0x4(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%r10
lea    0x10(%rsp),%rcx
lea    0x4(%rsp),%r8
mov    %edx,%esi
mov    %rbx,%rdx
push   %r10
push   %rax
call   1040 <handleMessages@plt>
add    $0x10,%rsp
mov    %eax,%ebx
test   %eax,%eax
je     1180 <executeHandleMessages+0x50>
cmp    $0xc9,%ebx
jne    119a <executeHandleMessages+0x6a>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%edx
lea    0x10(%rsp),%rsi
call   1030 <executeBatch@plt>
test   %eax,%eax
cmovne %eax,%ebx
jmp    11a8 <executeHandleMessages+0x78>
mov    0x4(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1050 <freeCommands@plt>
mov    %ebx,%eax
add    $0x13890,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
define i32 @executeHandleMessages(i8* %0, i8* %1, i8 zeroext %2, i32* %3, i32** %4) {
%6 = alloca [10000 x i8*]
%7 = alloca i32
%8 = alloca i8*
%9 = bitcast [10000 x i8*]* %6 to i8*
%10 = bitcast i32* %7 to i8*
store i32 0, i32* %7
%11 = bitcast i8** %8 to i8*
store i8* null, i8** %8
%12 = getelementptr inbounds [10000 x i8*], [10000 x i8*]* %6, i64 0, i64 0
%13 = call i32 @handleMessages(i8* %0, i8 zeroext %2, i8* %1, i8** %12, i32* %7, i32* %3, i32** %4, i8** %8)
switch i32 %13, label %14 [
i32 201, label %17
i32 0, label %17
]
14: ; preds = %5
%15 = load i32, i32* %7
%16 = call i32 @freeCommands(i8** %12, i32 %15)
br label %23
17: ; preds = %5, %5
%18 = load i8*, i8** %8
%19 = load i32, i32* %7
%20 = call i32 @executeBatch(i8* %18, i8** %12, i32 %19)
%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
}