#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 */

/* Variables and functions */
int /*<<< orphan*/ BELLMAN_FORD(int **, int *, int /*<<< orphan*/, int, int *);
int /*<<< orphan*/ print_path(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system(char *);
int main() {
  int d[100];
  int pre[100];
  int G[][100] = {{0, -1, 3, 0, 0},
                  {0, 0, 3, 2, 2},
                  {0, 0, 0, 0, 0},
                  {0, 1, 5, 0, 0},
                  {0, 0, 0, -3, 0}};
  int n = 5;
  BELLMAN_FORD(G, d, 0, n, pre);
  for (int i = 0; i < n; i++) {
    if (i == 0)
      continue;
    print_path(pre, 0, i);
    printf("%c  total_len: %d\n", i + 65, d[i]);
  }
  printf("\n");
  system("pause");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb10,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xb00(%rbp),%rdi
lea    0xe90(%rip),%rsi
mov    $0x7d0,%edx
call   1060 <memcpy@plt>
movl   $0x5,-0xb04(%rbp)
lea    -0xb00(%rbp),%rdi
lea    -0x1a0(%rbp),%rsi
mov    -0xb04(%rbp),%ecx
lea    -0x330(%rbp),%r8
xor    %edx,%edx
call   1050 <BELLMAN_FORD@plt>
movl   $0x0,-0xb08(%rbp)
mov    -0xb08(%rbp),%eax
cmp    -0xb04(%rbp),%eax
jge    1221 <main+0xd1>
cmpl   $0x0,-0xb08(%rbp)
jne    11d4 <main+0x84>
jmp    120d <main+0xbd>
lea    -0x330(%rbp),%rdi
mov    -0xb08(%rbp),%edx
xor    %esi,%esi
call   1070 <print_path@plt>
mov    -0xb08(%rbp),%esi
add    $0x41,%esi
movslq -0xb08(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%edx
lea    0x15ca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xb08(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xb08(%rbp)
jmp    11b0 <main+0x60>
lea    0x15b9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0x15ad(%rip),%rdi
call   1030 <system@plt>
xor    %eax,%eax
add    $0xb10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0xaf0,%rsp
lea    0xe8d(%rip),%rsi
lea    0x320(%rsp),%rbx
mov    $0x7d0,%edx
mov    %rbx,%rdi
call   1070 <memcpy@plt>
mov    %rsp,%rsi
lea    0x190(%rsp),%r15
mov    %rbx,%rdi
xor    %edx,%edx
mov    $0x5,%ecx
mov    %r15,%r8
call   1060 <BELLMAN_FORD@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1080 <print_path@plt>
mov    0x4(%rsp),%edx
lea    0x1611(%rip),%r14
mov    %r14,%rdi
mov    $0x42,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1080 <print_path@plt>
mov    0x8(%rsp),%edx
mov    %r14,%rdi
mov    $0x43,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x3,%edx
call   1080 <print_path@plt>
mov    0xc(%rsp),%edx
mov    %r14,%rdi
mov    $0x44,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1080 <print_path@plt>
mov    0x10(%rsp),%edx
mov    %r14,%rdi
mov    $0x45,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x159e(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0xaf0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.G = <{ <{ i32, i32, i32, [97 x i32] }>, <{ i32, i32, i32, i32, i32, [95 x i32] }>, [100 x i32], <{ i32, i32, i32, [97 x i32] }>, <{ i32, i32, i32, i32, [96 x i32] }> }> <{ <{ i32, i32, i32, [97 x i32] }> <{ i32 0, i32 -1, i32 3, [97 x i32] zeroinitializer }>, <{ i32, i32, i32, i32, i32, [95 x i32] }> <{ i32 0, i32 0, i32 3, i32 2, i32 2, [95 x i32] zeroinitializer }>, [100 x i32] zeroinitializer, <{ i32, i32, i32, [97 x i32] }> <{ i32 0, i32 1, i32 5, [97 x i32] zeroinitializer }>, <{ i32, i32, i32, i32, [96 x i32] }> <{ i32 0, i32 0, i32 0, i32 -3, [96 x i32] zeroinitializer }> }>
@.str = [19 x i8] c"%c total_len: %d\0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca [100 x i32]
%4 = alloca [5 x [100 x i32]]
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = bitcast [5 x [100 x i32]]* %4 to i8*
store i32 5, i32* %5
%8 = getelementptr inbounds [5 x [100 x i32]], [5 x [100 x i32]]* %4, i64 0, i64 0
%9 = bitcast [100 x i32]* %8 to i32**
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%11 = load i32, i32* %5
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%13 = call i32 @BELLMAN_FORD(i32** %9, i32* %10, i32 0, i32 %11, i32* %12)
store i32 0, i32* %6
br label %14
14: ; preds = %33, %0
%15 = load i32, i32* %6
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %36
18: ; preds = %14
%19 = load i32, i32* %6
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %18
br label %33
22: ; preds = %18
%23 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%24 = load i32, i32* %6
%25 = call i32 @print_path(i32* %23, i32 0, i32 %24)
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 65
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 %27, i32 %31)
br label %33
33: ; preds = %22, %21
%34 = load i32, i32* %6
%35 = add nsw i32 %34, 1
store i32 %35, i32* %6
br label %14
36: ; preds = %14
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%38 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.G = <{ <{ i32, i32, i32, [97 x i32] }>, <{ i32, i32, i32, i32, i32, [95 x i32] }>, [100 x i32], <{ i32, i32, i32, [97 x i32] }>, <{ i32, i32, i32, i32, [96 x i32] }> }> <{ <{ i32, i32, i32, [97 x i32] }> <{ i32 0, i32 -1, i32 3, [97 x i32] zeroinitializer }>, <{ i32, i32, i32, i32, i32, [95 x i32] }> <{ i32 0, i32 0, i32 3, i32 2, i32 2, [95 x i32] zeroinitializer }>, [100 x i32] zeroinitializer, <{ i32, i32, i32, [97 x i32] }> <{ i32 0, i32 1, i32 5, [97 x i32] zeroinitializer }>, <{ i32, i32, i32, i32, [96 x i32] }> <{ i32 0, i32 0, i32 0, i32 -3, [96 x i32] zeroinitializer }> }>
@.str = [19 x i8] c"%c total_len: %d\0A\00"
@.str.2 = [6 x i8] c"pause\00"
define i32 @main() {
%1 = alloca [100 x i32]
%2 = alloca [100 x i32]
%3 = alloca [5 x [100 x i32]]
%4 = bitcast [100 x i32]* %1 to i8*
%5 = bitcast [100 x i32]* %2 to i8*
%6 = bitcast [5 x [100 x i32]]* %3 to i8*
%7 = bitcast [5 x [100 x i32]]* %3 to i32**
%8 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 0
%9 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%10 = call i32 @BELLMAN_FORD(i32** %7, i32* %8, i32 0, i32 5, i32* %9)
%11 = call i32 @print_path(i32* %9, i32 0, i32 1)
%12 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 1
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 66, i32 %13)
%15 = call i32 @print_path(i32* %9, i32 0, i32 2)
%16 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 2
%17 = load i32, i32* %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 67, i32 %17)
%19 = call i32 @print_path(i32* %9, i32 0, i32 3)
%20 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 3
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 68, i32 %21)
%23 = call i32 @print_path(i32* %9, i32 0, i32 4)
%24 = getelementptr inbounds [100 x i32], [100 x i32]* %1, i64 0, i64 4
%25 = load i32, i32* %24
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i32 69, i32 %25)
%27 = call i32 @putchar(i32 10)
%28 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}