#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 getNextState(char *, int, int, int);
void computeTransitionFunction(char *pattern, int A,
                               int TransitionFunction[][256]) {
  int state, x;
  for (state = 0; state <= A; ++state)
    for (x = 0; x < 256; ++x)
      TransitionFunction[state][x] = getNextState(pattern, A, state, x);
}


x86 assembly (clang, -O0):
<computeTransitionFunction>:
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     1195 <computeTransitionFunction+0x85>
movl   $0x0,-0x20(%rbp)
cmpl   $0x100,-0x20(%rbp)
jge    1182 <computeTransitionFunction+0x72>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1030 <getNextState@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
shl    $0xa,%rcx
add    %rcx,%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    113d <computeTransitionFunction+0x2d>
jmp    1187 <computeTransitionFunction+0x77>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112a <computeTransitionFunction+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

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

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

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