#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 */
struct fsm *fsm_complement(struct fsm *);
struct fsm *fsm_concat(struct fsm *, struct fsm *);
int /*<<< orphan*/ fsm_copy(struct fsm *);
struct fsm *fsm_cross_product(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fsm_destroy(struct fsm *);
int /*<<< orphan*/ fsm_identity();
struct fsm *fsm_intersect(int /*<<< orphan*/, int /*<<< orphan*/);
struct fsm *fsm_kleene_plus(int /*<<< orphan*/);
struct fsm *fsm_kleene_star(struct fsm *);
struct fsm *fsm_minimize(struct fsm *);
struct fsm *fsm_universal();
struct fsm *fsm_simple_replace(struct fsm *net1, struct fsm *net2) {
  struct fsm *UPlus, *ret;
  UPlus = fsm_minimize(fsm_kleene_plus(fsm_identity()));
  ret = fsm_concat(
      fsm_minimize(fsm_kleene_star(fsm_minimize(fsm_concat(
          fsm_complement(fsm_minimize(fsm_concat(
              fsm_concat(
                  fsm_universal(),
                  fsm_minimize(fsm_intersect(fsm_copy(net1), fsm_copy(UPlus)))),
              fsm_universal()))),
          fsm_minimize(fsm_cross_product(fsm_copy(net1), fsm_copy(net2))))))),
      fsm_minimize(fsm_complement(fsm_minimize(
          fsm_concat(fsm_concat(fsm_universal(),
                                fsm_intersect(fsm_copy(net1), fsm_copy(UPlus))),
                     fsm_universal())))));
  fsm_destroy(net1);
  fsm_destroy(net2);
  fsm_destroy(UPlus);
  return (ret);
}


x86 assembly (clang, -O0):
<fsm_simple_replace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1090 <fsm_identity@plt>
mov    %eax,%edi
call   1030 <fsm_kleene_plus@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   10b0 <fsm_universal@plt>
mov    %rax,-0x60(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <fsm_copy@plt>
mov    %eax,-0x64(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fsm_copy@plt>
mov    -0x64(%rbp),%edi
mov    %eax,%esi
call   10c0 <fsm_intersect@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    -0x60(%rbp),%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,-0x58(%rbp)
mov    $0x0,%al
call   10b0 <fsm_universal@plt>
mov    -0x58(%rbp),%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rax,%rdi
call   1050 <fsm_complement@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <fsm_copy@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <fsm_copy@plt>
mov    -0x4c(%rbp),%edi
mov    %eax,%esi
call   10d0 <fsm_cross_product@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    -0x48(%rbp),%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rax,%rdi
call   1070 <fsm_kleene_star@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   10b0 <fsm_universal@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <fsm_copy@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fsm_copy@plt>
mov    -0x3c(%rbp),%edi
mov    %eax,%esi
call   10c0 <fsm_intersect@plt>
mov    -0x38(%rbp),%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   10b0 <fsm_universal@plt>
mov    -0x30(%rbp),%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rax,%rdi
call   1050 <fsm_complement@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <fsm_destroy@plt>
mov    -0x10(%rbp),%rdi
call   1080 <fsm_destroy@plt>
mov    -0x18(%rbp),%rdi
call   1080 <fsm_destroy@plt>
mov    -0x20(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsm_simple_replace>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r13
xor    %eax,%eax
call   1090 <fsm_identity@plt>
mov    %eax,%edi
call   1030 <fsm_kleene_plus@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rax,%r15
xor    %eax,%eax
call   10b0 <fsm_universal@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1060 <fsm_copy@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1060 <fsm_copy@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   10c0 <fsm_intersect@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   10b0 <fsm_universal@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rax,%rdi
call   1050 <fsm_complement@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1060 <fsm_copy@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1060 <fsm_copy@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   10d0 <fsm_cross_product@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rax,%rdi
call   1070 <fsm_kleene_star@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rax,%r12
xor    %eax,%eax
call   10b0 <fsm_universal@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1060 <fsm_copy@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1060 <fsm_copy@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   10c0 <fsm_intersect@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   10b0 <fsm_universal@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %rax,%rdi
call   1050 <fsm_complement@plt>
mov    %rax,%rdi
call   1040 <fsm_minimize@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   10a0 <fsm_concat@plt>
mov    %rax,%rbx
mov    %r13,%rdi
call   1080 <fsm_destroy@plt>
mov    %r14,%rdi
call   1080 <fsm_destroy@plt>
mov    %r15,%rdi
call   1080 <fsm_destroy@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.fsm = type { i32 }
define %struct.fsm* @fsm_simple_replace(%struct.fsm* %0, %struct.fsm* %1) {
%3 = alloca %struct.fsm*
%4 = alloca %struct.fsm*
%5 = alloca %struct.fsm*
%6 = alloca %struct.fsm*
store %struct.fsm* %0, %struct.fsm** %3
store %struct.fsm* %1, %struct.fsm** %4
%7 = call i32 (...) @fsm_identity()
%8 = call %struct.fsm* @fsm_kleene_plus(i32 %7)
%9 = call %struct.fsm* @fsm_minimize(%struct.fsm* %8)
store %struct.fsm* %9, %struct.fsm** %5
%10 = call %struct.fsm* (...) @fsm_universal()
%11 = load %struct.fsm*, %struct.fsm** %3
%12 = call i32 @fsm_copy(%struct.fsm* %11)
%13 = load %struct.fsm*, %struct.fsm** %5
%14 = call i32 @fsm_copy(%struct.fsm* %13)
%15 = call %struct.fsm* @fsm_intersect(i32 %12, i32 %14)
%16 = call %struct.fsm* @fsm_minimize(%struct.fsm* %15)
%17 = call %struct.fsm* @fsm_concat(%struct.fsm* %10, %struct.fsm* %16)
%18 = call %struct.fsm* (...) @fsm_universal()
%19 = call %struct.fsm* @fsm_concat(%struct.fsm* %17, %struct.fsm* %18)
%20 = call %struct.fsm* @fsm_minimize(%struct.fsm* %19)
%21 = call %struct.fsm* @fsm_complement(%struct.fsm* %20)
%22 = load %struct.fsm*, %struct.fsm** %3
%23 = call i32 @fsm_copy(%struct.fsm* %22)
%24 = load %struct.fsm*, %struct.fsm** %4
%25 = call i32 @fsm_copy(%struct.fsm* %24)
%26 = call %struct.fsm* @fsm_cross_product(i32 %23, i32 %25)
%27 = call %struct.fsm* @fsm_minimize(%struct.fsm* %26)
%28 = call %struct.fsm* @fsm_concat(%struct.fsm* %21, %struct.fsm* %27)
%29 = call %struct.fsm* @fsm_minimize(%struct.fsm* %28)
%30 = call %struct.fsm* @fsm_kleene_star(%struct.fsm* %29)
%31 = call %struct.fsm* @fsm_minimize(%struct.fsm* %30)
%32 = call %struct.fsm* (...) @fsm_universal()
%33 = load %struct.fsm*, %struct.fsm** %3
%34 = call i32 @fsm_copy(%struct.fsm* %33)
%35 = load %struct.fsm*, %struct.fsm** %5
%36 = call i32 @fsm_copy(%struct.fsm* %35)
%37 = call %struct.fsm* @fsm_intersect(i32 %34, i32 %36)
%38 = call %struct.fsm* @fsm_concat(%struct.fsm* %32, %struct.fsm* %37)
%39 = call %struct.fsm* (...) @fsm_universal()
%40 = call %struct.fsm* @fsm_concat(%struct.fsm* %38, %struct.fsm* %39)
%41 = call %struct.fsm* @fsm_minimize(%struct.fsm* %40)
%42 = call %struct.fsm* @fsm_complement(%struct.fsm* %41)
%43 = call %struct.fsm* @fsm_minimize(%struct.fsm* %42)
%44 = call %struct.fsm* @fsm_concat(%struct.fsm* %31, %struct.fsm* %43)
store %struct.fsm* %44, %struct.fsm** %6
%45 = load %struct.fsm*, %struct.fsm** %3
%46 = call i32 @fsm_destroy(%struct.fsm* %45)
%47 = load %struct.fsm*, %struct.fsm** %4
%48 = call i32 @fsm_destroy(%struct.fsm* %47)
%49 = load %struct.fsm*, %struct.fsm** %5
%50 = call i32 @fsm_destroy(%struct.fsm* %49)
%51 = load %struct.fsm*, %struct.fsm** %6
ret %struct.fsm* %51
}

LLVM IR (-O2):
%struct.fsm = type { i32 }
define %struct.fsm* @fsm_simple_replace(%struct.fsm* %0, %struct.fsm* %1) {
%3 = tail call i32 (...) @fsm_identity()
%4 = tail call %struct.fsm* @fsm_kleene_plus(i32 %3)
%5 = tail call %struct.fsm* @fsm_minimize(%struct.fsm* %4)
%6 = tail call %struct.fsm* (...) @fsm_universal()
%7 = tail call i32 @fsm_copy(%struct.fsm* %0)
%8 = tail call i32 @fsm_copy(%struct.fsm* %5)
%9 = tail call %struct.fsm* @fsm_intersect(i32 %7, i32 %8)
%10 = tail call %struct.fsm* @fsm_minimize(%struct.fsm* %9)
%11 = tail call %struct.fsm* @fsm_concat(%struct.fsm* %6, %struct.fsm* %10)
%12 = tail call %struct.fsm* (...) @fsm_universal()
%13 = tail call %struct.fsm* @fsm_concat(%struct.fsm* %11, %struct.fsm* %12)
%14 = tail call %struct.fsm* @fsm_minimize(%struct.fsm* %13)
%15 = tail call %struct.fsm* @fsm_complement(%struct.fsm* %14)
%16 = tail call i32 @fsm_copy(%struct.fsm* %0)
%17 = tail call i32 @fsm_copy(%struct.fsm* %1)
%18 = tail call %struct.fsm* @fsm_cross_product(i32 %16, i32 %17)
%19 = tail call %struct.fsm* @fsm_minimize(%struct.fsm* %18)
%20 = tail call %struct.fsm* @fsm_concat(%struct.fsm* %15, %struct.fsm* %19)
%21 = tail call %struct.fsm* @fsm_minimize(%struct.fsm* %20)
%22 = tail call %struct.fsm* @fsm_kleene_star(%struct.fsm* %21)
%23 = tail call %struct.fsm* @fsm_minimize(%struct.fsm* %22)
%24 = tail call %struct.fsm* (...) @fsm_universal()
%25 = tail call i32 @fsm_copy(%struct.fsm* %0)
%26 = tail call i32 @fsm_copy(%struct.fsm* %5)
%27 = tail call %struct.fsm* @fsm_intersect(i32 %25, i32 %26)
%28 = tail call %struct.fsm* @fsm_concat(%struct.fsm* %24, %struct.fsm* %27)
%29 = tail call %struct.fsm* (...) @fsm_universal()
%30 = tail call %struct.fsm* @fsm_concat(%struct.fsm* %28, %struct.fsm* %29)
%31 = tail call %struct.fsm* @fsm_minimize(%struct.fsm* %30)
%32 = tail call %struct.fsm* @fsm_complement(%struct.fsm* %31)
%33 = tail call %struct.fsm* @fsm_minimize(%struct.fsm* %32)
%34 = tail call %struct.fsm* @fsm_concat(%struct.fsm* %23, %struct.fsm* %33)
%35 = tail call i32 @fsm_destroy(%struct.fsm* %0)
%36 = tail call i32 @fsm_destroy(%struct.fsm* %1)
%37 = tail call i32 @fsm_destroy(%struct.fsm* %5)
ret %struct.fsm* %34
}