#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_compact(struct fsm *);
int /*<<< orphan*/ fsm_compose(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fsm_copy(struct fsm *);
int /*<<< orphan*/ fsm_destroy(struct fsm *);
int /*<<< orphan*/ fsm_extract_nonidentity(int /*<<< orphan*/);
int /*<<< orphan*/ fsm_invert(int /*<<< orphan*/);
struct fsm *fsm_lowerdet(struct fsm *);
int /*<<< orphan*/ fsm_minimize(int /*<<< orphan*/);
struct fsm *fsm_topsort(int /*<<< orphan*/);
int /*<<< orphan*/ fsm_upper(int /*<<< orphan*/);
int /*<<< orphan*/ sigma_cleanup(struct fsm *, int);
int /*<<< orphan*/ sigma_sort(struct fsm *);
struct fsm *fsm_extract_ambiguous_domain(struct fsm *net) {
  struct fsm *loweruniqnet, *result;
  loweruniqnet = fsm_lowerdet(net);
  result = fsm_topsort(fsm_minimize(fsm_upper(fsm_compose(
      fsm_copy(loweruniqnet),
      fsm_extract_nonidentity(fsm_compose(fsm_invert(fsm_copy(loweruniqnet)),
                                          fsm_copy(loweruniqnet)))))));
  fsm_destroy(loweruniqnet);
  sigma_cleanup(result, 1);
  fsm_compact(result);
  sigma_sort(result);
  return (result);
}


x86 assembly (clang, -O0):
<fsm_extract_ambiguous_domain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1090 <fsm_lowerdet@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fsm_copy@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fsm_copy@plt>
mov    %eax,%edi
call   10a0 <fsm_invert@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <fsm_copy@plt>
mov    -0x20(%rbp),%edi
mov    %eax,%esi
call   10c0 <fsm_compose@plt>
mov    %eax,%edi
call   1030 <fsm_extract_nonidentity@plt>
mov    -0x1c(%rbp),%edi
mov    %eax,%esi
call   10c0 <fsm_compose@plt>
mov    %eax,%edi
call   10e0 <fsm_upper@plt>
mov    %eax,%edi
call   1040 <fsm_minimize@plt>
mov    %eax,%edi
call   10b0 <fsm_topsort@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1080 <fsm_destroy@plt>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   10d0 <sigma_cleanup@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fsm_compact@plt>
mov    -0x18(%rbp),%rdi
call   1070 <sigma_sort@plt>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fsm_extract_ambiguous_domain>:
push   %rbp
push   %r14
push   %rbx
call   1090 <fsm_lowerdet@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1050 <fsm_copy@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1050 <fsm_copy@plt>
mov    %eax,%edi
call   10a0 <fsm_invert@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1050 <fsm_copy@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   10c0 <fsm_compose@plt>
mov    %eax,%edi
call   1030 <fsm_extract_nonidentity@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   10c0 <fsm_compose@plt>
mov    %eax,%edi
call   10e0 <fsm_upper@plt>
mov    %eax,%edi
call   1040 <fsm_minimize@plt>
mov    %eax,%edi
call   10b0 <fsm_topsort@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1080 <fsm_destroy@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
call   10d0 <sigma_cleanup@plt>
mov    %rbp,%rdi
call   1060 <fsm_compact@plt>
mov    %rbp,%rdi
call   1070 <sigma_sort@plt>
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.fsm = type { i32 }
define %struct.fsm* @fsm_extract_ambiguous_domain(%struct.fsm* %0) {
%2 = alloca %struct.fsm*
%3 = alloca %struct.fsm*
%4 = alloca %struct.fsm*
store %struct.fsm* %0, %struct.fsm** %2
%5 = load %struct.fsm*, %struct.fsm** %2
%6 = call %struct.fsm* @fsm_lowerdet(%struct.fsm* %5)
store %struct.fsm* %6, %struct.fsm** %3
%7 = load %struct.fsm*, %struct.fsm** %3
%8 = call i32 @fsm_copy(%struct.fsm* %7)
%9 = load %struct.fsm*, %struct.fsm** %3
%10 = call i32 @fsm_copy(%struct.fsm* %9)
%11 = call i32 @fsm_invert(i32 %10)
%12 = load %struct.fsm*, %struct.fsm** %3
%13 = call i32 @fsm_copy(%struct.fsm* %12)
%14 = call i32 @fsm_compose(i32 %11, i32 %13)
%15 = call i32 @fsm_extract_nonidentity(i32 %14)
%16 = call i32 @fsm_compose(i32 %8, i32 %15)
%17 = call i32 @fsm_upper(i32 %16)
%18 = call i32 @fsm_minimize(i32 %17)
%19 = call %struct.fsm* @fsm_topsort(i32 %18)
store %struct.fsm* %19, %struct.fsm** %4
%20 = load %struct.fsm*, %struct.fsm** %3
%21 = call i32 @fsm_destroy(%struct.fsm* %20)
%22 = load %struct.fsm*, %struct.fsm** %4
%23 = call i32 @sigma_cleanup(%struct.fsm* %22, i32 1)
%24 = load %struct.fsm*, %struct.fsm** %4
%25 = call i32 @fsm_compact(%struct.fsm* %24)
%26 = load %struct.fsm*, %struct.fsm** %4
%27 = call i32 @sigma_sort(%struct.fsm* %26)
%28 = load %struct.fsm*, %struct.fsm** %4
ret %struct.fsm* %28
}

LLVM IR (-O2):
%struct.fsm = type { i32 }
define %struct.fsm* @fsm_extract_ambiguous_domain(%struct.fsm* %0) {
%2 = tail call %struct.fsm* @fsm_lowerdet(%struct.fsm* %0)
%3 = tail call i32 @fsm_copy(%struct.fsm* %2)
%4 = tail call i32 @fsm_copy(%struct.fsm* %2)
%5 = tail call i32 @fsm_invert(i32 %4)
%6 = tail call i32 @fsm_copy(%struct.fsm* %2)
%7 = tail call i32 @fsm_compose(i32 %5, i32 %6)
%8 = tail call i32 @fsm_extract_nonidentity(i32 %7)
%9 = tail call i32 @fsm_compose(i32 %3, i32 %8)
%10 = tail call i32 @fsm_upper(i32 %9)
%11 = tail call i32 @fsm_minimize(i32 %10)
%12 = tail call %struct.fsm* @fsm_topsort(i32 %11)
%13 = tail call i32 @fsm_destroy(%struct.fsm* %2)
%14 = tail call i32 @sigma_cleanup(%struct.fsm* %12, i32 1)
%15 = tail call i32 @fsm_compact(%struct.fsm* %12)
%16 = tail call i32 @sigma_sort(%struct.fsm* %12)
ret %struct.fsm* %12
}