#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*/ abort();
int abs(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ maze_cell_exists(struct maze *, int, int);
int maze_find_wallbit(int, int, int, int);
int maze_get_cell(struct maze *, int, int);
int /*<<< orphan*/ stderr;
int maze_cells_connected(struct maze *mp, int row1, int col1, int row2,
                         int col2) {
  if (abs(row1 - row2) + abs(col1 - col2) != 1)
    do {
      fprintf(stderr, "Aborted at %s:%d\n",
              "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/brendanlong/perfbook/refs/heads/"
              "epub-output/CodeSamples/SMPdesign/maze/maze.h",
              140);
      abort();
    } while (0);
  if (!maze_cell_exists(mp, row1, col1) || !maze_cell_exists(mp, row2, col2))
    return 0;
  return (maze_find_wallbit(row1, col1, row2, col2) &
          maze_get_cell(mp, row1, col1)) == 0;
}


x86 assembly (clang, -O0):
<maze_cells_connected>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x14(%rbp),%edi
sub    -0x1c(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
sub    -0x20(%rbp),%edi
call   1040 <abs@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
cmp    $0x1,%eax
je     11cf <maze_cells_connected+0x6f>
jmp    11a7 <maze_cells_connected+0x47>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
lea    0xe54(%rip),%rdx
mov    $0x8c,%ecx
call   1070 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1060 <maze_cell_exists@plt>
cmp    $0x0,%eax
je     11ff <maze_cells_connected+0x9f>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1060 <maze_cell_exists@plt>
cmp    $0x0,%eax
jne    120b <maze_cells_connected+0xab>
movl   $0x0,-0x4(%rbp)
jmp    1243 <maze_cells_connected+0xe3>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
call   1050 <maze_find_wallbit@plt>
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1080 <maze_get_cell@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
and    %ecx,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<maze_cells_connected>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%eax
sub    %ecx,%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
mov    %edx,%eax
sub    %r8d,%eax
mov    %eax,%edx
neg    %edx
cmovs  %eax,%edx
add    %ecx,%edx
cmp    $0x1,%edx
jne    11e0 <maze_cells_connected+0x90>
mov    %r8d,%r15d
mov    %esi,%ebp
mov    %rdi,%r14
mov    %r13d,%edx
call   1050 <maze_cell_exists@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     11cf <maze_cells_connected+0x7f>
mov    %r14,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
call   1050 <maze_cell_exists@plt>
test   %eax,%eax
je     11cf <maze_cells_connected+0x7f>
mov    %ebp,%edi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15d,%ecx
call   1040 <maze_find_wallbit@plt>
mov    %eax,%r15d
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r13d,%edx
call   1070 <maze_get_cell@plt>
xor    %ebx,%ebx
test   %r15d,%eax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
lea    0xe10(%rip),%rsi
lea    0xe1b(%rip),%rdx
mov    $0x8c,%ecx
call   1060 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.maze = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"Aborted at %s:%d\0A\00"
@.str.1 = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/brendanlong/perfbook/refs/heads/epub-output/CodeSamples/SMPdesign/maze/maze.h\00"
define i32 @maze_cells_connected(%struct.maze* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca %struct.maze*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store %struct.maze* %0, %struct.maze** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%12 = load i32, i32* %8
%13 = load i32, i32* %10
%14 = sub nsw i32 %12, %13
%15 = call i32 @abs(i32 %14)
%16 = load i32, i32* %9
%17 = load i32, i32* %11
%18 = sub nsw i32 %16, %17
%19 = call i32 @abs(i32 %18)
%20 = add nsw i32 %15, %19
%21 = icmp ne i32 %20, 1
br i1 %21, label %22, label %28
22: ; preds = %5
br label %23
23: ; preds = %22
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.1, i64 0, i64 0), i32 140)
%26 = call i32 (...) @abort()
unreachable
27: ; No predecessors!
br label %28
28: ; preds = %27, %5
%29 = load %struct.maze*, %struct.maze** %7
%30 = load i32, i32* %8
%31 = load i32, i32* %9
%32 = call i32 @maze_cell_exists(%struct.maze* %29, i32 %30, i32 %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %28
%35 = load %struct.maze*, %struct.maze** %7
%36 = load i32, i32* %10
%37 = load i32, i32* %11
%38 = call i32 @maze_cell_exists(%struct.maze* %35, i32 %36, i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %41, label %40
40: ; preds = %34, %28
store i32 0, i32* %6
br label %54
41: ; preds = %34
%42 = load i32, i32* %8
%43 = load i32, i32* %9
%44 = load i32, i32* %10
%45 = load i32, i32* %11
%46 = call i32 @maze_find_wallbit(i32 %42, i32 %43, i32 %44, i32 %45)
%47 = load %struct.maze*, %struct.maze** %7
%48 = load i32, i32* %8
%49 = load i32, i32* %9
%50 = call i32 @maze_get_cell(%struct.maze* %47, i32 %48, i32 %49)
%51 = and i32 %46, %50
%52 = icmp eq i32 %51, 0
%53 = zext i1 %52 to i32
store i32 %53, i32* %6
br label %54
54: ; preds = %41, %40
%55 = load i32, i32* %6
ret i32 %55
}

LLVM IR (-O2):
%struct.maze = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"Aborted at %s:%d\0A\00"
@.str.1 = [168 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/brendanlong/perfbook/refs/heads/epub-output/CodeSamples/SMPdesign/maze/maze.h\00"
define i32 @maze_cells_connected(%struct.maze* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = sub nsw i32 %1, %3
%7 = tail call i32 @llvm.abs.i32(i32 %6, i1 true)
%8 = sub nsw i32 %2, %4
%9 = tail call i32 @llvm.abs.i32(i32 %8, i1 true)
%10 = add nuw nsw i32 %9, %7
%11 = icmp eq i32 %10, 1
br i1 %11, label %16, label %12
12: ; preds = %5
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([168 x i8], [168 x i8]* @.str.1, i64 0, i64 0), i32 140)
%15 = tail call i32 (...) @abort()
unreachable
16: ; preds = %5
%17 = tail call i32 @maze_cell_exists(%struct.maze* %0, i32 %1, i32 %2)
%18 = icmp eq i32 %17, 0
br i1 %18, label %28, label %19
19: ; preds = %16
%20 = tail call i32 @maze_cell_exists(%struct.maze* %0, i32 %3, i32 %4)
%21 = icmp eq i32 %20, 0
br i1 %21, label %28, label %22
22: ; preds = %19
%23 = tail call i32 @maze_find_wallbit(i32 %1, i32 %2, i32 %3, i32 %4)
%24 = tail call i32 @maze_get_cell(%struct.maze* %0, i32 %1, i32 %2)
%25 = and i32 %24, %23
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %16, %19, %22
%29 = phi i32 [ %27, %22 ], [ 0, %19 ], [ 0, %16 ]
ret i32 %29
}