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

/* Variables and functions */
int /*<<< orphan*/ add_edge(struct graph *, int, int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int fscanf(int /*<<< orphan*/ *, char *, int *, ...);
struct graph *init_graph(int, int);
int /*<<< orphan*/ print_graph(struct graph *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ release_graph(struct graph *);
int main() {
  struct graph *p_graph = NULL;
  FILE *fp = fopen("./text.txt", "r+");
  if (!fp) {
    printf("fopen() failed!\n");
    return 0;
  }
  int ret = 0;
  int vertex = 0;
  int edge = 0;
  int from_v = 0;
  int to_v = 0;
  fscanf(fp, "%d", &vertex);
  fscanf(fp, "%d", &edge);
  p_graph = init_graph(vertex, edge);
  int temp = 0;
  for (temp; temp < edge; temp++) {
    ret = fscanf(fp, "%d %d", &from_v, &to_v);
    if (ret != 2) {
      break;
    }
    add_edge(p_graph, from_v, to_v);
  }
  print_graph(p_graph);
  release_graph(p_graph);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    0xe62(%rip),%rdi
lea    0xe66(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d1 <main+0x51>
lea    0xe4e(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12ad <main+0x12d>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe23(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe0d(%rip),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    -0x20(%rbp),%edi
mov    -0x24(%rbp),%esi
call   10a0 <init_graph@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    128b <main+0x10b>
mov    -0x18(%rbp),%rdi
lea    0xdd2(%rip),%rsi
lea    -0x28(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
mov    $0x0,%al
call   1070 <fscanf@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
je     126e <main+0xee>
jmp    128b <main+0x10b>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1040 <add_edge@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1236 <main+0xb6>
mov    -0x10(%rbp),%rdi
call   1030 <print_graph@plt>
mov    -0x10(%rbp),%rdi
call   1080 <release_graph@plt>
mov    -0x18(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe6b(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     127b <main+0xfb>
mov    %rax,%r14
movl   $0x0,0x14(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
lea    0xe3d(%rip),%rbx
lea    0x14(%rsp),%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <fscanf@plt>
lea    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <fscanf@plt>
mov    0x14(%rsp),%edi
mov    0x8(%rsp),%esi
call   10a0 <init_graph@plt>
mov    %rax,%rbx
cmpl   $0x0,0x8(%rsp)
jle    1261 <main+0xe1>
lea    0xdf8(%rip),%r15
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1070 <fscanf@plt>
cmp    $0x2,%eax
jne    1261 <main+0xe1>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbx,%rdi
call   1050 <add_edge@plt>
add    $0x1,%ebp
cmp    0x8(%rsp),%ebp
jl     1230 <main+0xb0>
mov    %rbx,%rdi
call   1040 <print_graph@plt>
mov    %rbx,%rdi
call   1080 <release_graph@plt>
mov    %r14,%rdi
call   1060 <fclose@plt>
jmp    1287 <main+0x107>
lea    0xd92(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.graph = type { i32 }
@.str = [11 x i8] c"./text.txt\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.2 = [17 x i8] c"fopen() failed!\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [6 x i8] c"%d %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.graph*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store %struct.graph* null, %struct.graph** %2
%10 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %10, i32** %3
%11 = load i32*, i32** %3
%12 = icmp ne i32* %11, null
br i1 %12, label %15, label %13
13: ; preds = %0
%14 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %49
15: ; preds = %0
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%16 = load i32*, i32** %3
%17 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%18 = load i32*, i32** %3
%19 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%20 = load i32, i32* %5
%21 = load i32, i32* %6
%22 = call %struct.graph* @init_graph(i32 %20, i32 %21)
store %struct.graph* %22, %struct.graph** %2
store i32 0, i32* %9
%23 = load i32, i32* %9
br label %24
24: ; preds = %39, %15
%25 = load i32, i32* %9
%26 = load i32, i32* %6
%27 = icmp slt i32 %25, %26
br i1 %27, label %28, label %42
28: ; preds = %24
%29 = load i32*, i32** %3
%30 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %29, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %7, i32* %8)
store i32 %30, i32* %4
%31 = load i32, i32* %4
%32 = icmp ne i32 %31, 2
br i1 %32, label %33, label %34
33: ; preds = %28
br label %42
34: ; preds = %28
%35 = load %struct.graph*, %struct.graph** %2
%36 = load i32, i32* %7
%37 = load i32, i32* %8
%38 = call i32 @add_edge(%struct.graph* %35, i32 %36, i32 %37)
br label %39
39: ; preds = %34
%40 = load i32, i32* %9
%41 = add nsw i32 %40, 1
store i32 %41, i32* %9
br label %24
42: ; preds = %33, %24
%43 = load %struct.graph*, %struct.graph** %2
%44 = call i32 @print_graph(%struct.graph* %43)
%45 = load %struct.graph*, %struct.graph** %2
%46 = call i32 @release_graph(%struct.graph* %45)
%47 = load i32*, i32** %3
%48 = call i32 @fclose(i32* %47)
store i32 0, i32* %1
br label %49
49: ; preds = %42, %13
%50 = load i32, i32* %1
ret i32 %50
}

LLVM IR (-O2):
%struct.graph = type { i32 }
@.str = [11 x i8] c"./text.txt\00"
@.str.1 = [3 x i8] c"r+\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [6 x i8] c"%d %d\00"
@str = [16 x i8] c"fopen() failed!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %36
9: ; preds = %0
%10 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%11 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%12 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%13 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%14 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%15 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = call %struct.graph* @init_graph(i32 %16, i32 %17)
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 0
br i1 %20, label %21, label %32
21: ; preds = %9, %25
%22 = phi i32 [ %29, %25 ], [ 0, %9 ]
%23 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %3, i32* %4)
%24 = icmp eq i32 %23, 2
br i1 %24, label %25, label %32
25: ; preds = %21
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = call i32 @add_edge(%struct.graph* %18, i32 %26, i32 %27)
%29 = add nuw nsw i32 %22, 1
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %21, label %32
32: ; preds = %25, %21, %9
%33 = call i32 @print_graph(%struct.graph* %18)
%34 = call i32 @release_graph(%struct.graph* %18)
%35 = call i32 @fclose(i32* %5)
br label %36
36: ; preds = %32, %7
ret i32 0
}