#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 */
int /*<<< orphan*/ maze_cells_connected(struct maze *, int, int, int, int);
int maze_get_cell_distance(struct maze *, int, int);
int /*<<< orphan*/ maze_same_tids(struct maze *, int, int, int, int);
int maze_is_prev_cell(struct maze *mp, int row1, int col1, int row2, int col2,
                      int *nextrow, int *nextcol) {
  if (!maze_cells_connected(mp, row1, col1, row2, col2) ||
      !maze_same_tids(mp, row1, col1, row2, col2) ||
      maze_get_cell_distance(mp, row1, col1) -
              maze_get_cell_distance(mp, row2, col2) !=
          1)
    return 0;
  *nextrow = row2;
  *nextcol = col2;
  return 1;
}


x86 assembly (clang, -O0):
<maze_is_prev_cell>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
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     11c0 <maze_is_prev_cell+0x90>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x20(%rbp),%r8d
call   1030 <maze_same_tids@plt>
cmp    $0x0,%eax
je     11c0 <maze_is_prev_cell+0x90>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <maze_get_cell_distance@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1040 <maze_get_cell_distance@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
sub    %ecx,%eax
cmp    $0x1,%eax
je     11cc <maze_is_prev_cell+0x9c>
movl   $0x0,-0x4(%rbp)
jmp    11e5 <maze_is_prev_cell+0xb5>
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maze_is_prev_cell>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9,(%rsp)
mov    %r8d,%r12d
mov    %ecx,%r13d
mov    %edx,%ebp
mov    %esi,%r14d
mov    %rdi,%rbx
call   1050 <maze_cells_connected@plt>
xor    %r15d,%r15d
test   %eax,%eax
je     11a9 <maze_is_prev_cell+0x79>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %r13d,%ecx
mov    %r12d,%r8d
call   1030 <maze_same_tids@plt>
test   %eax,%eax
je     11a9 <maze_is_prev_cell+0x79>
mov    %rbx,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1040 <maze_get_cell_distance@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
call   1040 <maze_get_cell_distance@plt>
sub    %eax,%ebp
cmp    $0x1,%ebp
jne    11a9 <maze_is_prev_cell+0x79>
mov    0x40(%rsp),%rax
mov    (%rsp),%rcx
mov    %r13d,(%rcx)
mov    %r12d,(%rax)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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