#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ abort();
int atoi(char *);
int /*<<< orphan*/ build_dominator_tree(int **, int *, int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ generate_cfg(int **, int, int *);
int /*<<< orphan*/ print_dot_input(int **, int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ print_dot_output(int *, int, char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int cfg[1000][1000], i, j, no_of_vertices;
  int idominator[1000], idominator_from_gencfg[1000];
  int idominator2[1000], return_value = EXIT_SUCCESS;
  FILE *input, *output;
  int m, n;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s n\nEnter the graph matrix here...\n", argv[0]);
    abort();
  }
  no_of_vertices = atoi(argv[1]);
  if (no_of_vertices > 1000) {
    fprintf(stderr, "Too many nodes..\n");
    abort();
  }
  generate_cfg(cfg, no_of_vertices, idominator_from_gencfg);
  build_dominator_tree(cfg, idominator, no_of_vertices);
  input = fopen("cfg.dot", "w");
  print_dot_input(cfg, no_of_vertices, "CFG", input);
  output = fopen("dominator.lengauerTarjan.dot", "w");
  print_dot_output(idominator, no_of_vertices,
                   "DOMINATOR_TREE_FROM_LENGAUER_TARJAN", output);
  return !return_value;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x3d3820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e38(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3d3804(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11d7 <main+0x57>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x3d091c(%rbp)
cmpl   $0x3e8,-0x3d091c(%rbp)
jle    1218 <main+0x98>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
lea    -0x3d0910(%rbp),%rdi
mov    -0x3d091c(%rbp),%esi
lea    -0x3d2860(%rbp),%rdx
call   1030 <generate_cfg@plt>
lea    -0x3d0910(%rbp),%rdi
lea    -0x3d18c0(%rbp),%rsi
mov    -0x3d091c(%rbp),%edx
call   1070 <build_dominator_tree@plt>
lea    0xded(%rip),%rdi
lea    0xdee(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x3d3810(%rbp)
lea    -0x3d0910(%rbp),%rdi
mov    -0x3d091c(%rbp),%esi
mov    -0x3d3810(%rbp),%rcx
lea    0xdc9(%rip),%rdx
call   1060 <print_dot_input@plt>
lea    0xdc1(%rip),%rdi
lea    0xdb4(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x3d3818(%rbp)
lea    -0x3d18c0(%rbp),%rdi
mov    -0x3d091c(%rbp),%esi
mov    -0x3d3818(%rbp),%rcx
lea    0xdb0(%rip),%rdx
call   10a0 <print_dot_output@plt>
cmpl   $0x0,-0x3d3804(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
add    $0x3d3820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3d2840,%rsp
cmp    $0x2,%edi
jne    1245 <main+0xc5>
mov    0x2e39(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
cmp    $0x3e9,%eax
jge    1266 <main+0xe6>
mov    %eax,%ebx
lea    0x1f40(%rsp),%r15
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <generate_cfg@plt>
lea    0xfa0(%rsp),%r14
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1070 <build_dominator_tree@plt>
lea    0xe56(%rip),%rdi
lea    0xe57(%rip),%r12
mov    %r12,%rsi
call   1080 <fopen@plt>
lea    0xe4a(%rip),%rdx
mov    %r15,%rdi
mov    %ebx,%esi
mov    %rax,%rcx
call   1060 <print_dot_input@plt>
lea    0xe3a(%rip),%rdi
mov    %r12,%rsi
call   1080 <fopen@plt>
lea    0xe48(%rip),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rcx
call   10a0 <print_dot_output@plt>
xor    %eax,%eax
test   %ebp,%ebp
sete   %al
add    $0x3d2840,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d94(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xda8(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xdb6(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1040 <abort@plt>

LLVM IR (-O0):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [44 x i8] c"Usage: %s n\0AEnter the graph matrix here...\0A\00"
@.str.1 = [18 x i8] c"Too many nodes..\0A\00"
@.str.2 = [8 x i8] c"cfg.dot\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [4 x i8] c"CFG\00"
@.str.5 = [29 x i8] c"dominator.lengauerTarjan.dot\00"
@.str.6 = [36 x i8] c"DOMINATOR_TREE_FROM_LENGAUER_TARJAN\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x [1000 x i32]]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [1000 x i32]
%11 = alloca [1000 x i32]
%12 = alloca [1000 x i32]
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%18 = load i32, i32* @EXIT_SUCCESS
store i32 %18, i32* %13
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 2
br i1 %20, label %21, label %28
21: ; preds = %2
%22 = load i32, i32* @stderr
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = call i32 (...) @abort()
unreachable
28: ; preds = %2
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %9
%33 = load i32, i32* %9
%34 = icmp sgt i32 %33, 1000
br i1 %34, label %35, label %39
35: ; preds = %28
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%38 = call i32 (...) @abort()
unreachable
39: ; preds = %28
%40 = getelementptr inbounds [1000 x [1000 x i32]], [1000 x [1000 x i32]]* %6, i64 0, i64 0
%41 = bitcast [1000 x i32]* %40 to i32**
%42 = load i32, i32* %9
%43 = getelementptr inbounds [1000 x i32], [1000 x i32]* %11, i64 0, i64 0
%44 = call i32 @generate_cfg(i32** %41, i32 %42, i32* %43)
%45 = getelementptr inbounds [1000 x [1000 x i32]], [1000 x [1000 x i32]]* %6, i64 0, i64 0
%46 = bitcast [1000 x i32]* %45 to i32**
%47 = getelementptr inbounds [1000 x i32], [1000 x i32]* %10, i64 0, i64 0
%48 = load i32, i32* %9
%49 = call i32 @build_dominator_tree(i32** %46, i32* %47, i32 %48)
%50 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %50, i32** %14
%51 = getelementptr inbounds [1000 x [1000 x i32]], [1000 x [1000 x i32]]* %6, i64 0, i64 0
%52 = bitcast [1000 x i32]* %51 to i32**
%53 = load i32, i32* %9
%54 = load i32*, i32** %14
%55 = call i32 @print_dot_input(i32** %52, i32 %53, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %54)
%56 = call i32* @fopen(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %56, i32** %15
%57 = getelementptr inbounds [1000 x i32], [1000 x i32]* %10, i64 0, i64 0
%58 = load i32, i32* %9
%59 = load i32*, i32** %15
%60 = call i32 @print_dot_output(i32* %57, i32 %58, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32* %59)
%61 = load i32, i32* %13
%62 = icmp ne i32 %61, 0
%63 = xor i1 %62, true
%64 = zext i1 %63 to i32
ret i32 %64
}

LLVM IR (-O2):
@EXIT_SUCCESS = global i32 0
@stderr = global i32 0
@.str = [44 x i8] c"Usage: %s n\0AEnter the graph matrix here...\0A\00"
@.str.1 = [18 x i8] c"Too many nodes..\0A\00"
@.str.2 = [8 x i8] c"cfg.dot\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [4 x i8] c"CFG\00"
@.str.5 = [29 x i8] c"dominator.lengauerTarjan.dot\00"
@.str.6 = [36 x i8] c"DOMINATOR_TREE_FROM_LENGAUER_TARJAN\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x [1000 x i32]]
%4 = alloca [1000 x i32]
%5 = alloca [1000 x i32]
%6 = bitcast [1000 x [1000 x i32]]* %3 to i8*
%7 = bitcast [1000 x i32]* %4 to i8*
%8 = bitcast [1000 x i32]* %5 to i8*
%9 = load i32, i32* @EXIT_SUCCESS
%10 = icmp eq i32 %0, 2
br i1 %10, label %16, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %12, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = icmp sgt i32 %19, 1000
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%24 = tail call i32 (...) @abort()
unreachable
25: ; preds = %16
%26 = bitcast [1000 x [1000 x i32]]* %3 to i32**
%27 = getelementptr inbounds [1000 x i32], [1000 x i32]* %5, i64 0, i64 0
%28 = call i32 @generate_cfg(i32** %26, i32 %19, i32* %27)
%29 = getelementptr inbounds [1000 x i32], [1000 x i32]* %4, i64 0, i64 0
%30 = call i32 @build_dominator_tree(i32** %26, i32* %29, i32 %19)
%31 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = call i32 @print_dot_input(i32** %26, i32 %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32* %31)
%33 = call i32* @fopen(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @print_dot_output(i32* %29, i32 %19, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i32* %33)
%35 = icmp eq i32 %9, 0
%36 = zext i1 %35 to i32
ret i32 %36
}