#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*/ printf(char *, ...);
void PrintPaths(short int paths[20000][10000]) {
  int i, j;
  int step;
  printf("Paths: \n");
  for (i = 0; i < 20000; i++) {
    step = 0;
    printf("%d -- ", i);
    for (j = 0; j < 10000; j++) {
      printf("%d ", paths[i][j]);
      if (paths[i][j] != -1)
        step++;
    }
    printf(" -- %d steps \n", step == 0 ? step : step - 1);
  }
}


x86 assembly (clang, -O0):
<PrintPaths>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xedd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x4e20,-0xc(%rbp)
jge    120e <PrintPaths+0xfe>
movl   $0x0,-0x14(%rbp)
mov    -0xc(%rbp),%esi
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x2710,-0x10(%rbp)
jge    11d1 <PrintPaths+0xc1>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x4e20,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movswl (%rax,%rcx,2),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
imul   $0x4e20,%rcx,%rcx
add    %rcx,%rax
movslq -0x10(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
cmp    $0xffffffff,%eax
je     11be <PrintPaths+0xae>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c3 <PrintPaths+0xb3>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115d <PrintPaths+0x4d>
cmpl   $0x0,-0x14(%rbp)
jne    11e6 <PrintPaths+0xd6>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    11ef <PrintPaths+0xdf>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1131 <PrintPaths+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintPaths>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0xec6(%rip),%r15
lea    0xec3(%rip),%r12
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
lea    0xea9(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %r14d,%r14d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movswl (%rbx,%r14,2),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
cmpw   $0xffff,(%rbx,%r14,2)
setne  %al
add    %eax,%ebp
add    $0x1,%r14
cmp    $0x2710,%r14
jne    1170 <PrintPaths+0x50>
sub    $0x1,%ebp
mov    $0x0,%eax
cmovb  %eax,%ebp
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13
add    $0x4e20,%rbx
cmp    $0x4e20,%r13
jne    1150 <PrintPaths+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Paths: \0A\00"
@.str.1 = [7 x i8] c"%d -- \00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [15 x i8] c" -- %d steps \0A\00"
define void @PrintPaths([10000 x i16]* %0) {
%2 = alloca [10000 x i16]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store [10000 x i16]* %0, [10000 x i16]** %2
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %7
7: ; preds = %55, %1
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 20000
br i1 %9, label %10, label %58
10: ; preds = %7
store i32 0, i32* %5
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %11)
store i32 0, i32* %4
br label %13
13: ; preds = %41, %10
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 10000
br i1 %15, label %16, label %44
16: ; preds = %13
%17 = load [10000 x i16]*, [10000 x i16]** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [10000 x i16], [10000 x i16]* %17, i64 %19
%21 = load i32, i32* %4
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10000 x i16], [10000 x i16]* %20, i64 0, i64 %22
%24 = load i16, i16* %23
%25 = sext i16 %24 to i32
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = load [10000 x i16]*, [10000 x i16]** %2
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [10000 x i16], [10000 x i16]* %27, i64 %29
%31 = load i32, i32* %4
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [10000 x i16], [10000 x i16]* %30, i64 0, i64 %32
%34 = load i16, i16* %33
%35 = sext i16 %34 to i32
%36 = icmp ne i32 %35, -1
br i1 %36, label %37, label %40
37: ; preds = %16
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
br label %40
40: ; preds = %37, %16
br label %41
41: ; preds = %40
%42 = load i32, i32* %4
%43 = add nsw i32 %42, 1
store i32 %43, i32* %4
br label %13
44: ; preds = %13
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = load i32, i32* %5
br label %52
49: ; preds = %44
%50 = load i32, i32* %5
%51 = sub nsw i32 %50, 1
br label %52
52: ; preds = %49, %47
%53 = phi i32 [ %48, %47 ], [ %51, %49 ]
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %53)
br label %55
55: ; preds = %52
%56 = load i32, i32* %3
%57 = add nsw i32 %56, 1
store i32 %57, i32* %3
br label %7
58: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"%d -- \00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [15 x i8] c" -- %d steps \0A\00"
@str = [8 x i8] c"Paths: \00"
define void @PrintPaths([10000 x i16]* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %3
3: ; preds = %1, %20
%4 = phi i64 [ 0, %1 ], [ %25, %20 ]
%5 = trunc i64 %4 to i32
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %3, %7
%8 = phi i64 [ 0, %3 ], [ %18, %7 ]
%9 = phi i32 [ 0, %3 ], [ %17, %7 ]
%10 = getelementptr inbounds [10000 x i16], [10000 x i16]* %0, i64 %4, i64 %8
%11 = load i16, i16* %10
%12 = sext i16 %11 to i32
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i16, i16* %10
%15 = icmp ne i16 %14, -1
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %9, %16
%18 = add nuw nsw i64 %8, 1
%19 = icmp eq i64 %18, 10000
br i1 %19, label %20, label %7
20: ; preds = %7
%21 = icmp eq i32 %17, 0
%22 = add nsw i32 %17, -1
%23 = select i1 %21, i32 0, i32 %22
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = add nuw nsw i64 %4, 1
%26 = icmp eq i64 %25, 20000
br i1 %26, label %27, label %3
27: ; preds = %20
ret void
}