#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 */
struct fsm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fsm_compose(struct fsm *, int /*<<< orphan*/);
int /*<<< orphan*/ fsm_concat(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fsm_intersect(struct fsm *, struct fsm *);
struct fsm *fsm_kleene_star(int /*<<< orphan*/);
int /*<<< orphan*/ fsm_lower(int /*<<< orphan*/);
struct fsm *fsm_minimize(int /*<<< orphan*/);
int /*<<< orphan*/ fsm_parse_regex(char *, int /*<<< orphan*/ *,
                                   int /*<<< orphan*/ *);
int /*<<< orphan*/ fsm_substitute_symbol(struct fsm *, char *, char *);
int /*<<< orphan*/ fsm_symbol(char *);
int /*<<< orphan*/ rewrite_tape_m_to_n_of_k(struct fsm *, int, int, int);
struct fsm *rewrite_align_markup(struct fsm *upper, struct fsm *lower1,
                                 struct fsm *lower2) {
  struct fsm *first, *second, *third, *fourth, *fifth, *sixth, *align, *align2;
  first = fsm_minimize(
      rewrite_tape_m_to_n_of_k(fsm_kleene_star(fsm_symbol("@0@")), 1, 1, 2));
  second = fsm_minimize(rewrite_tape_m_to_n_of_k(lower1, 2, 2, 2));
  third = fsm_minimize(rewrite_tape_m_to_n_of_k(upper, 1, 1, 2));
  fourth = fsm_minimize(
      rewrite_tape_m_to_n_of_k(fsm_kleene_star(fsm_symbol("@ID@")), 2, 2, 2));
  fifth = fsm_minimize(
      rewrite_tape_m_to_n_of_k(fsm_kleene_star(fsm_symbol("@0@")), 1, 1, 2));
  sixth = fsm_minimize(rewrite_tape_m_to_n_of_k(lower2, 2, 2, 2));
  align = fsm_minimize(fsm_concat(
      fsm_intersect(first, second),
      fsm_concat(fsm_intersect(third, fourth), fsm_intersect(fifth, sixth))));
  align = fsm_minimize(
      fsm_substitute_symbol(align, "@_IDENTITY_SYMBOL_@", "@UNK@"));
  align2 = fsm_minimize(fsm_lower(fsm_compose(
      align,
      fsm_parse_regex("[? ? | \"@UNK@\" \"@UNK@\":\"@ID@\" ]*", NULL, NULL))));
  align2 = fsm_minimize(
      fsm_substitute_symbol(align2, "@UNK@", "@_IDENTITY_SYMBOL_@"));
  return align2;
}


x86 assembly (clang, -O0):
<rewrite_align_markup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xe45(%rip),%rdi
call   1050 <fsm_symbol@plt>
mov    %eax,%edi
call   1040 <fsm_kleene_star@plt>
mov    %rax,%rdi
mov    $0x1,%edx
mov    $0x2,%ecx
mov    %edx,%esi
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x1,%edx
mov    $0x2,%ecx
mov    %edx,%esi
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,-0x30(%rbp)
lea    0xdda(%rip),%rdi
call   1050 <fsm_symbol@plt>
mov    %eax,%edi
call   1040 <fsm_kleene_star@plt>
mov    %rax,%rdi
mov    $0x2,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,-0x38(%rbp)
lea    0xda7(%rip),%rdi
call   1050 <fsm_symbol@plt>
mov    %eax,%edi
call   1040 <fsm_kleene_star@plt>
mov    %rax,%rdi
mov    $0x1,%edx
mov    $0x2,%ecx
mov    %edx,%esi
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2,%ecx
mov    %ecx,%esi
mov    %ecx,%edx
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10b0 <fsm_intersect@plt>
mov    %eax,-0x64(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   10b0 <fsm_intersect@plt>
mov    %eax,-0x68(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   10b0 <fsm_intersect@plt>
mov    -0x68(%rbp),%edi
mov    %eax,%esi
call   1070 <fsm_concat@plt>
mov    -0x64(%rbp),%edi
mov    %eax,%esi
call   1070 <fsm_concat@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    0xd11(%rip),%rsi
lea    0xd1e(%rip),%rdx
call   10c0 <fsm_substitute_symbol@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    0xd05(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    %rdx,%rsi
call   1090 <fsm_parse_regex@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%esi
call   10a0 <fsm_compose@plt>
mov    %eax,%edi
call   1080 <fsm_lower@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
lea    0xccb(%rip),%rsi
lea    0xcb0(%rip),%rdx
call   10c0 <fsm_substitute_symbol@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rewrite_align_markup>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xe40(%rip),%r12
mov    %r12,%rdi
call   1050 <fsm_symbol@plt>
mov    %eax,%edi
call   1040 <fsm_kleene_star@plt>
mov    %rax,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,0x8(%rsp)
mov    %rbp,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,%r15
lea    0xdc9(%rip),%rdi
call   1050 <fsm_symbol@plt>
mov    %eax,%edi
call   1040 <fsm_kleene_star@plt>
mov    %rax,%rdi
mov    $0x2,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,%r14
mov    %r12,%rdi
call   1050 <fsm_symbol@plt>
mov    %eax,%edi
call   1040 <fsm_kleene_star@plt>
mov    %rax,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x2,%ecx
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,%r12
mov    0x10(%rsp),%rdi
mov    $0x2,%esi
mov    $0x2,%edx
mov    $0x2,%ecx
call   1060 <rewrite_tape_m_to_n_of_k@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,%rbp
mov    0x8(%rsp),%rdi
mov    %r13,%rsi
call   10b0 <fsm_intersect@plt>
mov    %eax,%r13d
mov    %r15,%rdi
mov    %r14,%rsi
call   10b0 <fsm_intersect@plt>
mov    %eax,%ebx
mov    %r12,%rdi
mov    %rbp,%rsi
call   10b0 <fsm_intersect@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1070 <fsm_concat@plt>
mov    %r13d,%edi
mov    %eax,%esi
call   1070 <fsm_concat@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
lea    0xd05(%rip),%r14
lea    0xd12(%rip),%rbp
mov    %rax,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   10c0 <fsm_substitute_symbol@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,%rbx
lea    0xcf9(%rip),%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1090 <fsm_parse_regex@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   10a0 <fsm_compose@plt>
mov    %eax,%edi
call   1080 <fsm_lower@plt>
mov    %eax,%edi
call   1030 <fsm_minimize@plt>
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   10c0 <fsm_substitute_symbol@plt>
mov    %eax,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fsm_minimize@plt>

LLVM IR (-O0):
%struct.fsm = type { i32 }
@.str = [4 x i8] c"@0@\00"
@.str.1 = [5 x i8] c"@ID@\00"
@.str.2 = [20 x i8] c"@_IDENTITY_SYMBOL_@\00"
@.str.3 = [6 x i8] c"@UNK@\00"
@.str.4 = [33 x i8] c"[? ? | \22@UNK@\22 \22@UNK@\22:\22@ID@\22 ]*\00"
define %struct.fsm* @rewrite_align_markup(%struct.fsm* %0, %struct.fsm* %1, %struct.fsm* %2) {
%4 = alloca %struct.fsm*
%5 = alloca %struct.fsm*
%6 = alloca %struct.fsm*
%7 = alloca %struct.fsm*
%8 = alloca %struct.fsm*
%9 = alloca %struct.fsm*
%10 = alloca %struct.fsm*
%11 = alloca %struct.fsm*
%12 = alloca %struct.fsm*
%13 = alloca %struct.fsm*
%14 = alloca %struct.fsm*
store %struct.fsm* %0, %struct.fsm** %4
store %struct.fsm* %1, %struct.fsm** %5
store %struct.fsm* %2, %struct.fsm** %6
%15 = call i32 @fsm_symbol(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%16 = call %struct.fsm* @fsm_kleene_star(i32 %15)
%17 = call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %16, i32 1, i32 1, i32 2)
%18 = call %struct.fsm* @fsm_minimize(i32 %17)
store %struct.fsm* %18, %struct.fsm** %7
%19 = load %struct.fsm*, %struct.fsm** %5
%20 = call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %19, i32 2, i32 2, i32 2)
%21 = call %struct.fsm* @fsm_minimize(i32 %20)
store %struct.fsm* %21, %struct.fsm** %8
%22 = load %struct.fsm*, %struct.fsm** %4
%23 = call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %22, i32 1, i32 1, i32 2)
%24 = call %struct.fsm* @fsm_minimize(i32 %23)
store %struct.fsm* %24, %struct.fsm** %9
%25 = call i32 @fsm_symbol(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%26 = call %struct.fsm* @fsm_kleene_star(i32 %25)
%27 = call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %26, i32 2, i32 2, i32 2)
%28 = call %struct.fsm* @fsm_minimize(i32 %27)
store %struct.fsm* %28, %struct.fsm** %10
%29 = call i32 @fsm_symbol(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%30 = call %struct.fsm* @fsm_kleene_star(i32 %29)
%31 = call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %30, i32 1, i32 1, i32 2)
%32 = call %struct.fsm* @fsm_minimize(i32 %31)
store %struct.fsm* %32, %struct.fsm** %11
%33 = load %struct.fsm*, %struct.fsm** %6
%34 = call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %33, i32 2, i32 2, i32 2)
%35 = call %struct.fsm* @fsm_minimize(i32 %34)
store %struct.fsm* %35, %struct.fsm** %12
%36 = load %struct.fsm*, %struct.fsm** %7
%37 = load %struct.fsm*, %struct.fsm** %8
%38 = call i32 @fsm_intersect(%struct.fsm* %36, %struct.fsm* %37)
%39 = load %struct.fsm*, %struct.fsm** %9
%40 = load %struct.fsm*, %struct.fsm** %10
%41 = call i32 @fsm_intersect(%struct.fsm* %39, %struct.fsm* %40)
%42 = load %struct.fsm*, %struct.fsm** %11
%43 = load %struct.fsm*, %struct.fsm** %12
%44 = call i32 @fsm_intersect(%struct.fsm* %42, %struct.fsm* %43)
%45 = call i32 @fsm_concat(i32 %41, i32 %44)
%46 = call i32 @fsm_concat(i32 %38, i32 %45)
%47 = call %struct.fsm* @fsm_minimize(i32 %46)
store %struct.fsm* %47, %struct.fsm** %13
%48 = load %struct.fsm*, %struct.fsm** %13
%49 = call i32 @fsm_substitute_symbol(%struct.fsm* %48, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%50 = call %struct.fsm* @fsm_minimize(i32 %49)
store %struct.fsm* %50, %struct.fsm** %13
%51 = load %struct.fsm*, %struct.fsm** %13
%52 = call i32 @fsm_parse_regex(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32* null, i32* null)
%53 = call i32 @fsm_compose(%struct.fsm* %51, i32 %52)
%54 = call i32 @fsm_lower(i32 %53)
%55 = call %struct.fsm* @fsm_minimize(i32 %54)
store %struct.fsm* %55, %struct.fsm** %14
%56 = load %struct.fsm*, %struct.fsm** %14
%57 = call i32 @fsm_substitute_symbol(%struct.fsm* %56, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%58 = call %struct.fsm* @fsm_minimize(i32 %57)
store %struct.fsm* %58, %struct.fsm** %14
%59 = load %struct.fsm*, %struct.fsm** %14
ret %struct.fsm* %59
}

LLVM IR (-O2):
%struct.fsm = type { i32 }
@.str = [4 x i8] c"@0@\00"
@.str.1 = [5 x i8] c"@ID@\00"
@.str.2 = [20 x i8] c"@_IDENTITY_SYMBOL_@\00"
@.str.3 = [6 x i8] c"@UNK@\00"
@.str.4 = [33 x i8] c"[? ? | \22@UNK@\22 \22@UNK@\22:\22@ID@\22 ]*\00"
define %struct.fsm* @rewrite_align_markup(%struct.fsm* %0, %struct.fsm* %1, %struct.fsm* %2) {
%4 = tail call i32 @fsm_symbol(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%5 = tail call %struct.fsm* @fsm_kleene_star(i32 %4)
%6 = tail call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %5, i32 1, i32 1, i32 2)
%7 = tail call %struct.fsm* @fsm_minimize(i32 %6)
%8 = tail call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %1, i32 2, i32 2, i32 2)
%9 = tail call %struct.fsm* @fsm_minimize(i32 %8)
%10 = tail call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %0, i32 1, i32 1, i32 2)
%11 = tail call %struct.fsm* @fsm_minimize(i32 %10)
%12 = tail call i32 @fsm_symbol(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call %struct.fsm* @fsm_kleene_star(i32 %12)
%14 = tail call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %13, i32 2, i32 2, i32 2)
%15 = tail call %struct.fsm* @fsm_minimize(i32 %14)
%16 = tail call i32 @fsm_symbol(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%17 = tail call %struct.fsm* @fsm_kleene_star(i32 %16)
%18 = tail call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %17, i32 1, i32 1, i32 2)
%19 = tail call %struct.fsm* @fsm_minimize(i32 %18)
%20 = tail call i32 @rewrite_tape_m_to_n_of_k(%struct.fsm* %2, i32 2, i32 2, i32 2)
%21 = tail call %struct.fsm* @fsm_minimize(i32 %20)
%22 = tail call i32 @fsm_intersect(%struct.fsm* %7, %struct.fsm* %9)
%23 = tail call i32 @fsm_intersect(%struct.fsm* %11, %struct.fsm* %15)
%24 = tail call i32 @fsm_intersect(%struct.fsm* %19, %struct.fsm* %21)
%25 = tail call i32 @fsm_concat(i32 %23, i32 %24)
%26 = tail call i32 @fsm_concat(i32 %22, i32 %25)
%27 = tail call %struct.fsm* @fsm_minimize(i32 %26)
%28 = tail call i32 @fsm_substitute_symbol(%struct.fsm* %27, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%29 = tail call %struct.fsm* @fsm_minimize(i32 %28)
%30 = tail call i32 @fsm_parse_regex(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32* null, i32* null)
%31 = tail call i32 @fsm_compose(%struct.fsm* %29, i32 %30)
%32 = tail call i32 @fsm_lower(i32 %31)
%33 = tail call %struct.fsm* @fsm_minimize(i32 %32)
%34 = tail call i32 @fsm_substitute_symbol(%struct.fsm* %33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%35 = tail call %struct.fsm* @fsm_minimize(i32 %34)
ret %struct.fsm* %35
}