Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t edge_weight;

typedef struct directed_edge {
  int32_t vertex;
  int32_t next;
  edge_weight cost;
} graph_edge;

typedef struct directedGraph {
  graph_edge *edge;
  int32_t *start;
  int32_t pointer;
  int32_t vertex_num;
  int32_t edge_max_size;
} graph;

graph* new_graph (const int vertex_num) {
  graph *g = (graph *) calloc (1, sizeof (graph));
  g->edge = (graph_edge *) calloc (1, sizeof (graph_edge));
  g->start = (int32_t *) calloc (vertex_num, sizeof (int32_t));
  g->pointer = 0;
  g->vertex_num = vertex_num;
  g->edge_max_size = 1;
  for (int32_t i = 0; i < vertex_num; ++i) {
    g->start[i] = -1;
  }
  return g;
}

void free_graph (graph *g) {
  free (g->edge);
  free (g->start);
  free (g);
  return;
}

void clear_graph (graph *g) {
  g->pointer = 0;
  for (int32_t i = 0; i < g->vertex_num; ++i) {
    g->start[i] = -1;
  }
}

void add_edge (graph *g, int32_t from, int32_t to, edge_weight cost) {
  if (g->pointer == g->edge_max_size) {
    g->edge_max_size *= 2;
    g->edge = (graph_edge *) realloc (g->edge, sizeof (graph_edge) * g->edge_max_size);
  }
  g->edge[g->pointer] = (graph_edge) {to, g->start[from], cost};
  g->start[from] = g->pointer++;
}

typedef int32_t i32;

int bellman_ford (graph *g, i32 *dp, i32 inf) {
  int update = 0;
  for (i32 i = 0; i < g->vertex_num; ++i) {
    if (dp[i] == inf) continue;
    for (i32 p = g->start[i]; p != -1; p = g->edge[p].next) {
      i32 u = g->edge[p].vertex;
      i32 d = dp[i] + g->edge[p].cost;
      if (d >= dp[u]) continue;
      update = 1;
      dp[u] = d;
    }
  }
  return update;
}

void run (void) {
  i32 v, e, r;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &v, &e, &r);
  graph *g = new_graph (v);
  while (e--) {
    i32 s, t, d;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &s, &t, &d);
    add_edge (g, s, t, d);
  }
  i32 *dp = (i32 *) calloc (v, sizeof (i32));
  const i32 inf = 10000 * v + 1;
  for (i32 i = 0; i < v; ++i) {
    dp[i] = inf;
  }
  dp[r] = 0;
  for (i32 iter = 0; iter < v - 1; ++iter) {
    bellman_ford (g, dp, inf);
  }
  if (bellman_ford (g, dp, inf)) {
    puts ("NEGATIVE CYCLE");
    return;
  }
  for (i32 i = 0; i < v; ++i) {
    if (dp[i] == inf) {
      puts ("INF");
    } else {
      printf ("%" PRIi32 "\n", dp[i]);
    }
  }
}

int main (void) {
  run ();
  return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	new_graph
	.type	new_graph, @function
new_graph:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$32, %esi
	movl	$1, %edi
	call	calloc@PLT
	movq	%rax, -8(%rbp)
	movl	$12, %esi
	movl	$1, %edi
	call	calloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, (%rax)
	movl	-20(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	movl	$0, 16(%rax)
	movq	-8(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 20(%rax)
	movq	-8(%rbp), %rax
	movl	$1, 24(%rax)
	movl	$0, -12(%rbp)
	jmp	.L2
.L3:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rdx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -12(%rbp)
.L2:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	new_graph, .-new_graph
	.globl	free_graph
	.type	free_graph, @function
free_graph:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	free_graph, .-free_graph
	.globl	clear_graph
	.type	clear_graph, @function
clear_graph:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movl	$0, 16(%rax)
	movl	$0, -4(%rbp)
	jmp	.L8
.L9:
	movq	-24(%rbp), %rax
	movq	8(%rax), %rdx
	movl	-4(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -4(%rbp)
.L8:
	movq	-24(%rbp), %rax
	movl	20(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L9
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	clear_graph, .-clear_graph
	.globl	add_edge
	.type	add_edge, @function
add_edge:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	%ecx, -36(%rbp)
	movq	-24(%rbp), %rax
	movl	16(%rax), %edx
	movq	-24(%rbp), %rax
	movl	24(%rax), %eax
	cmpl	%eax, %edx
	jne	.L11
	movq	-24(%rbp), %rax
	movl	24(%rax), %eax
	leal	(%rax,%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 24(%rax)
	movq	-24(%rbp), %rax
	movl	24(%rax), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	-24(%rbp), %rdx
	movq	%rax, (%rdx)
.L11:
	movq	-24(%rbp), %rax
	movq	(%rax), %rcx
	movq	-24(%rbp), %rax
	movl	16(%rax), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movq	-24(%rbp), %rdx
	movq	8(%rdx), %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	movl	-32(%rbp), %ecx
	movl	%ecx, (%rax)
	movl	%edx, 4(%rax)
	movl	-36(%rbp), %edx
	movl	%edx, 8(%rax)
	movq	-24(%rbp), %rax
	movl	16(%rax), %eax
	leal	1(%rax), %ecx
	movq	-24(%rbp), %rdx
	movl	%ecx, 16(%rdx)
	movq	-24(%rbp), %rdx
	movq	8(%rdx), %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	movl	%eax, (%rdx)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	add_edge, .-add_edge
	.globl	bellman_ford
	.type	bellman_ford, @function
bellman_ford:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movl	%edx, -52(%rbp)
	movl	$0, -20(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L13
.L20:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -52(%rbp)
	je	.L22
	movq	-40(%rbp), %rax
	movq	8(%rax), %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -12(%rbp)
	jmp	.L16
.L19:
	movq	-40(%rbp), %rax
	movq	(%rax), %rcx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-40(%rbp), %rax
	movq	(%rax), %rsi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	8(%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L23
	movl	$1, -20(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L18
.L23:
	nop
.L18:
	movq	-40(%rbp), %rax
	movq	(%rax), %rcx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	movl	%eax, -12(%rbp)
.L16:
	cmpl	$-1, -12(%rbp)
	jne	.L19
	jmp	.L15
.L22:
	nop
.L15:
	addl	$1, -16(%rbp)
.L13:
	movq	-40(%rbp), %rax
	movl	20(%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	movl	-20(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	bellman_ford, .-bellman_ford
	.section	.rodata
.LC0:
	.string	"%i%i%i"
.LC1:
	.string	"NEGATIVE CYCLE"
.LC2:
	.string	"INF"
.LC3:
	.string	"%i\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rcx
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-64(%rbp), %eax
	movl	%eax, %edi
	call	new_graph
	movq	%rax, -24(%rbp)
	jmp	.L25
.L26:
	leaq	-44(%rbp), %rcx
	leaq	-48(%rbp), %rdx
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %ecx
	movl	-48(%rbp), %edx
	movl	-52(%rbp), %esi
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	add_edge
.L25:
	movl	-60(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -60(%rbp)
	testl	%eax, %eax
	jne	.L26
	movl	-64(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	-64(%rbp), %eax
	imull	$10000, %eax, %eax
	addl	$1, %eax
	movl	%eax, -28(%rbp)
	movl	$0, -40(%rbp)
	jmp	.L27
.L28:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-28(%rbp), %eax
	movl	%eax, (%rdx)
	addl	$1, -40(%rbp)
.L27:
	movl	-64(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L28
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	movl	$0, -36(%rbp)
	jmp	.L29
.L30:
	movl	-28(%rbp), %edx
	movq	-16(%rbp), %rcx
	movq	-24(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	bellman_ford
	addl	$1, -36(%rbp)
.L29:
	movl	-64(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -36(%rbp)
	jl	.L30
	movl	-28(%rbp), %edx
	movq	-16(%rbp), %rcx
	movq	-24(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	bellman_ford
	testl	%eax, %eax
	je	.L31
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L24
.L31:
	movl	$0, -32(%rbp)
	jmp	.L33
.L36:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L34
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L35
.L34:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L35:
	addl	$1, -32(%rbp)
.L33:
	movl	-64(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L36
.L24:
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
user
	.file	"temp.c"
	.text
	.p2align 4
	.globl	new_graph
	.type	new_graph, @function
new_graph:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$32, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movslq	%edi, %rbp
	movl	$1, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	calloc@PLT
	movl	$12, %esi
	movl	$1, %edi
	movq	%rax, %r12
	call	calloc@PLT
	movl	$4, %esi
	movq	%rbp, %rdi
	movq	%rax, (%r12)
	call	calloc@PLT
	movl	%ebp, 20(%r12)
	movq	%rax, 8(%r12)
	movl	$0, 16(%r12)
	movl	$1, 24(%r12)
	testl	%ebp, %ebp
	jle	.L1
	movq	%rax, %rdi
	leaq	0(,%rbp,4), %rdx
	movl	$255, %esi
	call	memset@PLT
.L1:
	movq	%r12, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE39:
	.size	new_graph, .-new_graph
	.p2align 4
	.globl	free_graph
	.type	free_graph, @function
free_graph:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	movq	(%rdi), %rdi
	call	free@PLT
	movq	8(%rbp), %rdi
	call	free@PLT
	movq	%rbp, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE40:
	.size	free_graph, .-free_graph
	.p2align 4
	.globl	clear_graph
	.type	clear_graph, @function
clear_graph:
.LFB41:
	.cfi_startproc
	endbr64
	movl	20(%rdi), %eax
	movl	$0, 16(%rdi)
	testl	%eax, %eax
	jle	.L7
	movq	8(%rdi), %rdx
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L9:
	movl	$-1, (%rdx,%rax,4)
	addq	$1, %rax
	cmpl	%eax, 20(%rdi)
	jg	.L9
.L7:
	ret
	.cfi_endproc
.LFE41:
	.size	clear_graph, .-clear_graph
	.p2align 4
	.globl	add_edge
	.type	add_edge, @function
add_edge:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%ecx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movslq	%esi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rdi, %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	movl	16(%rdi), %ecx
	movq	(%rdi), %rdi
	cmpl	24(%rbx), %ecx
	je	.L14
.L12:
	movslq	%ecx, %rax
	movd	%r13d, %xmm0
	leal	1(%rcx), %edx
	leaq	(%rax,%rax,2), %rax
	leaq	(%rdi,%rax,4), %rsi
	movq	8(%rbx), %rax
	leaq	(%rax,%rbp,4), %rax
	movd	(%rax), %xmm1
	movl	%r12d, 8(%rsi)
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%rsi)
	movl	%edx, 16(%rbx)
	movl	%ecx, (%rax)
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L14:
	.cfi_restore_state
	addl	%ecx, %ecx
	movl	%ecx, 24(%rbx)
	movslq	%ecx, %rcx
	leaq	(%rcx,%rcx,2), %rsi
	salq	$2, %rsi
	call	realloc@PLT
	movl	16(%rbx), %ecx
	movq	%rax, (%rbx)
	movq	%rax, %rdi
	jmp	.L12
	.cfi_endproc
.LFE42:
	.size	add_edge, .-add_edge
	.p2align 4
	.globl	bellman_ford
	.type	bellman_ford, @function
bellman_ford:
.LFB43:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	%edx, %ebx
	movl	20(%rdi), %edx
	movq	%rdi, %r11
	testl	%edx, %edx
	jle	.L23
	movq	%rsi, %rdi
	xorl	%r8d, %r8d
	xorl	%r10d, %r10d
	.p2align 4,,10
	.p2align 3
.L22:
	movl	(%rdi,%r8,4), %esi
	cmpl	%ebx, %esi
	je	.L17
	movq	8(%r11), %rax
	movslq	(%rax,%r8,4), %rax
	cmpl	$-1, %eax
	je	.L17
	movq	(%r11), %r9
	.p2align 4,,10
	.p2align 3
.L21:
	leaq	(%rax,%rax,2), %rax
	leaq	(%r9,%rax,4), %rax
	movslq	(%rax), %rdx
	movl	8(%rax), %ecx
	leaq	(%rdi,%rdx,4), %rdx
	addl	%esi, %ecx
	cmpl	%ecx, (%rdx)
	jle	.L18
	movl	%ecx, (%rdx)
	movslq	4(%rax), %rax
	movl	$1, %r10d
	cmpl	$-1, %eax
	je	.L20
	movl	(%rdi,%r8,4), %esi
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L18:
	movslq	4(%rax), %rax
	cmpl	$-1, %eax
	jne	.L21
.L20:
	movl	20(%r11), %edx
.L17:
	addq	$1, %r8
	cmpl	%r8d, %edx
	jg	.L22
	movl	%r10d, %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L23:
	.cfi_restore_state
	xorl	%r10d, %r10d
	popq	%rbx
	.cfi_def_cfa_offset 8
	movl	%r10d, %eax
	ret
	.cfi_endproc
.LFE43:
	.size	bellman_ford, .-bellman_ford
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%i%i%i"
.LC1:
	.string	"NEGATIVE CYCLE"
.LC2:
	.string	"INF"
.LC3:
	.string	"%i\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB44:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rcx
	leaq	36(%rsp), %rdx
	leaq	32(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	32(%rsp), %r14
	movl	$32, %esi
	movl	$1, %edi
	movl	%r14d, 12(%rsp)
	call	calloc@PLT
	movl	$12, %esi
	movl	$1, %edi
	movq	%rax, %rbx
	call	calloc@PLT
	movl	$4, %esi
	movq	%r14, %rdi
	movq	%rax, (%rbx)
	call	calloc@PLT
	movl	$0, 16(%rbx)
	movq	%rax, 8(%rbx)
	movq	%rax, %rbp
	movl	%r14d, 20(%rbx)
	movl	$1, 24(%rbx)
	testl	%r14d, %r14d
	jle	.L31
	leaq	0(,%r14,4), %rdx
	movl	$255, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	36(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 36(%rsp)
	testl	%eax, %eax
	je	.L32
.L63:
	leaq	48(%rsp), %rax
	leaq	52(%rsp), %r15
	movq	%rax, (%rsp)
	leaq	44(%rsp), %r13
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L93:
	movq	(%rbx), %rax
.L34:
	movslq	%edx, %rsi
	leaq	(%rsi,%rsi,2), %rsi
	leaq	(%rax,%rsi,4), %rax
	leaq	0(%rbp,%r11,4), %rsi
	movd	(%rsi), %xmm1
	movl	%r10d, 8(%rax)
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%rax)
	leal	1(%rdx), %eax
	movl	%eax, 16(%rbx)
	movl	36(%rsp), %eax
	movl	%edx, (%rsi)
	leal	-1(%rax), %edx
	movl	%edx, 36(%rsp)
	testl	%eax, %eax
	je	.L92
.L35:
	movq	(%rsp), %rdx
	movq	%r15, %rcx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %r10d
	movd	48(%rsp), %xmm0
	movslq	44(%rsp), %r11
	movl	16(%rbx), %edx
	cmpl	24(%rbx), %edx
	jne	.L93
	leal	(%rdx,%rdx), %eax
	movq	(%rbx), %rdi
	movl	%r11d, 28(%rsp)
	movl	%eax, 24(%rbx)
	cltq
	leaq	(%rax,%rax,2), %rsi
	movl	%r10d, 20(%rsp)
	salq	$2, %rsi
	movl	%edx, 16(%rsp)
	movd	%xmm0, 24(%rsp)
	call	realloc@PLT
	movslq	28(%rsp), %r11
	movd	24(%rsp), %xmm0
	movl	20(%rsp), %r10d
	movl	16(%rsp), %edx
	movq	%rax, (%rbx)
	jmp	.L34
.L92:
	movslq	32(%rsp), %rdi
	movl	$4, %esi
	movl	%edi, (%rsp)
	call	calloc@PLT
	movl	(%rsp), %r9d
	movq	%rax, %r12
	imull	$10000, %r9d, %r13d
	addl	$1, %r13d
	testl	%r9d, %r9d
	jle	.L94
.L36:
	leal	-1(%r9), %r10d
	cmpl	$2, %r10d
	jbe	.L67
	movl	%r9d, %edx
	movd	%r13d, %xmm2
	movq	%r12, %rax
	shrl	$2, %edx
	pshufd	$0, %xmm2, %xmm0
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%r12,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L41:
	movups	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rax, %rdx
	jne	.L41
	movl	%r9d, %eax
	andl	$-4, %eax
	testb	$3, %r9b
	je	.L42
.L40:
	movslq	%eax, %rdx
	movl	%r13d, (%r12,%rdx,4)
	leaq	0(,%rdx,4), %rcx
	leal	1(%rax), %edx
	cmpl	%r9d, %edx
	jge	.L43
	addl	$2, %eax
	movl	%r13d, 4(%r12,%rcx)
	cmpl	%eax, %r9d
	jle	.L42
	movl	%r13d, 8(%r12,%rcx)
.L42:
	movslq	40(%rsp), %rax
	movl	$0, (%r12,%rax,4)
.L61:
	movl	12(%rsp), %edx
	xorl	%edi, %edi
	testl	%edx, %edx
	jle	.L39
	.p2align 4,,10
	.p2align 3
.L38:
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L48:
	movl	(%r12,%rcx,4), %edx
	cmpl	%r13d, %edx
	je	.L44
	movslq	0(%rbp,%rcx,4), %rax
	cmpl	$-1, %eax
	je	.L44
	movq	(%rbx), %rsi
	.p2align 4,,10
	.p2align 3
.L47:
	leaq	(%rax,%rax,2), %rax
	leaq	(%rsi,%rax,4), %rax
	movslq	(%rax), %r11
	movl	8(%rax), %r15d
	leaq	(%r12,%r11,4), %r11
	addl	%edx, %r15d
	cmpl	(%r11), %r15d
	jge	.L45
	movslq	4(%rax), %rax
	movl	%r15d, (%r11)
	cmpl	$-1, %eax
	je	.L44
	movl	(%r12,%rcx,4), %edx
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L53:
	movslq	4(%rax), %rax
	cmpl	$-1, %eax
	jne	.L55
	.p2align 4,,10
	.p2align 3
.L52:
	addq	$1, %rdi
	cmpq	%r11, %rdi
	jne	.L56
	testl	%r10d, %r10d
	jne	.L95
.L39:
	xorl	%ebx, %ebx
	leaq	.LC3(%rip), %rbp
	leaq	.LC2(%rip), %r15
	testl	%r9d, %r9d
	jle	.L30
	.p2align 4,,10
	.p2align 3
.L50:
	movl	(%r12,%rbx,4), %edx
	cmpl	%r13d, %edx
	je	.L96
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, 32(%rsp)
	jg	.L50
.L30:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L97
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L45:
	.cfi_restore_state
	movslq	4(%rax), %rax
	cmpl	$-1, %eax
	jne	.L47
	.p2align 4,,10
	.p2align 3
.L44:
	addq	$1, %rcx
	cmpq	%r14, %rcx
	jne	.L48
	addl	$1, %edi
	cmpl	%r10d, %edi
	jne	.L38
.L49:
	movl	12(%rsp), %r11d
	xorl	%edi, %edi
	xorl	%r10d, %r10d
	.p2align 4,,10
	.p2align 3
.L56:
	movl	(%r12,%rdi,4), %esi
	cmpl	%r13d, %esi
	je	.L52
	movslq	0(%rbp,%rdi,4), %rax
	cmpl	$-1, %eax
	je	.L52
	movq	(%rbx), %r8
	.p2align 4,,10
	.p2align 3
.L55:
	leaq	(%rax,%rax,2), %rax
	leaq	(%r8,%rax,4), %rax
	movslq	(%rax), %rdx
	movl	8(%rax), %ecx
	leaq	(%r12,%rdx,4), %rdx
	addl	%esi, %ecx
	cmpl	(%rdx), %ecx
	jge	.L53
	movslq	4(%rax), %rax
	movl	%ecx, (%rdx)
	movl	$1, %r10d
	cmpl	$-1, %eax
	je	.L52
	movl	(%r12,%rdi,4), %esi
	jmp	.L55
.L96:
	movq	%r15, %rdi
	addq	$1, %rbx
	call	puts@PLT
	cmpl	%ebx, 32(%rsp)
	jg	.L50
	jmp	.L30
.L95:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L30
.L94:
	leal	-1(%r9), %r10d
.L43:
	movslq	40(%rsp), %rax
	movl	$0, (%r12,%rax,4)
	testl	%r10d, %r10d
	jg	.L61
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jg	.L49
	jmp	.L39
	.p2align 4,,10
	.p2align 3
.L31:
	movl	36(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 36(%rsp)
	testl	%eax, %eax
	jne	.L63
	movq	%r14, %rdi
	movl	$4, %esi
	call	calloc@PLT
	movl	12(%rsp), %edi
	movq	%rax, %r12
	movslq	40(%rsp), %rax
	imull	$10000, %edi, %r13d
	leal	-1(%rdi), %r10d
	movl	%edi, %r9d
	movl	$0, (%r12,%rax,4)
	addl	$1, %r13d
	testl	%r10d, %r10d
	jle	.L39
	jmp	.L61
	.p2align 4,,10
	.p2align 3
.L67:
	xorl	%eax, %eax
	jmp	.L40
.L97:
	call	__stack_chk_fail@PLT
	.p2align 4,,10
	.p2align 3
.L32:
	movl	$4, %esi
	movq	%r14, %rdi
	call	calloc@PLT
	movl	12(%rsp), %r9d
	movq	%rax, %r12
	imull	$10000, %r9d, %r13d
	addl	$1, %r13d
	jmp	.L36
	.cfi_endproc
.LFE44:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB45:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE45:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

rule
	.file	"temp.c"
	.text
	.p2align 4
	.globl	new_graph
	.type	new_graph, @function
new_graph:
.LFB39:
	.cfi_startproc
	endbr64
	pushq	%r12
	.cfi_def_cfa_offset 16
	.cfi_offset 12, -16
	movl	$32, %esi
	pushq	%rbp
	.cfi_def_cfa_offset 24
	.cfi_offset 6, -24
	movslq	%edi, %rbp
	movl	$1, %edi
	pushq	%rbx
	.cfi_def_cfa_offset 32
	.cfi_offset 3, -32
	call	calloc@PLT
	movl	$12, %esi
	movl	$1, %edi
	movq	%rax, %r12
	call	calloc@PLT
	movl	$4, %esi
	movq	%rbp, %rdi
	movq	%rax, (%r12)
	call	calloc@PLT
	movl	%ebp, 20(%r12)
	movq	%rax, 8(%r12)
	movl	$0, 16(%r12)
	movl	$1, 24(%r12)
	testl	%ebp, %ebp
	jle	.L1
	movq	%rax, %rdi
	leaq	0(,%rbp,4), %rdx
	movl	$255, %esi
	call	memset@PLT
.L1:
	movq	%r12, %rax
	popq	%rbx
	.cfi_def_cfa_offset 24
	popq	%rbp
	.cfi_def_cfa_offset 16
	popq	%r12
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE39:
	.size	new_graph, .-new_graph
	.p2align 4
	.globl	free_graph
	.type	free_graph, @function
free_graph:
.LFB40:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rdi, %rbp
	movq	(%rdi), %rdi
	call	free@PLT
	movq	8(%rbp), %rdi
	call	free@PLT
	movq	%rbp, %rdi
	popq	%rbp
	.cfi_def_cfa_offset 8
	jmp	free@PLT
	.cfi_endproc
.LFE40:
	.size	free_graph, .-free_graph
	.p2align 4
	.globl	clear_graph
	.type	clear_graph, @function
clear_graph:
.LFB41:
	.cfi_startproc
	endbr64
	movl	20(%rdi), %eax
	movl	$0, 16(%rdi)
	testl	%eax, %eax
	jle	.L7
	movq	8(%rdi), %rdx
	xorl	%eax, %eax
	.p2align 4,,10
	.p2align 3
.L9:
	movl	$-1, (%rdx,%rax,4)
	addq	$1, %rax
	cmpl	%eax, 20(%rdi)
	jg	.L9
.L7:
	ret
	.cfi_endproc
.LFE41:
	.size	clear_graph, .-clear_graph
	.p2align 4
	.globl	add_edge
	.type	add_edge, @function
add_edge:
.LFB42:
	.cfi_startproc
	endbr64
	pushq	%r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	movl	%edx, %r13d
	pushq	%r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	movl	%ecx, %r12d
	pushq	%rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	movslq	%esi, %rbp
	pushq	%rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	movq	%rdi, %rbx
	subq	$8, %rsp
	.cfi_def_cfa_offset 48
	movl	16(%rdi), %ecx
	movq	(%rdi), %rdi
	cmpl	24(%rbx), %ecx
	je	.L14
.L12:
	movslq	%ecx, %rax
	movd	%r13d, %xmm0
	leal	1(%rcx), %edx
	leaq	(%rax,%rax,2), %rax
	leaq	(%rdi,%rax,4), %rsi
	movq	8(%rbx), %rax
	leaq	(%rax,%rbp,4), %rax
	movd	(%rax), %xmm1
	movl	%r12d, 8(%rsi)
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%rsi)
	movl	%edx, 16(%rbx)
	movl	%ecx, (%rax)
	addq	$8, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	popq	%rbx
	.cfi_def_cfa_offset 32
	popq	%rbp
	.cfi_def_cfa_offset 24
	popq	%r12
	.cfi_def_cfa_offset 16
	popq	%r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L14:
	.cfi_restore_state
	addl	%ecx, %ecx
	movl	%ecx, 24(%rbx)
	movslq	%ecx, %rcx
	leaq	(%rcx,%rcx,2), %rsi
	salq	$2, %rsi
	call	realloc@PLT
	movl	16(%rbx), %ecx
	movq	%rax, (%rbx)
	movq	%rax, %rdi
	jmp	.L12
	.cfi_endproc
.LFE42:
	.size	add_edge, .-add_edge
	.p2align 4
	.globl	bellman_ford
	.type	bellman_ford, @function
bellman_ford:
.LFB43:
	.cfi_startproc
	endbr64
	pushq	%rbx
	.cfi_def_cfa_offset 16
	.cfi_offset 3, -16
	movl	%edx, %ebx
	movl	20(%rdi), %edx
	movq	%rdi, %r11
	testl	%edx, %edx
	jle	.L23
	movq	%rsi, %rdi
	xorl	%r8d, %r8d
	xorl	%r10d, %r10d
	.p2align 4,,10
	.p2align 3
.L22:
	movl	(%rdi,%r8,4), %esi
	cmpl	%ebx, %esi
	je	.L17
	movq	8(%r11), %rax
	movslq	(%rax,%r8,4), %rax
	cmpl	$-1, %eax
	je	.L17
	movq	(%r11), %r9
	.p2align 4,,10
	.p2align 3
.L21:
	leaq	(%rax,%rax,2), %rax
	leaq	(%r9,%rax,4), %rax
	movslq	(%rax), %rdx
	movl	8(%rax), %ecx
	leaq	(%rdi,%rdx,4), %rdx
	addl	%esi, %ecx
	cmpl	%ecx, (%rdx)
	jle	.L18
	movl	%ecx, (%rdx)
	movslq	4(%rax), %rax
	movl	$1, %r10d
	cmpl	$-1, %eax
	je	.L20
	movl	(%rdi,%r8,4), %esi
	jmp	.L21
	.p2align 4,,10
	.p2align 3
.L18:
	movslq	4(%rax), %rax
	cmpl	$-1, %eax
	jne	.L21
.L20:
	movl	20(%r11), %edx
.L17:
	addq	$1, %r8
	cmpl	%r8d, %edx
	jg	.L22
	movl	%r10d, %eax
	popq	%rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 8
	ret
.L23:
	.cfi_restore_state
	xorl	%r10d, %r10d
	popq	%rbx
	.cfi_def_cfa_offset 8
	movl	%r10d, %eax
	ret
	.cfi_endproc
.LFE43:
	.size	bellman_ford, .-bellman_ford
	.section	.rodata.str1.1,"aMS",@progbits,1
.LC0:
	.string	"%i%i%i"
.LC1:
	.string	"NEGATIVE CYCLE"
.LC2:
	.string	"INF"
.LC3:
	.string	"%i\n"
	.text
	.p2align 4
	.globl	run
	.type	run, @function
run:
.LFB44:
	.cfi_startproc
	endbr64
	pushq	%r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	pushq	%r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	pushq	%r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	pushq	%r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	leaq	.LC0(%rip), %r12
	pushq	%rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	movq	%r12, %rdi
	pushq	%rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	subq	$72, %rsp
	.cfi_def_cfa_offset 128
	movq	%fs:40, %rax
	movq	%rax, 56(%rsp)
	xorl	%eax, %eax
	leaq	40(%rsp), %rcx
	leaq	36(%rsp), %rdx
	leaq	32(%rsp), %rsi
	call	__isoc99_scanf@PLT
	movslq	32(%rsp), %r14
	movl	$32, %esi
	movl	$1, %edi
	movl	%r14d, 12(%rsp)
	call	calloc@PLT
	movl	$12, %esi
	movl	$1, %edi
	movq	%rax, %rbx
	call	calloc@PLT
	movl	$4, %esi
	movq	%r14, %rdi
	movq	%rax, (%rbx)
	call	calloc@PLT
	movl	$0, 16(%rbx)
	movq	%rax, 8(%rbx)
	movq	%rax, %rbp
	movl	%r14d, 20(%rbx)
	movl	$1, 24(%rbx)
	testl	%r14d, %r14d
	jle	.L31
	leaq	0(,%r14,4), %rdx
	movl	$255, %esi
	movq	%rax, %rdi
	call	memset@PLT
	movl	36(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 36(%rsp)
	testl	%eax, %eax
	je	.L32
.L63:
	leaq	48(%rsp), %rax
	leaq	52(%rsp), %r15
	movq	%rax, (%rsp)
	leaq	44(%rsp), %r13
	jmp	.L35
	.p2align 4,,10
	.p2align 3
.L93:
	movq	(%rbx), %rax
.L34:
	movslq	%edx, %rsi
	leaq	(%rsi,%rsi,2), %rsi
	leaq	(%rax,%rsi,4), %rax
	leaq	0(%rbp,%r11,4), %rsi
	movd	(%rsi), %xmm1
	movl	%r10d, 8(%rax)
	punpckldq	%xmm1, %xmm0
	movq	%xmm0, (%rax)
	leal	1(%rdx), %eax
	movl	%eax, 16(%rbx)
	movl	36(%rsp), %eax
	movl	%edx, (%rsi)
	leal	-1(%rax), %edx
	movl	%edx, 36(%rsp)
	testl	%eax, %eax
	je	.L92
.L35:
	movq	(%rsp), %rdx
	movq	%r15, %rcx
	movq	%r13, %rsi
	movq	%r12, %rdi
	xorl	%eax, %eax
	call	__isoc99_scanf@PLT
	movl	52(%rsp), %r10d
	movd	48(%rsp), %xmm0
	movslq	44(%rsp), %r11
	movl	16(%rbx), %edx
	cmpl	24(%rbx), %edx
	jne	.L93
	leal	(%rdx,%rdx), %eax
	movq	(%rbx), %rdi
	movl	%r11d, 28(%rsp)
	movl	%eax, 24(%rbx)
	cltq
	leaq	(%rax,%rax,2), %rsi
	movl	%r10d, 20(%rsp)
	salq	$2, %rsi
	movl	%edx, 16(%rsp)
	movd	%xmm0, 24(%rsp)
	call	realloc@PLT
	movslq	28(%rsp), %r11
	movd	24(%rsp), %xmm0
	movl	20(%rsp), %r10d
	movl	16(%rsp), %edx
	movq	%rax, (%rbx)
	jmp	.L34
.L92:
	movslq	32(%rsp), %rdi
	movl	$4, %esi
	movl	%edi, (%rsp)
	call	calloc@PLT
	movl	(%rsp), %r9d
	movq	%rax, %r12
	imull	$10000, %r9d, %r13d
	addl	$1, %r13d
	testl	%r9d, %r9d
	jle	.L94
.L36:
	leal	-1(%r9), %r10d
	cmpl	$2, %r10d
	jbe	.L67
	movl	%r9d, %edx
	movd	%r13d, %xmm2
	movq	%r12, %rax
	shrl	$2, %edx
	pshufd	$0, %xmm2, %xmm0
	subl	$1, %edx
	salq	$4, %rdx
	leaq	16(%r12,%rdx), %rdx
	.p2align 4,,10
	.p2align 3
.L41:
	movups	%xmm0, (%rax)
	addq	$16, %rax
	cmpq	%rax, %rdx
	jne	.L41
	movl	%r9d, %eax
	andl	$-4, %eax
	testb	$3, %r9b
	je	.L42
.L40:
	movslq	%eax, %rdx
	movl	%r13d, (%r12,%rdx,4)
	leaq	0(,%rdx,4), %rcx
	leal	1(%rax), %edx
	cmpl	%r9d, %edx
	jge	.L43
	addl	$2, %eax
	movl	%r13d, 4(%r12,%rcx)
	cmpl	%eax, %r9d
	jle	.L42
	movl	%r13d, 8(%r12,%rcx)
.L42:
	movslq	40(%rsp), %rax
	movl	$0, (%r12,%rax,4)
.L61:
	movl	12(%rsp), %edx
	xorl	%edi, %edi
	testl	%edx, %edx
	jle	.L39
	.p2align 4,,10
	.p2align 3
.L38:
	xorl	%ecx, %ecx
	.p2align 4,,10
	.p2align 3
.L48:
	movl	(%r12,%rcx,4), %edx
	cmpl	%r13d, %edx
	je	.L44
	movslq	0(%rbp,%rcx,4), %rax
	cmpl	$-1, %eax
	je	.L44
	movq	(%rbx), %rsi
	.p2align 4,,10
	.p2align 3
.L47:
	leaq	(%rax,%rax,2), %rax
	leaq	(%rsi,%rax,4), %rax
	movslq	(%rax), %r11
	movl	8(%rax), %r15d
	leaq	(%r12,%r11,4), %r11
	addl	%edx, %r15d
	cmpl	(%r11), %r15d
	jge	.L45
	movslq	4(%rax), %rax
	movl	%r15d, (%r11)
	cmpl	$-1, %eax
	je	.L44
	movl	(%r12,%rcx,4), %edx
	jmp	.L47
	.p2align 4,,10
	.p2align 3
.L53:
	movslq	4(%rax), %rax
	cmpl	$-1, %eax
	jne	.L55
	.p2align 4,,10
	.p2align 3
.L52:
	addq	$1, %rdi
	cmpq	%r11, %rdi
	jne	.L56
	testl	%r10d, %r10d
	jne	.L95
.L39:
	xorl	%ebx, %ebx
	leaq	.LC3(%rip), %rbp
	leaq	.LC2(%rip), %r15
	testl	%r9d, %r9d
	jle	.L30
	.p2align 4,,10
	.p2align 3
.L50:
	movl	(%r12,%rbx,4), %edx
	cmpl	%r13d, %edx
	je	.L96
	movq	%rbp, %rsi
	movl	$1, %edi
	xorl	%eax, %eax
	addq	$1, %rbx
	call	__printf_chk@PLT
	cmpl	%ebx, 32(%rsp)
	jg	.L50
.L30:
	movq	56(%rsp), %rax
	subq	%fs:40, %rax
	jne	.L97
	addq	$72, %rsp
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	popq	%rbx
	.cfi_def_cfa_offset 48
	popq	%rbp
	.cfi_def_cfa_offset 40
	popq	%r12
	.cfi_def_cfa_offset 32
	popq	%r13
	.cfi_def_cfa_offset 24
	popq	%r14
	.cfi_def_cfa_offset 16
	popq	%r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L45:
	.cfi_restore_state
	movslq	4(%rax), %rax
	cmpl	$-1, %eax
	jne	.L47
	.p2align 4,,10
	.p2align 3
.L44:
	addq	$1, %rcx
	cmpq	%r14, %rcx
	jne	.L48
	addl	$1, %edi
	cmpl	%r10d, %edi
	jne	.L38
.L49:
	movl	12(%rsp), %r11d
	xorl	%edi, %edi
	xorl	%r10d, %r10d
	.p2align 4,,10
	.p2align 3
.L56:
	movl	(%r12,%rdi,4), %esi
	cmpl	%r13d, %esi
	je	.L52
	movslq	0(%rbp,%rdi,4), %rax
	cmpl	$-1, %eax
	je	.L52
	movq	(%rbx), %r8
	.p2align 4,,10
	.p2align 3
.L55:
	leaq	(%rax,%rax,2), %rax
	leaq	(%r8,%rax,4), %rax
	movslq	(%rax), %rdx
	movl	8(%rax), %ecx
	leaq	(%r12,%rdx,4), %rdx
	addl	%esi, %ecx
	cmpl	(%rdx), %ecx
	jge	.L53
	movslq	4(%rax), %rax
	movl	%ecx, (%rdx)
	movl	$1, %r10d
	cmpl	$-1, %eax
	je	.L52
	movl	(%r12,%rdi,4), %esi
	jmp	.L55
.L96:
	movq	%r15, %rdi
	addq	$1, %rbx
	call	puts@PLT
	cmpl	%ebx, 32(%rsp)
	jg	.L50
	jmp	.L30
.L95:
	leaq	.LC1(%rip), %rdi
	call	puts@PLT
	jmp	.L30
.L94:
	leal	-1(%r9), %r10d
.L43:
	movslq	40(%rsp), %rax
	movl	$0, (%r12,%rax,4)
	testl	%r10d, %r10d
	jg	.L61
	movl	12(%rsp), %eax
	testl	%eax, %eax
	jg	.L49
	jmp	.L39
	.p2align 4,,10
	.p2align 3
.L31:
	movl	36(%rsp), %eax
	leal	-1(%rax), %edx
	movl	%edx, 36(%rsp)
	testl	%eax, %eax
	jne	.L63
	movq	%r14, %rdi
	movl	$4, %esi
	call	calloc@PLT
	movl	12(%rsp), %edi
	movq	%rax, %r12
	movslq	40(%rsp), %rax
	imull	$10000, %edi, %r13d
	leal	-1(%rdi), %r10d
	movl	%edi, %r9d
	movl	$0, (%r12,%rax,4)
	addl	$1, %r13d
	testl	%r10d, %r10d
	jle	.L39
	jmp	.L61
	.p2align 4,,10
	.p2align 3
.L67:
	xorl	%eax, %eax
	jmp	.L40
.L97:
	call	__stack_chk_fail@PLT
	.p2align 4,,10
	.p2align 3
.L32:
	movl	$4, %esi
	movq	%r14, %rdi
	call	calloc@PLT
	movl	12(%rsp), %r9d
	movq	%rax, %r12
	imull	$10000, %r9d, %r13d
	addl	$1, %r13d
	jmp	.L36
	.cfi_endproc
.LFE44:
	.size	run, .-run
	.section	.text.startup,"ax",@progbits
	.p2align 4
	.globl	main
	.type	main, @function
main:
.LFB45:
	.cfi_startproc
	endbr64
	subq	$8, %rsp
	.cfi_def_cfa_offset 16
	call	run
	xorl	%eax, %eax
	addq	$8, %rsp
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE45:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:

#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t edge_weight;

typedef struct directed_edge {
  int32_t vertex;
  int32_t next;
  edge_weight cost;
} graph_edge;

typedef struct directedGraph {
  graph_edge *edge;
  int32_t *start;
  int32_t pointer;
  int32_t vertex_num;
  int32_t edge_max_size;
} graph;

graph* new_graph (const int vertex_num) {
  graph *g = (graph *) calloc (1, sizeof (graph));
  g->edge = (graph_edge *) calloc (1, sizeof (graph_edge));
  g->start = (int32_t *) calloc (vertex_num, sizeof (int32_t));
  g->pointer = 0;
  g->vertex_num = vertex_num;
  g->edge_max_size = 1;
  for (int32_t i = 0; i < vertex_num; ++i) {
    g->start[i] = -1;
  }
  return g;
}

void free_graph (graph *g) {
  free (g->edge);
  free (g->start);
  free (g);
  return;
}

void clear_graph (graph *g) {
  g->pointer = 0;
  for (int32_t i = 0; i < g->vertex_num; ++i) {
    g->start[i] = -1;
  }
}

void add_edge (graph *g, int32_t from, int32_t to, edge_weight cost) {
  if (g->pointer == g->edge_max_size) {
    g->edge_max_size *= 2;
    g->edge = (graph_edge *) realloc (g->edge, sizeof (graph_edge) * g->edge_max_size);
  }
  g->edge[g->pointer] = (graph_edge) {to, g->start[from], cost};
  g->start[from] = g->pointer++;
}

typedef int32_t i32;

int bellman_ford (graph *g, i32 *dp, i32 inf) {
  int update = 0;
  for (i32 i = 0; i < g->vertex_num; ++i) {
    if (dp[i] == inf) continue;
    for (i32 p = g->start[i]; p != -1; p = g->edge[p].next) {
      i32 u = g->edge[p].vertex;
      i32 d = dp[i] + g->edge[p].cost;
      if (d >= dp[u]) continue;
      update = 1;
      dp[u] = d;
    }
  }
  return update;
}

void run (void) {
  i32 v, e, r;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &v, &e, &r);
  graph *g = new_graph (v);
  while (e--) {
    i32 s, t, d;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &s, &t, &d);
    add_edge (g, s, t, d);
  }
  i32 *dp = (i32 *) calloc (v, sizeof (i32));
  const i32 inf = 10000 * v + 1;
  for (i32 i = 0; i < v; ++i) {
    dp[i] = inf;
  }
  dp[r] = 0;
  for (i32 iter = 0; iter < v - 1; ++iter) {
    bellman_ford (g, dp, inf);
  }
  if (bellman_ford (g, dp, inf)) {
    puts ("NEGATIVE CYCLE");
    return;
  }
  for (i32 i = 0; i < v; ++i) {
    if (dp[i] == inf) {
      puts ("INF");
    } else {
      printf ("%" PRIi32 "\n", dp[i]);
    }
  }
}

int main (void) {
  run ();
  return 0;
}


4 5 1
0 1 2
0 3 3
1 2 -5
1 3 1
2 3 2
 4 5 0
0 1 2
0 2 3
1 2 -5
2 3 1
2 3 2
 4 6 0
0 1 2
0 2 3
1 2 -5
1 3 1
3 3 2
3 1 0
 4 5 0
0 1 2
0 2 3
1 0 -5
2 3 1
2 3 2
 4 5 2
0 1 2
0 3 3
1 2 -5
1 3 2
2 3 2
 4 0 1
0 0 2
1 2 3
2 0 -5
2 3 1
0 2 2
 4 5 1
0 1 2
0 2 3
1 2 -5
1 3 1
0 3 2
 4 5 0
0 1 3
0 2 3
1 2 -5
1 3 1
2 3 2
 4 0 0
0 1 2
0 2 3
1 2 -5
2 3 1
2 3 2
 4 5 1
0 1 2
1 2 3
2 0 -5
2 3 1
0 3 2

INF
0
-5
-3
 0
2
-3
-2
 0
2
-3
3
 NEGATIVE CYCLE
 INF
INF
0
2
 INF
0
INF
INF
 INF
0
-5
1
 0
3
-2
0
 0
INF
INF
INF
 -2
0
3
0

Given the following C code and unoptimized assembly code, your task is to generate highly optimized x86-64 assembly code.
C Code:

```c
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t edge_weight;

typedef struct directed_edge {
  int32_t vertex;
  int32_t next;
  edge_weight cost;
} graph_edge;

typedef struct directedGraph {
  graph_edge *edge;
  int32_t *start;
  int32_t pointer;
  int32_t vertex_num;
  int32_t edge_max_size;
} graph;

graph* new_graph (const int vertex_num) {
  graph *g = (graph *) calloc (1, sizeof (graph));
  g->edge = (graph_edge *) calloc (1, sizeof (graph_edge));
  g->start = (int32_t *) calloc (vertex_num, sizeof (int32_t));
  g->pointer = 0;
  g->vertex_num = vertex_num;
  g->edge_max_size = 1;
  for (int32_t i = 0; i < vertex_num; ++i) {
    g->start[i] = -1;
  }
  return g;
}

void free_graph (graph *g) {
  free (g->edge);
  free (g->start);
  free (g);
  return;
}

void clear_graph (graph *g) {
  g->pointer = 0;
  for (int32_t i = 0; i < g->vertex_num; ++i) {
    g->start[i] = -1;
  }
}

void add_edge (graph *g, int32_t from, int32_t to, edge_weight cost) {
  if (g->pointer == g->edge_max_size) {
    g->edge_max_size *= 2;
    g->edge = (graph_edge *) realloc (g->edge, sizeof (graph_edge) * g->edge_max_size);
  }
  g->edge[g->pointer] = (graph_edge) {to, g->start[from], cost};
  g->start[from] = g->pointer++;
}

typedef int32_t i32;

int bellman_ford (graph *g, i32 *dp, i32 inf) {
  int update = 0;
  for (i32 i = 0; i < g->vertex_num; ++i) {
    if (dp[i] == inf) continue;
    for (i32 p = g->start[i]; p != -1; p = g->edge[p].next) {
      i32 u = g->edge[p].vertex;
      i32 d = dp[i] + g->edge[p].cost;
      if (d >= dp[u]) continue;
      update = 1;
      dp[u] = d;
    }
  }
  return update;
}

void run (void) {
  i32 v, e, r;
  scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &v, &e, &r);
  graph *g = new_graph (v);
  while (e--) {
    i32 s, t, d;
    scanf ("%" SCNi32 "%" SCNi32 "%" SCNi32, &s, &t, &d);
    add_edge (g, s, t, d);
  }
  i32 *dp = (i32 *) calloc (v, sizeof (i32));
  const i32 inf = 10000 * v + 1;
  for (i32 i = 0; i < v; ++i) {
    dp[i] = inf;
  }
  dp[r] = 0;
  for (i32 iter = 0; iter < v - 1; ++iter) {
    bellman_ford (g, dp, inf);
  }
  if (bellman_ford (g, dp, inf)) {
    puts ("NEGATIVE CYCLE");
    return;
  }
  for (i32 i = 0; i < v; ++i) {
    if (dp[i] == inf) {
      puts ("INF");
    } else {
      printf ("%" PRIi32 "\n", dp[i]);
    }
  }
}

int main (void) {
  run ();
  return 0;
}

```

Unoptimized Assembly Code:

```assembly
	.file	"temp.c"
	.text
	.globl	new_graph
	.type	new_graph, @function
new_graph:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$32, %esi
	movl	$1, %edi
	call	calloc@PLT
	movq	%rax, -8(%rbp)
	movl	$12, %esi
	movl	$1, %edi
	call	calloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, (%rax)
	movl	-20(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	movl	$0, 16(%rax)
	movq	-8(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 20(%rax)
	movq	-8(%rbp), %rax
	movl	$1, 24(%rax)
	movl	$0, -12(%rbp)
	jmp	.L2
.L3:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rdx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -12(%rbp)
.L2:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	new_graph, .-new_graph
	.globl	free_graph
	.type	free_graph, @function
free_graph:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	free_graph, .-free_graph
	.globl	clear_graph
	.type	clear_graph, @function
clear_graph:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movl	$0, 16(%rax)
	movl	$0, -4(%rbp)
	jmp	.L8
.L9:
	movq	-24(%rbp), %rax
	movq	8(%rax), %rdx
	movl	-4(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -4(%rbp)
.L8:
	movq	-24(%rbp), %rax
	movl	20(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L9
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	clear_graph, .-clear_graph
	.globl	add_edge
	.type	add_edge, @function
add_edge:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	%ecx, -36(%rbp)
	movq	-24(%rbp), %rax
	movl	16(%rax), %edx
	movq	-24(%rbp), %rax
	movl	24(%rax), %eax
	cmpl	%eax, %edx
	jne	.L11
	movq	-24(%rbp), %rax
	movl	24(%rax), %eax
	leal	(%rax,%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 24(%rax)
	movq	-24(%rbp), %rax
	movl	24(%rax), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	-24(%rbp), %rdx
	movq	%rax, (%rdx)
.L11:
	movq	-24(%rbp), %rax
	movq	(%rax), %rcx
	movq	-24(%rbp), %rax
	movl	16(%rax), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movq	-24(%rbp), %rdx
	movq	8(%rdx), %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	movl	-32(%rbp), %ecx
	movl	%ecx, (%rax)
	movl	%edx, 4(%rax)
	movl	-36(%rbp), %edx
	movl	%edx, 8(%rax)
	movq	-24(%rbp), %rax
	movl	16(%rax), %eax
	leal	1(%rax), %ecx
	movq	-24(%rbp), %rdx
	movl	%ecx, 16(%rdx)
	movq	-24(%rbp), %rdx
	movq	8(%rdx), %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	movl	%eax, (%rdx)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	add_edge, .-add_edge
	.globl	bellman_ford
	.type	bellman_ford, @function
bellman_ford:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movl	%edx, -52(%rbp)
	movl	$0, -20(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L13
.L20:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -52(%rbp)
	je	.L22
	movq	-40(%rbp), %rax
	movq	8(%rax), %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -12(%rbp)
	jmp	.L16
.L19:
	movq	-40(%rbp), %rax
	movq	(%rax), %rcx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-40(%rbp), %rax
	movq	(%rax), %rsi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	8(%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L23
	movl	$1, -20(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L18
.L23:
	nop
.L18:
	movq	-40(%rbp), %rax
	movq	(%rax), %rcx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	movl	%eax, -12(%rbp)
.L16:
	cmpl	$-1, -12(%rbp)
	jne	.L19
	jmp	.L15
.L22:
	nop
.L15:
	addl	$1, -16(%rbp)
.L13:
	movq	-40(%rbp), %rax
	movl	20(%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	movl	-20(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	bellman_ford, .-bellman_ford
	.section	.rodata
.LC0:
	.string	"%i%i%i"
.LC1:
	.string	"NEGATIVE CYCLE"
.LC2:
	.string	"INF"
.LC3:
	.string	"%i\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rcx
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-64(%rbp), %eax
	movl	%eax, %edi
	call	new_graph
	movq	%rax, -24(%rbp)
	jmp	.L25
.L26:
	leaq	-44(%rbp), %rcx
	leaq	-48(%rbp), %rdx
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %ecx
	movl	-48(%rbp), %edx
	movl	-52(%rbp), %esi
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	add_edge
.L25:
	movl	-60(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -60(%rbp)
	testl	%eax, %eax
	jne	.L26
	movl	-64(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	-64(%rbp), %eax
	imull	$10000, %eax, %eax
	addl	$1, %eax
	movl	%eax, -28(%rbp)
	movl	$0, -40(%rbp)
	jmp	.L27
.L28:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-28(%rbp), %eax
	movl	%eax, (%rdx)
	addl	$1, -40(%rbp)
.L27:
	movl	-64(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L28
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	movl	$0, -36(%rbp)
	jmp	.L29
.L30:
	movl	-28(%rbp), %edx
	movq	-16(%rbp), %rcx
	movq	-24(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	bellman_ford
	addl	$1, -36(%rbp)
.L29:
	movl	-64(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -36(%rbp)
	jl	.L30
	movl	-28(%rbp), %edx
	movq	-16(%rbp), %rcx
	movq	-24(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	bellman_ford
	testl	%eax, %eax
	je	.L31
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L24
.L31:
	movl	$0, -32(%rbp)
	jmp	.L33
.L36:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L34
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L35
.L34:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L35:
	addl	$1, -32(%rbp)
.L33:
	movl	-64(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L36
.L24:
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
```

Only output the optimized assembly code. Do not include any other text. Do not write any comments in the assembly code. Wrap the assembly code in ```assembly``` tags.
train
	.file	"temp.c"
	.text
	.globl	new_graph
	.type	new_graph, @function
new_graph:
.LFB6:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$32, %rsp
	movl	%edi, -20(%rbp)
	movl	$32, %esi
	movl	$1, %edi
	call	calloc@PLT
	movq	%rax, -8(%rbp)
	movl	$12, %esi
	movl	$1, %edi
	call	calloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, (%rax)
	movl	-20(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, %rdx
	movq	-8(%rbp), %rax
	movq	%rdx, 8(%rax)
	movq	-8(%rbp), %rax
	movl	$0, 16(%rax)
	movq	-8(%rbp), %rax
	movl	-20(%rbp), %edx
	movl	%edx, 20(%rax)
	movq	-8(%rbp), %rax
	movl	$1, 24(%rax)
	movl	$0, -12(%rbp)
	jmp	.L2
.L3:
	movq	-8(%rbp), %rax
	movq	8(%rax), %rdx
	movl	-12(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -12(%rbp)
.L2:
	movl	-12(%rbp), %eax
	cmpl	-20(%rbp), %eax
	jl	.L3
	movq	-8(%rbp), %rax
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE6:
	.size	new_graph, .-new_graph
	.globl	free_graph
	.type	free_graph, @function
free_graph:
.LFB7:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$16, %rsp
	movq	%rdi, -8(%rbp)
	movq	-8(%rbp), %rax
	movq	(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	8(%rax), %rax
	movq	%rax, %rdi
	call	free@PLT
	movq	-8(%rbp), %rax
	movq	%rax, %rdi
	call	free@PLT
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE7:
	.size	free_graph, .-free_graph
	.globl	clear_graph
	.type	clear_graph, @function
clear_graph:
.LFB8:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -24(%rbp)
	movq	-24(%rbp), %rax
	movl	$0, 16(%rax)
	movl	$0, -4(%rbp)
	jmp	.L8
.L9:
	movq	-24(%rbp), %rax
	movq	8(%rax), %rdx
	movl	-4(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	$-1, (%rax)
	addl	$1, -4(%rbp)
.L8:
	movq	-24(%rbp), %rax
	movl	20(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jl	.L9
	nop
	nop
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE8:
	.size	clear_graph, .-clear_graph
	.globl	add_edge
	.type	add_edge, @function
add_edge:
.LFB9:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$48, %rsp
	movq	%rdi, -24(%rbp)
	movl	%esi, -28(%rbp)
	movl	%edx, -32(%rbp)
	movl	%ecx, -36(%rbp)
	movq	-24(%rbp), %rax
	movl	16(%rax), %edx
	movq	-24(%rbp), %rax
	movl	24(%rax), %eax
	cmpl	%eax, %edx
	jne	.L11
	movq	-24(%rbp), %rax
	movl	24(%rax), %eax
	leal	(%rax,%rax), %edx
	movq	-24(%rbp), %rax
	movl	%edx, 24(%rax)
	movq	-24(%rbp), %rax
	movl	24(%rax), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	movq	%rax, %rdx
	movq	-24(%rbp), %rax
	movq	(%rax), %rax
	movq	%rdx, %rsi
	movq	%rax, %rdi
	call	realloc@PLT
	movq	-24(%rbp), %rdx
	movq	%rax, (%rdx)
.L11:
	movq	-24(%rbp), %rax
	movq	(%rax), %rcx
	movq	-24(%rbp), %rax
	movl	16(%rax), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movq	-24(%rbp), %rdx
	movq	8(%rdx), %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	movl	(%rdx), %edx
	movl	-32(%rbp), %ecx
	movl	%ecx, (%rax)
	movl	%edx, 4(%rax)
	movl	-36(%rbp), %edx
	movl	%edx, 8(%rax)
	movq	-24(%rbp), %rax
	movl	16(%rax), %eax
	leal	1(%rax), %ecx
	movq	-24(%rbp), %rdx
	movl	%ecx, 16(%rdx)
	movq	-24(%rbp), %rdx
	movq	8(%rdx), %rcx
	movl	-28(%rbp), %edx
	movslq	%edx, %rdx
	salq	$2, %rdx
	addq	%rcx, %rdx
	movl	%eax, (%rdx)
	nop
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE9:
	.size	add_edge, .-add_edge
	.globl	bellman_ford
	.type	bellman_ford, @function
bellman_ford:
.LFB10:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	movq	%rdi, -40(%rbp)
	movq	%rsi, -48(%rbp)
	movl	%edx, -52(%rbp)
	movl	$0, -20(%rbp)
	movl	$0, -16(%rbp)
	jmp	.L13
.L20:
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -52(%rbp)
	je	.L22
	movq	-40(%rbp), %rax
	movq	8(%rax), %rdx
	movl	-16(%rbp), %eax
	cltq
	salq	$2, %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, -12(%rbp)
	jmp	.L16
.L19:
	movq	-40(%rbp), %rax
	movq	(%rax), %rcx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	(%rax), %eax
	movl	%eax, -8(%rbp)
	movl	-16(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %ecx
	movq	-40(%rbp), %rax
	movq	(%rax), %rsi
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rsi, %rax
	movl	8(%rax), %eax
	addl	%ecx, %eax
	movl	%eax, -4(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -4(%rbp)
	jge	.L23
	movl	$1, -20(%rbp)
	movl	-8(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-48(%rbp), %rax
	addq	%rax, %rdx
	movl	-4(%rbp), %eax
	movl	%eax, (%rdx)
	jmp	.L18
.L23:
	nop
.L18:
	movq	-40(%rbp), %rax
	movq	(%rax), %rcx
	movl	-12(%rbp), %eax
	movslq	%eax, %rdx
	movq	%rdx, %rax
	addq	%rax, %rax
	addq	%rdx, %rax
	salq	$2, %rax
	addq	%rcx, %rax
	movl	4(%rax), %eax
	movl	%eax, -12(%rbp)
.L16:
	cmpl	$-1, -12(%rbp)
	jne	.L19
	jmp	.L15
.L22:
	nop
.L15:
	addl	$1, -16(%rbp)
.L13:
	movq	-40(%rbp), %rax
	movl	20(%rax), %eax
	cmpl	%eax, -16(%rbp)
	jl	.L20
	movl	-20(%rbp), %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE10:
	.size	bellman_ford, .-bellman_ford
	.section	.rodata
.LC0:
	.string	"%i%i%i"
.LC1:
	.string	"NEGATIVE CYCLE"
.LC2:
	.string	"INF"
.LC3:
	.string	"%i\n"
	.text
	.globl	run
	.type	run, @function
run:
.LFB11:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	subq	$64, %rsp
	movq	%fs:40, %rax
	movq	%rax, -8(%rbp)
	xorl	%eax, %eax
	leaq	-56(%rbp), %rcx
	leaq	-60(%rbp), %rdx
	leaq	-64(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-64(%rbp), %eax
	movl	%eax, %edi
	call	new_graph
	movq	%rax, -24(%rbp)
	jmp	.L25
.L26:
	leaq	-44(%rbp), %rcx
	leaq	-48(%rbp), %rdx
	leaq	-52(%rbp), %rax
	movq	%rax, %rsi
	leaq	.LC0(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	__isoc99_scanf@PLT
	movl	-44(%rbp), %ecx
	movl	-48(%rbp), %edx
	movl	-52(%rbp), %esi
	movq	-24(%rbp), %rax
	movq	%rax, %rdi
	call	add_edge
.L25:
	movl	-60(%rbp), %eax
	leal	-1(%rax), %edx
	movl	%edx, -60(%rbp)
	testl	%eax, %eax
	jne	.L26
	movl	-64(%rbp), %eax
	cltq
	movl	$4, %esi
	movq	%rax, %rdi
	call	calloc@PLT
	movq	%rax, -16(%rbp)
	movl	-64(%rbp), %eax
	imull	$10000, %eax, %eax
	addl	$1, %eax
	movl	%eax, -28(%rbp)
	movl	$0, -40(%rbp)
	jmp	.L27
.L28:
	movl	-40(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rax, %rdx
	movl	-28(%rbp), %eax
	movl	%eax, (%rdx)
	addl	$1, -40(%rbp)
.L27:
	movl	-64(%rbp), %eax
	cmpl	%eax, -40(%rbp)
	jl	.L28
	movl	-56(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	$0, (%rax)
	movl	$0, -36(%rbp)
	jmp	.L29
.L30:
	movl	-28(%rbp), %edx
	movq	-16(%rbp), %rcx
	movq	-24(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	bellman_ford
	addl	$1, -36(%rbp)
.L29:
	movl	-64(%rbp), %eax
	subl	$1, %eax
	cmpl	%eax, -36(%rbp)
	jl	.L30
	movl	-28(%rbp), %edx
	movq	-16(%rbp), %rcx
	movq	-24(%rbp), %rax
	movq	%rcx, %rsi
	movq	%rax, %rdi
	call	bellman_ford
	testl	%eax, %eax
	je	.L31
	leaq	.LC1(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L24
.L31:
	movl	$0, -32(%rbp)
	jmp	.L33
.L36:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	cmpl	%eax, -28(%rbp)
	jne	.L34
	leaq	.LC2(%rip), %rax
	movq	%rax, %rdi
	call	puts@PLT
	jmp	.L35
.L34:
	movl	-32(%rbp), %eax
	cltq
	leaq	0(,%rax,4), %rdx
	movq	-16(%rbp), %rax
	addq	%rdx, %rax
	movl	(%rax), %eax
	movl	%eax, %esi
	leaq	.LC3(%rip), %rax
	movq	%rax, %rdi
	movl	$0, %eax
	call	printf@PLT
.L35:
	addl	$1, -32(%rbp)
.L33:
	movl	-64(%rbp), %eax
	cmpl	%eax, -32(%rbp)
	jl	.L36
.L24:
	movq	-8(%rbp), %rax
	subq	%fs:40, %rax
	je	.L37
	call	__stack_chk_fail@PLT
.L37:
	leave
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE11:
	.size	run, .-run
	.globl	main
	.type	main, @function
main:
.LFB12:
	.cfi_startproc
	endbr64
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset 6, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register 6
	call	run
	movl	$0, %eax
	popq	%rbp
	.cfi_def_cfa 7, 8
	ret
	.cfi_endproc
.LFE12:
	.size	main, .-main
	.ident	"GCC: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	1f - 0f
	.long	4f - 1f
	.long	5
0:
	.string	"GNU"
1:
	.align 8
	.long	0xc0000002
	.long	3f - 2f
2:
	.long	0x3
3:
	.align 8
4:
