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

/* Variables and functions */
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, ...);
int /*<<< orphan*/ list_delete_all(struct ListNode **, int);
int /*<<< orphan*/ list_display_all(struct ListNode **, int);
int /*<<< orphan*/ list_insert_node(struct ListNode **, int);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ spanning_tree(struct ListNode **, int);
int main(int argc, char *argv[]) {
  FILE *fp;
  int i;
  if (argc != 2) {
    printf("Usage:  a.out <file name>\n");
    return 0;
  }
  fp = fopen(argv[1], "r");
  int num_nodes;
  int num_edges;
  fscanf(fp, "%d", &num_nodes);
  fscanf(fp, "%d", &num_edges);
  struct ListNode **adj_list;
  adj_list = (struct ListNode **)malloc(num_nodes * sizeof(struct ListNode *));
  for (i = 0; i < num_nodes; i++) {
    adj_list[i] = NULL;
  }
  int node1, node2;
  printf("Edges:\n");
  for (i = 0; i < num_edges; i++) {
    fscanf(fp, "%d %d", &node1, &node2);
    printf("(%d %d)\n", node1, node2);
    list_insert_node(&adj_list[node1], node2);
    list_insert_node(&adj_list[node2], node1);
  }
  list_display_all(adj_list, num_nodes);
  spanning_tree(adj_list, num_nodes);
  list_delete_all(adj_list, num_nodes);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11ba <main+0x3a>
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12f1 <main+0x171>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe52(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe4b(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe35(%rip),%rsi
lea    -0x24(%rbp),%rdx
mov    $0x0,%al
call   1040 <fscanf@plt>
movslq -0x20(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1242 <main+0xc2>
mov    -0x30(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1218 <main+0x98>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    12cd <main+0x14d>
mov    -0x18(%rbp),%rdi
lea    0xdb7(%rip),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
mov    $0x0,%al
call   1040 <fscanf@plt>
mov    -0x34(%rbp),%esi
mov    -0x38(%rbp),%edx
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rdi
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x38(%rbp),%esi
call   1090 <list_insert_node@plt>
mov    -0x30(%rbp),%rdi
movslq -0x38(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
mov    -0x34(%rbp),%esi
call   1090 <list_insert_node@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1257 <main+0xd7>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1070 <list_display_all@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1080 <spanning_tree@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1050 <list_delete_all@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jne    12ce <main+0x12e>
mov    0x8(%rsi),%rdi
lea    0xe3e(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,%r14
lea    0xe34(%rip),%rbx
lea    0x8(%rsp),%rdx
mov    %rax,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
lea    0x14(%rsp),%rdx
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    0x8(%rsp),%edi
shl    $0x3,%edi
call   1080 <malloc@plt>
mov    %rax,%rbx
mov    0x8(%rsp),%edx
test   %edx,%edx
jle    121a <main+0x7a>
shl    $0x3,%rdx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
lea    0xdf0(%rip),%rdi
call   1030 <puts@plt>
cmpl   $0x0,0x14(%rsp)
jle    12a8 <main+0x108>
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0xdca(%rip),%rbp
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
lea    0xda8(%rip),%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1060 <fscanf@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x10(%rsp),%rax
lea    (%rbx,%rax,8),%rdi
mov    0xc(%rsp),%esi
call   10b0 <list_insert_node@plt>
movslq 0xc(%rsp),%rax
lea    (%rbx,%rax,8),%rdi
mov    0x10(%rsp),%esi
call   10b0 <list_insert_node@plt>
add    $0x1,%r15d
cmp    0x14(%rsp),%r15d
jl     1250 <main+0xb0>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1090 <list_display_all@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   10a0 <spanning_tree@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
call   1070 <list_delete_all@plt>
jmp    12da <main+0x13a>
lea    0xd43(%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.ListNode = type { i32 }
@.str = [27 x i8] c"Usage: a.out <file name>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [8 x i8] c"Edges:\0A\00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [9 x i8] c"(%d %d)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.ListNode**
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %81
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %21, i32** %6
%22 = load i32*, i32** %6
%23 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%24 = load i32*, i32** %6
%25 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%26 = load i32, i32* %8
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 8
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to %struct.ListNode**
store %struct.ListNode** %31, %struct.ListNode*** %10
store i32 0, i32* %7
br label %32
32: ; preds = %41, %17
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %44
36: ; preds = %32
%37 = load %struct.ListNode**, %struct.ListNode*** %10
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds %struct.ListNode*, %struct.ListNode** %37, i64 %39
store %struct.ListNode* null, %struct.ListNode** %40
br label %41
41: ; preds = %36
%42 = load i32, i32* %7
%43 = add nsw i32 %42, 1
store i32 %43, i32* %7
br label %32
44: ; preds = %32
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %7
br label %46
46: ; preds = %68, %44
%47 = load i32, i32* %7
%48 = load i32, i32* %9
%49 = icmp slt i32 %47, %48
br i1 %49, label %50, label %71
50: ; preds = %46
%51 = load i32*, i32** %6
%52 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %51, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %11, i32* %12)
%53 = load i32, i32* %11
%54 = load i32, i32* %12
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %53, i32 %54)
%56 = load %struct.ListNode**, %struct.ListNode*** %10
%57 = load i32, i32* %11
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds %struct.ListNode*, %struct.ListNode** %56, i64 %58
%60 = load i32, i32* %12
%61 = call i32 @list_insert_node(%struct.ListNode** %59, i32 %60)
%62 = load %struct.ListNode**, %struct.ListNode*** %10
%63 = load i32, i32* %12
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds %struct.ListNode*, %struct.ListNode** %62, i64 %64
%66 = load i32, i32* %11
%67 = call i32 @list_insert_node(%struct.ListNode** %65, i32 %66)
br label %68
68: ; preds = %50
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %46
71: ; preds = %46
%72 = load %struct.ListNode**, %struct.ListNode*** %10
%73 = load i32, i32* %8
%74 = call i32 @list_display_all(%struct.ListNode** %72, i32 %73)
%75 = load %struct.ListNode**, %struct.ListNode*** %10
%76 = load i32, i32* %8
%77 = call i32 @spanning_tree(%struct.ListNode** %75, i32 %76)
%78 = load %struct.ListNode**, %struct.ListNode*** %10
%79 = load i32, i32* %8
%80 = call i32 @list_delete_all(%struct.ListNode** %78, i32 %79)
br label %81
81: ; preds = %71, %15
%82 = load i32, i32* %3
ret i32 %82
}

LLVM IR (-O2):
%struct.ListNode = type { i32 }
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.4 = [6 x i8] c"%d %d\00"
@.str.5 = [9 x i8] c"(%d %d)\0A\00"
@str = [7 x i8] c"Edges:\00"
@str.6 = [26 x i8] c"Usage: a.out <file name>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = icmp eq i32 %0, 2
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.6, i64 0, i64 0))
br label %60
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = bitcast i32* %3 to i8*
%15 = bitcast i32* %4 to i8*
%16 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%17 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%18 = load i32, i32* %3
%19 = shl i32 %18, 3
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to %struct.ListNode**
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %10
%25 = inttoptr i64 %20 to i8*
%26 = zext i32 %22 to i64
%27 = shl nuw nsw i64 %26, 3
br label %28
28: ; preds = %24, %10
%29 = bitcast i32* %5 to i8*
%30 = bitcast i32* %6 to i8*
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %53
34: ; preds = %28, %34
%35 = phi i32 [ %50, %34 ], [ 0, %28 ]
%36 = call i32 (i32*, i8*, i32*, ...) @fscanf(i32* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i32* %5, i32* %6)
%37 = load i32, i32* %5
%38 = load i32, i32* %6
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0), i32 %37, i32 %38)
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds %struct.ListNode*, %struct.ListNode** %21, i64 %41
%43 = load i32, i32* %6
%44 = call i32 @list_insert_node(%struct.ListNode** %42, i32 %43)
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds %struct.ListNode*, %struct.ListNode** %21, i64 %46
%48 = load i32, i32* %5
%49 = call i32 @list_insert_node(%struct.ListNode** %47, i32 %48)
%50 = add nuw nsw i32 %35, 1
%51 = load i32, i32* %4
%52 = icmp slt i32 %50, %51
br i1 %52, label %34, label %53
53: ; preds = %34, %28
%54 = load i32, i32* %3
%55 = call i32 @list_display_all(%struct.ListNode** %21, i32 %54)
%56 = load i32, i32* %3
%57 = call i32 @spanning_tree(%struct.ListNode** %21, i32 %56)
%58 = load i32, i32* %3
%59 = call i32 @list_delete_all(%struct.ListNode** %21, i32 %58)
br label %60
60: ; preds = %53, %8
ret i32 0
}