#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*/ draw_pgraph(int, int);
int /*<<< orphan*/ *fopen(char *, char *);
int make_adj_matrix(int /*<<< orphan*/ *);
int make_inc_matrix(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  char filename[50];
  FILE *fp;
  int lines, edges;
  printf("Enter the name of the program file: ");
  scanf("%s", filename);
  fp = fopen(filename, "r");
  if (fp == NULL) {
    printf("File not found!");
    return 0;
  }
  lines = make_adj_matrix(fp);
  edges = make_inc_matrix(lines);
  draw_pgraph(lines, edges);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe8a(%rip),%rdi
call   1050 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x40(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11c2 <main+0x62>
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11eb <main+0x8b>
mov    -0x48(%rbp),%rdi
call   1070 <make_adj_matrix@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edi
call   1030 <make_inc_matrix@plt>
mov    %eax,-0x50(%rbp)
mov    -0x4c(%rbp),%edi
mov    -0x50(%rbp),%esi
call   1040 <draw_pgraph@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xe94(%rip),%rdi
call   1050 <printf@plt>
lea    0xead(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1060 <scanf@plt>
lea    0xe9e(%rip),%rsi
mov    %rbx,%rdi
call   1080 <fopen@plt>
test   %rax,%rax
je     11b3 <main+0x53>
mov    %rax,%rdi
call   1070 <make_adj_matrix@plt>
mov    %eax,%ebx
mov    %eax,%edi
call   1030 <make_inc_matrix@plt>
mov    %ebx,%edi
mov    %eax,%esi
call   1040 <draw_pgraph@plt>
jmp    11bf <main+0x5f>
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Enter the name of the program file: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [16 x i8] c"File not found!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %10, i32** %3
%11 = load i32*, i32** %3
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %23
15: ; preds = %0
%16 = load i32*, i32** %3
%17 = call i32 @make_adj_matrix(i32* %16)
store i32 %17, i32* %4
%18 = load i32, i32* %4
%19 = call i32 @make_inc_matrix(i32 %18)
store i32 %19, i32* %5
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = call i32 @draw_pgraph(i32 %20, i32 %21)
store i32 0, i32* %1
br label %23
23: ; preds = %15, %13
%24 = load i32, i32* %1
ret i32 %24
}

LLVM IR (-O2):
@.str = [37 x i8] c"Enter the name of the program file: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [16 x i8] c"File not found!\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
br label %13
9: ; preds = %0
%10 = call i32 @make_adj_matrix(i32* %5)
%11 = call i32 @make_inc_matrix(i32 %10)
%12 = call i32 @draw_pgraph(i32 %10, i32 %11)
br label %13
13: ; preds = %9, %7
ret i32 0
}