#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*/ border_e_horizontal_water(unsigned char *, unsigned char *);
int /*<<< orphan*/ border_n_vertical_water(unsigned char *, unsigned char *);
int /*<<< orphan*/ border_ne_ext_corner_water(unsigned char *, unsigned char *);
int /*<<< orphan*/ border_ne_ext_diagonal_water(unsigned char *,
                                                unsigned char *);
int /*<<< orphan*/ border_ne_int_diagonal_water(unsigned char *,
                                                unsigned char *);
int /*<<< orphan*/ border_nw_ext_corner_water(unsigned char *, unsigned char *);
int /*<<< orphan*/ border_nw_ext_diagonal_water(unsigned char *,
                                                unsigned char *);
int /*<<< orphan*/ border_nw_int_diagonal_water(unsigned char *,
                                                unsigned char *);
int /*<<< orphan*/ border_s_vertical_water(unsigned char *, unsigned char *);
int /*<<< orphan*/ border_se_ext_corner_water(unsigned char *, unsigned char *);
int /*<<< orphan*/ border_se_ext_diagonal_water(unsigned char *,
                                                unsigned char *);
int /*<<< orphan*/ border_se_int_diagonal_water(unsigned char *,
                                                unsigned char *);
int /*<<< orphan*/ border_sw_ext_corner_water(unsigned char *, unsigned char *);
int /*<<< orphan*/ border_sw_ext_diagonal_water(unsigned char *,
                                                unsigned char *);
int /*<<< orphan*/ border_sw_int_diagonal_water(unsigned char *,
                                                unsigned char *);
int /*<<< orphan*/ border_w_horizontal_water(unsigned char *, unsigned char *);
int /*<<< orphan*/ borderless_water(unsigned char *);
int dispatch_terrain_water(unsigned char adjacent_same, unsigned char *pic,
                           unsigned char *mirr) {
  switch (adjacent_same) {
  case 0xD6:
  case 0xD7:
  case 0xF6:
  case 0xF7:
    border_w_horizontal_water(pic, mirr);
    break;
  case 0x6B:
  case 0x6F:
  case 0xEB:
  case 0xEF:
    border_e_horizontal_water(pic, mirr);
    break;
  case 0xF8:
  case 0xF9:
  case 0xFC:
  case 0xFD:
    border_n_vertical_water(pic, mirr);
    break;
  case 0x1F:
  case 0x3F:
  case 0x9F:
  case 0xBF:
    border_s_vertical_water(pic, mirr);
    break;
  case 0xD4:
  case 0xF0:
  case 0xF4:
    border_nw_ext_diagonal_water(pic, mirr);
    break;
  case 0xE8:
  case 0xE9:
  case 0x69:
    border_ne_ext_diagonal_water(pic, mirr);
    break;
  case 0x96:
  case 0x97:
  case 0x17:
    border_sw_ext_diagonal_water(pic, mirr);
    break;
  case 0x2B:
  case 0x2F:
  case 0x0F:
    border_se_ext_diagonal_water(pic, mirr);
    break;
  case 0xFE:
    border_nw_int_diagonal_water(pic, mirr);
    break;
  case 0xFB:
    border_ne_int_diagonal_water(pic, mirr);
    break;
  case 0xDF:
    border_sw_int_diagonal_water(pic, mirr);
    break;
  case 0x7F:
    border_se_int_diagonal_water(pic, mirr);
    break;
  case 0xD0:
    border_nw_ext_corner_water(pic, mirr);
    break;
  case 0x68:
    border_ne_ext_corner_water(pic, mirr);
    break;
  case 0x16:
    border_sw_ext_corner_water(pic, mirr);
    break;
  case 0x0B:
    border_se_ext_corner_water(pic, mirr);
    break;
  case 0xFF:
    borderless_water(pic);
    break;
  default:
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<dispatch_terrain_water>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x5(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movzbl -0x5(%rbp),%eax
add    $0xfffffff5,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0xf4,%eax
ja     1380 <dispatch_terrain_water+0x170>
mov    -0x20(%rbp),%rax
lea    0xdb7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10b0 <border_w_horizontal_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10e0 <border_e_horizontal_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <border_n_vertical_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <border_s_vertical_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10c0 <border_nw_ext_diagonal_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <border_ne_ext_diagonal_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1090 <border_sw_ext_diagonal_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10a0 <border_se_ext_diagonal_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <border_nw_int_diagonal_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <border_ne_int_diagonal_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1120 <border_sw_int_diagonal_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1080 <border_se_int_diagonal_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1100 <border_nw_ext_corner_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   10d0 <border_ne_ext_corner_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1130 <border_sw_ext_corner_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <border_se_ext_corner_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
mov    -0x10(%rbp),%rdi
call   10f0 <borderless_water@plt>
jmp    138c <dispatch_terrain_water+0x17c>
movl   $0x1,-0x4(%rbp)
jmp    1393 <dispatch_terrain_water+0x183>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dispatch_terrain_water>:
push   %rax
mov    $0x1,%eax
add    $0x6a,%dil
cmp    $0xe9,%dil
ja     1324 <dispatch_terrain_water+0x114>
movzbl %dil,%ecx
lea    0xdd1(%rip),%rdi
movslq (%rdi,%rcx,4),%rcx
add    %rdi,%rcx
jmp    *%rcx
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1040 <border_s_vertical_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   10b0 <border_w_horizontal_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   10e0 <border_e_horizontal_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1030 <border_n_vertical_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1090 <border_sw_ext_diagonal_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   10c0 <border_nw_ext_diagonal_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1110 <border_ne_ext_diagonal_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   10a0 <border_se_ext_diagonal_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1100 <border_nw_ext_corner_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1120 <border_sw_int_diagonal_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1060 <border_ne_int_diagonal_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1050 <border_nw_int_diagonal_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
call   10f0 <borderless_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1070 <border_se_ext_corner_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1130 <border_sw_ext_corner_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   10d0 <border_ne_ext_corner_water@plt>
jmp    1322 <dispatch_terrain_water+0x112>
mov    %rsi,%rdi
mov    %rdx,%rsi
call   1080 <border_se_int_diagonal_water@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @dispatch_terrain_water(i8 zeroext %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8*
store i8 %0, i8* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i8, i8* %5
%9 = zext i8 %8 to i32
switch i32 %9, label %77 [
i32 214, label %10
i32 215, label %10
i32 246, label %10
i32 247, label %10
i32 107, label %14
i32 111, label %14
i32 235, label %14
i32 239, label %14
i32 248, label %18
i32 249, label %18
i32 252, label %18
i32 253, label %18
i32 31, label %22
i32 63, label %22
i32 159, label %22
i32 191, label %22
i32 212, label %26
i32 240, label %26
i32 244, label %26
i32 232, label %30
i32 233, label %30
i32 105, label %30
i32 150, label %34
i32 151, label %34
i32 23, label %34
i32 43, label %38
i32 47, label %38
i32 15, label %38
i32 254, label %42
i32 251, label %46
i32 223, label %50
i32 127, label %54
i32 208, label %58
i32 104, label %62
i32 22, label %66
i32 11, label %70
i32 255, label %74
]
10: ; preds = %3, %3, %3, %3
%11 = load i8*, i8** %6
%12 = load i8*, i8** %7
%13 = call i32 @border_w_horizontal_water(i8* %11, i8* %12)
br label %78
14: ; preds = %3, %3, %3, %3
%15 = load i8*, i8** %6
%16 = load i8*, i8** %7
%17 = call i32 @border_e_horizontal_water(i8* %15, i8* %16)
br label %78
18: ; preds = %3, %3, %3, %3
%19 = load i8*, i8** %6
%20 = load i8*, i8** %7
%21 = call i32 @border_n_vertical_water(i8* %19, i8* %20)
br label %78
22: ; preds = %3, %3, %3, %3
%23 = load i8*, i8** %6
%24 = load i8*, i8** %7
%25 = call i32 @border_s_vertical_water(i8* %23, i8* %24)
br label %78
26: ; preds = %3, %3, %3
%27 = load i8*, i8** %6
%28 = load i8*, i8** %7
%29 = call i32 @border_nw_ext_diagonal_water(i8* %27, i8* %28)
br label %78
30: ; preds = %3, %3, %3
%31 = load i8*, i8** %6
%32 = load i8*, i8** %7
%33 = call i32 @border_ne_ext_diagonal_water(i8* %31, i8* %32)
br label %78
34: ; preds = %3, %3, %3
%35 = load i8*, i8** %6
%36 = load i8*, i8** %7
%37 = call i32 @border_sw_ext_diagonal_water(i8* %35, i8* %36)
br label %78
38: ; preds = %3, %3, %3
%39 = load i8*, i8** %6
%40 = load i8*, i8** %7
%41 = call i32 @border_se_ext_diagonal_water(i8* %39, i8* %40)
br label %78
42: ; preds = %3
%43 = load i8*, i8** %6
%44 = load i8*, i8** %7
%45 = call i32 @border_nw_int_diagonal_water(i8* %43, i8* %44)
br label %78
46: ; preds = %3
%47 = load i8*, i8** %6
%48 = load i8*, i8** %7
%49 = call i32 @border_ne_int_diagonal_water(i8* %47, i8* %48)
br label %78
50: ; preds = %3
%51 = load i8*, i8** %6
%52 = load i8*, i8** %7
%53 = call i32 @border_sw_int_diagonal_water(i8* %51, i8* %52)
br label %78
54: ; preds = %3
%55 = load i8*, i8** %6
%56 = load i8*, i8** %7
%57 = call i32 @border_se_int_diagonal_water(i8* %55, i8* %56)
br label %78
58: ; preds = %3
%59 = load i8*, i8** %6
%60 = load i8*, i8** %7
%61 = call i32 @border_nw_ext_corner_water(i8* %59, i8* %60)
br label %78
62: ; preds = %3
%63 = load i8*, i8** %6
%64 = load i8*, i8** %7
%65 = call i32 @border_ne_ext_corner_water(i8* %63, i8* %64)
br label %78
66: ; preds = %3
%67 = load i8*, i8** %6
%68 = load i8*, i8** %7
%69 = call i32 @border_sw_ext_corner_water(i8* %67, i8* %68)
br label %78
70: ; preds = %3
%71 = load i8*, i8** %6
%72 = load i8*, i8** %7
%73 = call i32 @border_se_ext_corner_water(i8* %71, i8* %72)
br label %78
74: ; preds = %3
%75 = load i8*, i8** %6
%76 = call i32 @borderless_water(i8* %75)
br label %78
77: ; preds = %3
store i32 1, i32* %4
br label %79
78: ; preds = %74, %70, %66, %62, %58, %54, %50, %46, %42, %38, %34, %30, %26, %22, %18, %14, %10
store i32 0, i32* %4
br label %79
79: ; preds = %78, %77
%80 = load i32, i32* %4
ret i32 %80
}

LLVM IR (-O2):
define i32 @dispatch_terrain_water(i8 zeroext %0, i8* %1, i8* %2) {
switch i8 %0, label %38 [
i8 -42, label %4
i8 -41, label %4
i8 -10, label %4
i8 -9, label %4
i8 107, label %6
i8 111, label %6
i8 -21, label %6
i8 -17, label %6
i8 -8, label %8
i8 -7, label %8
i8 -4, label %8
i8 -3, label %8
i8 31, label %10
i8 63, label %10
i8 -97, label %10
i8 -65, label %10
i8 -44, label %12
i8 -16, label %12
i8 -12, label %12
i8 -24, label %14
i8 -23, label %14
i8 105, label %14
i8 -106, label %16
i8 -105, label %16
i8 23, label %16
i8 43, label %18
i8 47, label %18
i8 15, label %18
i8 -2, label %20
i8 -5, label %22
i8 -33, label %24
i8 127, label %26
i8 -48, label %28
i8 104, label %30
i8 22, label %32
i8 11, label %34
i8 -1, label %36
]
4: ; preds = %3, %3, %3, %3
%5 = tail call i32 @border_w_horizontal_water(i8* %1, i8* %2)
br label %38
6: ; preds = %3, %3, %3, %3
%7 = tail call i32 @border_e_horizontal_water(i8* %1, i8* %2)
br label %38
8: ; preds = %3, %3, %3, %3
%9 = tail call i32 @border_n_vertical_water(i8* %1, i8* %2)
br label %38
10: ; preds = %3, %3, %3, %3
%11 = tail call i32 @border_s_vertical_water(i8* %1, i8* %2)
br label %38
12: ; preds = %3, %3, %3
%13 = tail call i32 @border_nw_ext_diagonal_water(i8* %1, i8* %2)
br label %38
14: ; preds = %3, %3, %3
%15 = tail call i32 @border_ne_ext_diagonal_water(i8* %1, i8* %2)
br label %38
16: ; preds = %3, %3, %3
%17 = tail call i32 @border_sw_ext_diagonal_water(i8* %1, i8* %2)
br label %38
18: ; preds = %3, %3, %3
%19 = tail call i32 @border_se_ext_diagonal_water(i8* %1, i8* %2)
br label %38
20: ; preds = %3
%21 = tail call i32 @border_nw_int_diagonal_water(i8* %1, i8* %2)
br label %38
22: ; preds = %3
%23 = tail call i32 @border_ne_int_diagonal_water(i8* %1, i8* %2)
br label %38
24: ; preds = %3
%25 = tail call i32 @border_sw_int_diagonal_water(i8* %1, i8* %2)
br label %38
26: ; preds = %3
%27 = tail call i32 @border_se_int_diagonal_water(i8* %1, i8* %2)
br label %38
28: ; preds = %3
%29 = tail call i32 @border_nw_ext_corner_water(i8* %1, i8* %2)
br label %38
30: ; preds = %3
%31 = tail call i32 @border_ne_ext_corner_water(i8* %1, i8* %2)
br label %38
32: ; preds = %3
%33 = tail call i32 @border_sw_ext_corner_water(i8* %1, i8* %2)
br label %38
34: ; preds = %3
%35 = tail call i32 @border_se_ext_corner_water(i8* %1, i8* %2)
br label %38
36: ; preds = %3
%37 = tail call i32 @borderless_water(i8* %1)
br label %38
38: ; preds = %4, %6, %8, %10, %12, %14, %16, %18, %20, %22, %24, %26, %28, %30, %32, %34, %36, %3
%39 = phi i32 [ 1, %3 ], [ 0, %36 ], [ 0, %34 ], [ 0, %32 ], [ 0, %30 ], [ 0, %28 ], [ 0, %26 ], [ 0, %24 ], [ 0, %22 ], [ 0, %20 ], [ 0, %18 ], [ 0, %16 ], [ 0, %14 ], [ 0, %12 ], [ 0, %10 ], [ 0, %8 ], [ 0, %6 ], [ 0, %4 ]
ret i32 %39
}