#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*/ *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);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xeaf(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x40(%rbp),%rdi
lea    0xea2(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
jne    11b2 <main+0x62>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d0 <main+0x80>
mov    -0x48(%rbp),%rdi
call   1060 <make_adj_matrix@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%edi
call   1030 <make_inc_matrix@plt>
mov    %eax,-0x50(%rbp)
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    0xea4(%rip),%rdi
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
test   %rax,%rax
je     1198 <main+0x48>
mov    %rax,%rdi
call   1060 <make_adj_matrix@plt>
mov    %eax,%edi
call   1030 <make_inc_matrix@plt>
jmp    11a4 <main+0x54>
lea    0xe8b(%rip),%rdi
call   1040 <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 %20
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
store i32 0, i32* %1
br label %20
20: ; preds = %15, %13
%21 = load i32, i32* %1
ret i32 %21
}

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 %12
9: ; preds = %0
%10 = call i32 @make_adj_matrix(i32* %5)
%11 = call i32 @make_inc_matrix(i32 %10)
br label %12
12: ; preds = %9, %7
ret i32 0
}