#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*/ delete_state(int);
int /*<<< orphan*/ delete_transition(int, char);
int find_equivalent(int);
int /*<<< orphan*/ hash_code(int);
int /*<<< orphan*/ insert(int, int /*<<< orphan*/);
int /*<<< orphan*/ path(char *, int *, int *);
int /*<<< orphan*/ set_transition(int, char, int);
void reduce(char *word, int length) {
  int i;
  int position;
  int current_state, state;
  int path_states[64];
  int path_states_length;
  path(word, path_states, &path_states_length);
  for (i = 1; path_states_length - i >= length; ++i) {
    position = path_states_length - i;
    current_state = path_states[position];
    state = find_equivalent(current_state);
    if (state != -1) {
      delete_state(current_state);
      delete_transition(path_states[position - 1], word[position - 1]);
      set_transition(path_states[position - 1], word[position - 1], state);
    } else
      insert(current_state, hash_code(current_state));
  }
}


x86 assembly (clang, -O0):
<reduce>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x120(%rbp),%rsi
lea    -0x124(%rbp),%rdx
call   1050 <path@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x124(%rbp),%eax
sub    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jl     126e <reduce+0xfe>
mov    -0x124(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
mov    -0x120(%rbp,%rax,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1080 <find_equivalent@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
je     123d <reduce+0xcd>
mov    -0x18(%rbp),%edi
call   1090 <delete_state@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x120(%rbp,%rax,4),%edi
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%esi
call   1030 <delete_transition@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x120(%rbp,%rax,4),%edi
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    -0x1c(%rbp),%edx
movsbl %al,%esi
call   1040 <set_transition@plt>
jmp    125b <reduce+0xeb>
mov    -0x18(%rbp),%eax
mov    %eax,-0x128(%rbp)
mov    -0x18(%rbp),%edi
call   1060 <hash_code@plt>
mov    -0x128(%rbp),%edi
mov    %eax,%esi
call   1070 <insert@plt>
jmp    1260 <reduce+0xf0>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a0 <reduce+0x30>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reduce>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %esi,%ebx
mov    %rdi,%r15
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <path@plt>
mov    0x8(%rsp),%eax
mov    %ebx,0xc(%rsp)
cmp    %ebx,%eax
jle    1232 <reduce+0xc2>
add    $0xffffffff,%eax
mov    $0x1,%ebp
mov    $0xffffffff,%r13d
jmp    11ef <reduce+0x7f>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebx,%edi
call   1060 <hash_code@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <insert@plt>
add    $0x1,%ebp
mov    0x8(%rsp),%eax
lea    (%rax,%r13,1),%ecx
add    $0xffffffff,%ecx
mov    %r13d,%edx
add    $0xffffffff,%edx
sub    %ebp,%eax
mov    %edx,%r13d
cmp    0xc(%rsp),%ecx
jl     1232 <reduce+0xc2>
movslq %eax,%r14
mov    0x10(%rsp,%r14,4),%ebx
mov    %ebx,%edi
call   1080 <find_equivalent@plt>
cmp    $0xffffffff,%eax
je     11c0 <reduce+0x50>
mov    %eax,%r12d
mov    %ebx,%edi
call   1090 <delete_state@plt>
mov    0xc(%rsp,%r14,4),%edi
movsbl -0x1(%r15,%r14,1),%esi
call   1030 <delete_transition@plt>
mov    0xc(%rsp,%r14,4),%edi
movsbl -0x1(%r15,%r14,1),%esi
mov    %r12d,%edx
call   1040 <set_transition@plt>
jmp    11d0 <reduce+0x60>
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @reduce(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [64 x i32]
%10 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%11 = load i8*, i8** %3
%12 = getelementptr inbounds [64 x i32], [64 x i32]* %9, i64 0, i64 0
%13 = call i32 @path(i8* %11, i32* %12, i32* %10)
store i32 1, i32* %5
br label %14
14: ; preds = %66, %2
%15 = load i32, i32* %10
%16 = load i32, i32* %5
%17 = sub nsw i32 %15, %16
%18 = load i32, i32* %4
%19 = icmp sge i32 %17, %18
br i1 %19, label %20, label %69
20: ; preds = %14
%21 = load i32, i32* %10
%22 = load i32, i32* %5
%23 = sub nsw i32 %21, %22
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [64 x i32], [64 x i32]* %9, i64 0, i64 %25
%27 = load i32, i32* %26
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = call i32 @find_equivalent(i32 %28)
store i32 %29, i32* %8
%30 = load i32, i32* %8
%31 = icmp ne i32 %30, -1
br i1 %31, label %32, label %60
32: ; preds = %20
%33 = load i32, i32* %7
%34 = call i32 @delete_state(i32 %33)
%35 = load i32, i32* %6
%36 = sub nsw i32 %35, 1
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [64 x i32], [64 x i32]* %9, i64 0, i64 %37
%39 = load i32, i32* %38
%40 = load i8*, i8** %3
%41 = load i32, i32* %6
%42 = sub nsw i32 %41, 1
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = load i8, i8* %44
%46 = call i32 @delete_transition(i32 %39, i8 signext %45)
%47 = load i32, i32* %6
%48 = sub nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [64 x i32], [64 x i32]* %9, i64 0, i64 %49
%51 = load i32, i32* %50
%52 = load i8*, i8** %3
%53 = load i32, i32* %6
%54 = sub nsw i32 %53, 1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %52, i64 %55
%57 = load i8, i8* %56
%58 = load i32, i32* %8
%59 = call i32 @set_transition(i32 %51, i8 signext %57, i32 %58)
br label %65
60: ; preds = %20
%61 = load i32, i32* %7
%62 = load i32, i32* %7
%63 = call i32 @hash_code(i32 %62)
%64 = call i32 @insert(i32 %61, i32 %63)
br label %65
65: ; preds = %60, %32
br label %66
66: ; preds = %65
%67 = load i32, i32* %5
%68 = add nsw i32 %67, 1
store i32 %68, i32* %5
br label %14
69: ; preds = %14
ret void
}

LLVM IR (-O2):
define void @reduce(i8* %0, i32 %1) {
%3 = alloca [64 x i32]
%4 = alloca i32
%5 = bitcast [64 x i32]* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 0
%8 = call i32 @path(i8* %0, i32* %7, i32* %4)
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, %1
br i1 %10, label %11, label %41
11: ; preds = %2
%12 = add nsw i32 %9, -1
br label %13
13: ; preds = %11, %36
%14 = phi i32 [ %39, %36 ], [ %12, %11 ]
%15 = phi i32 [ %37, %36 ], [ 1, %11 ]
%16 = sext i32 %14 to i64
%17 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 %16
%18 = load i32, i32* %17
%19 = call i32 @find_equivalent(i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %33, label %21
21: ; preds = %13
%22 = call i32 @delete_state(i32 %18)
%23 = add nsw i32 %14, -1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [64 x i32], [64 x i32]* %3, i64 0, i64 %24
%26 = load i32, i32* %25
%27 = getelementptr inbounds i8, i8* %0, i64 %24
%28 = load i8, i8* %27
%29 = call i32 @delete_transition(i32 %26, i8 signext %28)
%30 = load i32, i32* %25
%31 = load i8, i8* %27
%32 = call i32 @set_transition(i32 %30, i8 signext %31, i32 %19)
br label %36
33: ; preds = %13
%34 = call i32 @hash_code(i32 %18)
%35 = call i32 @insert(i32 %18, i32 %34)
br label %36
36: ; preds = %21, %33
%37 = add nuw nsw i32 %15, 1
%38 = load i32, i32* %4
%39 = sub nsw i32 %38, %37
%40 = icmp slt i32 %39, %1
br i1 %40, label %41, label %13
41: ; preds = %36, %2
ret void
}