#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 maze {
  int dummy;
};

/* Variables and functions */
scalar_t__ maze_cell_visited(struct maze *, int, int);
int /*<<< orphan*/ maze_cells_connected(struct maze *, int, int, int, int);
int /*<<< orphan*/ maze_visit_cell(struct maze *, int, int, int);
int maze_try_visit_cell(struct maze *mp, int cr, int cc, int tr, int tc,
                        int *nextrow, int *nextcol, int distance) {
  if (!maze_cells_connected(mp, cr, cc, tr, tc) ||
      maze_cell_visited(mp, tr, tc))
    return 1;
  *nextrow = tr;
  *nextcol = tc;
  maze_visit_cell(mp, tr, tc, distance);
  return 0;
}


x86 assembly (clang, -O0):
<maze_try_visit_cell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1050 <maze_cells_connected@plt>
cmp    $0x0,%eax
je     118c <maze_try_visit_cell+0x5c>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <maze_cell_visited@plt>
cmp    $0x0,%rax
je     1198 <maze_try_visit_cell+0x68>
movl   $0x1,-0x4(%rbp)
jmp    11c3 <maze_try_visit_cell+0x93>
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    0x18(%rbp),%ecx
call   1030 <maze_visit_cell@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maze_try_visit_cell>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r9,%r14
mov    %r8d,%r15d
mov    %ecx,%ebp
mov    %rdi,%rbx
call   1050 <maze_cells_connected@plt>
mov    $0x1,%r12d
test   %eax,%eax
je     1183 <maze_try_visit_cell+0x53>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1040 <maze_cell_visited@plt>
test   %rax,%rax
jne    1183 <maze_try_visit_cell+0x53>
mov    0x38(%rsp),%ecx
mov    0x30(%rsp),%rax
mov    %ebp,(%r14)
mov    %r15d,(%rax)
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1030 <maze_visit_cell@plt>
xor    %r12d,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.maze = type { i32 }
define i32 @maze_try_visit_cell(%struct.maze* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* %5, i32* %6, i32 %7) {
%9 = alloca i32
%10 = alloca %struct.maze*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32
store %struct.maze* %0, %struct.maze** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store i32 %3, i32* %13
store i32 %4, i32* %14
store i32* %5, i32** %15
store i32* %6, i32** %16
store i32 %7, i32* %17
%18 = load %struct.maze*, %struct.maze** %10
%19 = load i32, i32* %11
%20 = load i32, i32* %12
%21 = load i32, i32* %13
%22 = load i32, i32* %14
%23 = call i32 @maze_cells_connected(%struct.maze* %18, i32 %19, i32 %20, i32 %21, i32 %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %8
%26 = load %struct.maze*, %struct.maze** %10
%27 = load i32, i32* %13
%28 = load i32, i32* %14
%29 = call i64 @maze_cell_visited(%struct.maze* %26, i32 %27, i32 %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25, %8
store i32 1, i32* %9
br label %42
32: ; preds = %25
%33 = load i32, i32* %13
%34 = load i32*, i32** %15
store i32 %33, i32* %34
%35 = load i32, i32* %14
%36 = load i32*, i32** %16
store i32 %35, i32* %36
%37 = load %struct.maze*, %struct.maze** %10
%38 = load i32, i32* %13
%39 = load i32, i32* %14
%40 = load i32, i32* %17
%41 = call i32 @maze_visit_cell(%struct.maze* %37, i32 %38, i32 %39, i32 %40)
store i32 0, i32* %9
br label %42
42: ; preds = %32, %31
%43 = load i32, i32* %9
ret i32 %43
}

LLVM IR (-O2):
%struct.maze = type { i32 }
define i32 @maze_try_visit_cell(%struct.maze* %0, i32 %1, i32 %2, i32 %3, i32 %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6, i32 %7) {
%9 = tail call i32 @maze_cells_connected(%struct.maze* %0, i32 %1, i32 %2, i32 %3, i32 %4)
%10 = icmp eq i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = tail call i64 @maze_cell_visited(%struct.maze* %0, i32 %3, i32 %4)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
store i32 %3, i32* %5
store i32 %4, i32* %6
%15 = tail call i32 @maze_visit_cell(%struct.maze* %0, i32 %3, i32 %4, i32 %7)
br label %16
16: ; preds = %8, %11, %14
%17 = phi i32 [ 0, %14 ], [ 1, %11 ], [ 1, %8 ]
ret i32 %17
}