#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 am_nextstate(char const *, int, int, int);
void am_table(const char *term, int term_len, int **table) {
  int state, x;
  for (state = 0; state <= term_len; ++state)
    for (x = 0; x < 256; ++x)
      table[state][x] = am_nextstate(term, term_len, state, x);
}


x86 assembly (clang, -O0):
<am_table>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1192 <am_table+0x82>
movl   $0x0,-0x20(%rbp)
cmpl   $0x100,-0x20(%rbp)
jge    117f <am_table+0x6f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1030 <am_nextstate@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <am_table+0x2d>
jmp    1184 <am_table+0x74>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <am_table+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<am_table>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
js     116d <am_table+0x5d>
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%r12
lea    0x1(%r15),%ebp
xor    %r13d,%r13d
nop
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rdi
mov    %r15d,%esi
mov    %r13d,%edx
mov    %ebx,%ecx
call   1030 <am_nextstate@plt>
mov    (%r14,%r13,8),%rcx
mov    %eax,(%rcx,%rbx,4)
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    1140 <am_table+0x30>
add    $0x1,%r13
cmp    %rbp,%r13
jne    1130 <am_table+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @am_table(i8* %0, i32 %1, i32** %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32**
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32** %2, i32*** %6
store i32 0, i32* %7
br label %9
9: ; preds = %35, %3
%10 = load i32, i32* %7
%11 = load i32, i32* %5
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %38
13: ; preds = %9
store i32 0, i32* %8
br label %14
14: ; preds = %31, %13
%15 = load i32, i32* %8
%16 = icmp slt i32 %15, 256
br i1 %16, label %17, label %34
17: ; preds = %14
%18 = load i8*, i8** %4
%19 = load i32, i32* %5
%20 = load i32, i32* %7
%21 = load i32, i32* %8
%22 = call i32 @am_nextstate(i8* %18, i32 %19, i32 %20, i32 %21)
%23 = load i32**, i32*** %6
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32*, i32** %23, i64 %25
%27 = load i32*, i32** %26
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
store i32 %22, i32* %30
br label %31
31: ; preds = %17
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %14
34: ; preds = %14
br label %35
35: ; preds = %34
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %9
38: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @am_table(i8* %0, i32 %1, i32** nocapture %2) {
%4 = icmp slt i32 %1, 0
br i1 %4, label %23, label %5
5: ; preds = %3
%6 = add nuw i32 %1, 1
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %5, %20
%9 = phi i64 [ 0, %5 ], [ %21, %20 ]
%10 = getelementptr inbounds i32*, i32** %2, i64 %9
%11 = trunc i64 %9 to i32
br label %12
12: ; preds = %8, %12
%13 = phi i64 [ 0, %8 ], [ %18, %12 ]
%14 = trunc i64 %13 to i32
%15 = tail call i32 @am_nextstate(i8* %0, i32 %1, i32 %11, i32 %14)
%16 = load i32*, i32** %10
%17 = getelementptr inbounds i32, i32* %16, i64 %13
store i32 %15, i32* %17
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, 256
br i1 %19, label %20, label %12
20: ; preds = %12
%21 = add nuw nsw i64 %9, 1
%22 = icmp eq i64 %21, %7
br i1 %22, label %23, label %8
23: ; preds = %20, %3
ret void
}