#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 handleState(void *, char *, char **, unsigned int *, void **);
unsigned int assertState(void *handle, char *state) {
  char *commands[10000];
  unsigned int commandCount = 0;
  void *rulesBinding = NULL;
  unsigned int result =
      handleState(handle, state, commands, &commandCount, &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):
<assertState>:
push   %rbp
mov    %rsp,%rbp
sub    $0x138c0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x138a4(%rbp)
movq   $0x0,-0x138b0(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x138a0(%rbp),%rdx
lea    -0x138a4(%rbp),%rcx
lea    -0x138b0(%rbp),%r8
call   1050 <handleState@plt>
mov    %eax,-0x138b4(%rbp)
cmpl   $0x0,-0x138b4(%rbp)
je     11bd <assertState+0x8d>
cmpl   $0xc9,-0x138b4(%rbp)
je     11bd <assertState+0x8d>
lea    -0x138a0(%rbp),%rdi
mov    -0x138a4(%rbp),%esi
call   1040 <freeCommands@plt>
mov    -0x138b4(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1200 <assertState+0xd0>
mov    -0x138b0(%rbp),%rdi
lea    -0x138a0(%rbp),%rsi
mov    -0x138a4(%rbp),%edx
call   1030 <executeBatch@plt>
mov    %eax,-0x138b8(%rbp)
cmpl   $0x0,-0x138b8(%rbp)
je     11f7 <assertState+0xc7>
mov    -0x138b8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1200 <assertState+0xd0>
mov    -0x138b4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x138c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<assertState>:
push   %rbx
sub    $0x13890,%rsp
movl   $0x0,0x4(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rdx
lea    0x4(%rsp),%rcx
lea    0x8(%rsp),%r8
call   1050 <handleState@plt>
mov    %eax,%ebx
test   %eax,%eax
je     116b <assertState+0x3b>
cmp    $0xc9,%ebx
jne    1185 <assertState+0x55>
mov    0x8(%rsp),%rdi
mov    0x4(%rsp),%edx
lea    0x10(%rsp),%rsi
call   1030 <executeBatch@plt>
test   %eax,%eax
cmovne %eax,%ebx
jmp    1193 <assertState+0x63>
mov    0x4(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1040 <freeCommands@plt>
mov    %ebx,%eax
add    $0x13890,%rsp
pop    %rbx
ret

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

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