#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 *, int);
void way(int **p, int i, int j) {
  int k;
  k = p[i][j];
  if (k != 0) {
    way(p, i, k);
    printf("%d ", k);
    way(p, k, j);
  }
}


x86 assembly (clang, -O0):
<way>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     117f <way+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
call   1030 <way@plt>
mov    -0x14(%rbp),%esi
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1030 <way@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<way>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movslq %edx,%r15
movslq %esi,%rax
mov    (%rdi,%rax,8),%rax
mov    (%rax,%r15,4),%eax
test   %eax,%eax
je     1177 <way+0x57>
mov    %rdi,%rbx
lea    0xebd(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %eax,%edx
call   1030 <way@plt>
mov    %r14,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
movslq %ebp,%rax
mov    (%rbx,%rax,8),%rax
mov    (%rax,%r15,4),%eax
mov    %ebp,%esi
test   %eax,%eax
jne    1150 <way+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
define void @way(i32** %0, i32 %1, i32 %2) {
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32** %0, i32*** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32**, i32*** %4
%9 = load i32, i32* %5
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32*, i32** %8, i64 %10
%12 = load i32*, i32** %11
%13 = load i32, i32* %6
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %3
%20 = load i32**, i32*** %4
%21 = load i32, i32* %5
%22 = load i32, i32* %7
%23 = load i32, i32* %7
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %23)
%25 = load i32**, i32*** %4
%26 = load i32, i32* %7
%27 = load i32, i32* %6
br label %28
28: ; preds = %19, %3
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @way(i32** %0, i32 %1, i32 %2) {
%4 = sext i32 %2 to i64
%5 = sext i32 %1 to i64
%6 = getelementptr inbounds i32*, i32** %0, i64 %5
%7 = load i32*, i32** %6
%8 = getelementptr inbounds i32, i32* %7, i64 %4
%9 = load i32, i32* %8
%10 = icmp eq i32 %9, 0
br i1 %10, label %21, label %11
11: ; preds = %3, %11
%12 = phi i32 [ %19, %11 ], [ %9, %3 ]
%13 = phi i32 [ %12, %11 ], [ %1, %3 ]
tail call void @way(i32** %0, i32 %13, i32 %12)
%14 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%15 = sext i32 %12 to i64
%16 = getelementptr inbounds i32*, i32** %0, i64 %15
%17 = load i32*, i32** %16
%18 = getelementptr inbounds i32, i32* %17, i64 %4
%19 = load i32, i32* %18
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %11
21: ; preds = %11, %3
ret void
}