#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ print_parentless_nodes(char *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ system(char *);
int main(int argc, char *argv[]) {
  char buffer[1024], newfile[1024];
  FILE *infile, *outfile;
  buffer[0] = newfile[0] = 0x0;
  strcat(buffer, argv[1]);
  strcat(buffer, "/graph.dot");
  infile = fopen(buffer, "r");
  if (infile == NULL) {
    fprintf(stderr, "output_order: error opening %s, exiting...\n", buffer);
    exit(1);
  }
  strcpy(newfile, buffer);
  strcat(newfile, "_temp");
  outfile = fopen(newfile, "w");
  if (outfile == NULL) {
    fprintf(stderr, "output_order: error opening %s, exiting...\n", newfile);
    exit(1);
  }
  while (fgets(buffer, 1024, infile))
    fprintf(outfile, "%s", buffer);
  fclose(infile);
  fclose(outfile);
  print_parentless_nodes(argv[1]);
  strcpy(buffer, "rm ");
  strcat(buffer, newfile);
  system(buffer);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x810(%rbp)
movb   $0x0,-0x410(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
call   10a0 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   10a0 <strcat@plt>
lea    -0x410(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x818(%rbp)
cmpq   $0x0,-0x818(%rbp)
jne    122d <main+0x9d>
mov    0x2dd3(%rip),%rax
mov    (%rax),%rdi
lea    -0x410(%rbp),%rdx
lea    0xdef(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    -0x810(%rbp),%rdi
lea    -0x410(%rbp),%rsi
call   1040 <strcpy@plt>
lea    -0x810(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   10a0 <strcat@plt>
lea    -0x810(%rbp),%rdi
lea    0xdde(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x820(%rbp)
jne    12a2 <main+0x112>
mov    0x2d5e(%rip),%rax
mov    (%rax),%rdi
lea    -0x810(%rbp),%rdx
lea    0xd7a(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
jmp    12a7 <main+0x117>
lea    -0x410(%rbp),%rdi
mov    -0x818(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12e8 <main+0x158>
mov    -0x820(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    0xd63(%rip),%rsi
call   1080 <fprintf@plt>
jmp    12a7 <main+0x117>
mov    -0x818(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x820(%rbp),%rdi
call   1050 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <print_parentless_nodes@plt>
lea    -0x410(%rbp),%rdi
lea    0xd29(%rip),%rsi
call   1040 <strcpy@plt>
lea    -0x410(%rbp),%rdi
lea    -0x810(%rbp),%rsi
call   10a0 <strcat@plt>
lea    -0x410(%rbp),%rdi
call   1060 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%r14
movb   $0x0,0x400(%rsp)
movb   $0x0,(%rsp)
mov    0x8(%rsi),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   10b0 <strcat@plt>
lea    0xe2d(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcat@plt>
lea    0xe29(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12c4 <main+0x124>
mov    %rax,%r15
lea    0x400(%rsp),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0xe29(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <strcat@plt>
lea    0xe20(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12da <main+0x13a>
mov    %rax,%r12
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     1270 <main+0xd0>
mov    %rsp,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <fputs@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
jne    1250 <main+0xb0>
mov    %r15,%rdi
call   1050 <fclose@plt>
mov    %r12,%rdi
call   1050 <fclose@plt>
mov    0x8(%r14),%rdi
call   1030 <print_parentless_nodes@plt>
lea    0xdb1(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1040 <strcpy@plt>
lea    0x400(%rsp),%rsi
mov    %rbx,%rdi
call   10b0 <strcat@plt>
mov    %rbx,%rdi
call   1060 <system@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2d15(%rip),%rax
mov    (%rax),%rdi
lea    0xd38(%rip),%rsi
mov    %rsp,%rdx
jmp    12f3 <main+0x153>
mov    0x2cff(%rip),%rax
mov    (%rax),%rdi
lea    0xd22(%rip),%rsi
lea    0x400(%rsp),%rdx
call   1090 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"/graph.dot\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32* null
@.str.2 = [44 x i8] c"output_order: error opening %s, exiting...\0A\00"
@.str.3 = [6 x i8] c"_temp\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [4 x i8] c"rm \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca i32*
%9 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
store i8 0, i8* %10
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
store i8 0, i8* %11
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strcat(i8* %12, i8* %15)
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %8
%21 = load i32*, i32** %8
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %28
23: ; preds = %2
%24 = load i32*, i32** @stderr
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%26 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %2
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%31 = call i32 @strcpy(i8* %29, i8* %30)
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %35, i32** %9
%36 = load i32*, i32** %9
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %43
38: ; preds = %28
%39 = load i32*, i32** @stderr
%40 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%41 = call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %40)
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %28
br label %44
44: ; preds = %49, %43
%45 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%46 = load i32*, i32** %8
%47 = call i64 @fgets(i8* %45, i32 1024, i32* %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %44
%50 = load i32*, i32** %9
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%52 = call i32 @fprintf(i32* %50, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %51)
br label %44
53: ; preds = %44
%54 = load i32*, i32** %8
%55 = call i32 @fclose(i32* %54)
%56 = load i32*, i32** %9
%57 = call i32 @fclose(i32* %56)
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = call i32 @print_parentless_nodes(i8* %60)
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%63 = call i32 @strcpy(i8* %62, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%66 = call i32 @strcat(i8* %64, i8* %65)
%67 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%68 = call i32 @system(i8* %67)
%69 = load i32, i32* %3
ret i32 %69
}

LLVM IR (-O2):
@.str = [11 x i8] c"/graph.dot\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32* null
@.str.2 = [44 x i8] c"output_order: error opening %s, exiting...\0A\00"
@.str.3 = [6 x i8] c"_temp\00"
@.str.4 = [2 x i8] c"w\00"
@.str.6 = [4 x i8] c"rm \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
store i8 0, i8* %6
store i8 0, i8* %5
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @strcat(i8* %5, i8* %8)
%10 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32*, i32** @stderr
%15 = call i32 @fprintf(i32* %14, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = call i32 @strcpy(i8* %6, i8* %5)
%19 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = call i64 @fgets(i8* %5, i32 1024, i32* %11)
%24 = icmp eq i64 %23, 0
br i1 %24, label %33, label %29
25: ; preds = %17
%26 = load i32*, i32** @stderr
%27 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%28 = call i32 @exit(i32 1)
unreachable
29: ; preds = %22, %29
%30 = call i32 @fputs(i8* %5, i32* %20)
%31 = call i64 @fgets(i8* %5, i32 1024, i32* %11)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %29
33: ; preds = %29, %22
%34 = call i32 @fclose(i32* %11)
%35 = call i32 @fclose(i32* %20)
%36 = load i8*, i8** %7
%37 = call i32 @print_parentless_nodes(i8* %36)
%38 = call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%39 = call i32 @strcat(i8* %5, i8* %6)
%40 = call i32 @system(i8* %5)
ret i32 0
}