#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*/ ai_simulation_explosion_set_unwalkable(int, int, char);
scalar_t__ gameplay_get_walkable(int, int, int);
void ai_simulation_explosion(int position_x, int position_y,
                             int explosion_radius, char simulated) {
  int x = 0;
  int y = 0;
  for (x = position_x; x < 9 && x < position_x + explosion_radius &&
                       gameplay_get_walkable(x, position_y, 1);
       x++) {
    ai_simulation_explosion_set_unwalkable(x, position_y, simulated);
  }
  for (x = position_x - 1; x > 0 && x > position_x - explosion_radius &&
                           gameplay_get_walkable(x, position_y, 1);
       x--) {
    ai_simulation_explosion_set_unwalkable(x, position_y, simulated);
  }
  for (y = position_y; y < 9 && y < position_y + explosion_radius &&
                       gameplay_get_walkable(position_x, y, 1);
       y++) {
    ai_simulation_explosion_set_unwalkable(position_x, y, simulated);
  }
  for (y = position_y - 1; y > 0 && y > position_y - explosion_radius &&
                           gameplay_get_walkable(position_x, y, 1);
       y--) {
    ai_simulation_explosion_set_unwalkable(position_x, y, simulated);
  }
}


x86 assembly (clang, -O0):
<ai_simulation_explosion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %al,-0xd(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x9,-0x14(%rbp)
mov    %al,-0x19(%rbp)
jge    1189 <ai_simulation_explosion+0x69>
mov    -0x14(%rbp),%ecx
mov    -0x4(%rbp),%edx
add    -0xc(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x19(%rbp)
jge    1189 <ai_simulation_explosion+0x69>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1040 <gameplay_get_walkable@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1199 <ai_simulation_explosion+0x79>
jmp    11b6 <ai_simulation_explosion+0x96>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
movsbl -0xd(%rbp),%edx
call   1030 <ai_simulation_explosion_set_unwalkable@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    114a <ai_simulation_explosion+0x2a>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x14(%rbp)
mov    %al,-0x1a(%rbp)
jle    11fe <ai_simulation_explosion+0xde>
mov    -0x14(%rbp),%ecx
mov    -0x4(%rbp),%edx
sub    -0xc(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x1a(%rbp)
jle    11fe <ai_simulation_explosion+0xde>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x1,%edx
call   1040 <gameplay_get_walkable@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
test   $0x1,%al
jne    120e <ai_simulation_explosion+0xee>
jmp    122b <ai_simulation_explosion+0x10b>
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%esi
movsbl -0xd(%rbp),%edx
call   1030 <ai_simulation_explosion_set_unwalkable@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11bf <ai_simulation_explosion+0x9f>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x9,-0x18(%rbp)
mov    %al,-0x1b(%rbp)
jge    1270 <ai_simulation_explosion+0x150>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%edx
add    -0xc(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x1b(%rbp)
jge    1270 <ai_simulation_explosion+0x150>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   1040 <gameplay_get_walkable@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1b(%rbp)
mov    -0x1b(%rbp),%al
test   $0x1,%al
jne    1280 <ai_simulation_explosion+0x160>
jmp    129d <ai_simulation_explosion+0x17d>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
movsbl -0xd(%rbp),%edx
call   1030 <ai_simulation_explosion_set_unwalkable@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1231 <ai_simulation_explosion+0x111>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x18(%rbp)
mov    %al,-0x1c(%rbp)
jle    12e5 <ai_simulation_explosion+0x1c5>
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%edx
sub    -0xc(%rbp),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x1c(%rbp)
jle    12e5 <ai_simulation_explosion+0x1c5>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   1040 <gameplay_get_walkable@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1c(%rbp)
mov    -0x1c(%rbp),%al
test   $0x1,%al
jne    12f5 <ai_simulation_explosion+0x1d5>
jmp    1312 <ai_simulation_explosion+0x1f2>
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%esi
movsbl -0xd(%rbp),%edx
call   1030 <ai_simulation_explosion_set_unwalkable@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    12a6 <ai_simulation_explosion+0x186>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ai_simulation_explosion>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%r14d
movsbl %cl,%r12d
cmp    $0x8,%edi
jg     117c <ai_simulation_explosion+0x5c>
test   %r15d,%r15d
jle    117c <ai_simulation_explosion+0x5c>
lea    (%r15,%r14,1),%r13d
mov    %r14d,%ebp
nopl   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
call   1040 <gameplay_get_walkable@plt>
test   %rax,%rax
je     117c <ai_simulation_explosion+0x5c>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r12d,%edx
call   1030 <ai_simulation_explosion_set_unwalkable@plt>
cmp    $0x7,%ebp
jg     117c <ai_simulation_explosion+0x5c>
add    $0x1,%ebp
cmp    %r13d,%ebp
jl     1150 <ai_simulation_explosion+0x30>
mov    %r15,(%rsp)
cmp    $0x2,%r14d
jl     11d4 <ai_simulation_explosion+0xb4>
mov    %r14d,%r13d
sub    (%rsp),%r13d
lea    -0x1(%r14),%eax
cmp    %r13d,%eax
jle    11d4 <ai_simulation_explosion+0xb4>
lea    -0x2(%r14),%r15d
nopw   0x0(%rax,%rax,1)
lea    0x1(%r15),%ebp
mov    %ebp,%edi
mov    %ebx,%esi
mov    $0x1,%edx
call   1040 <gameplay_get_walkable@plt>
test   %rax,%rax
je     11d4 <ai_simulation_explosion+0xb4>
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r12d,%edx
call   1030 <ai_simulation_explosion_set_unwalkable@plt>
cmp    $0x2,%ebp
jl     11d4 <ai_simulation_explosion+0xb4>
lea    -0x1(%r15),%eax
cmp    %r13d,%r15d
mov    %eax,%r15d
jg     11a0 <ai_simulation_explosion+0x80>
cmp    $0x8,%ebx
mov    (%rsp),%r15
jg     121e <ai_simulation_explosion+0xfe>
test   %r15d,%r15d
jle    121e <ai_simulation_explosion+0xfe>
lea    (%r15,%rbx,1),%r13d
mov    %ebx,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14d,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <gameplay_get_walkable@plt>
test   %rax,%rax
je     121e <ai_simulation_explosion+0xfe>
mov    %r14d,%edi
mov    %ebp,%esi
mov    %r12d,%edx
call   1030 <ai_simulation_explosion_set_unwalkable@plt>
cmp    $0x7,%ebp
jg     121e <ai_simulation_explosion+0xfe>
add    $0x1,%ebp
cmp    %r13d,%ebp
jl     11f0 <ai_simulation_explosion+0xd0>
cmp    $0x2,%ebx
jl     1273 <ai_simulation_explosion+0x153>
mov    %ebx,%r13d
sub    %r15d,%r13d
lea    -0x1(%rbx),%eax
cmp    %r13d,%eax
jle    1273 <ai_simulation_explosion+0x153>
add    $0xfffffffe,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%rbx),%ebp
mov    %r14d,%edi
mov    %ebp,%esi
mov    $0x1,%edx
call   1040 <gameplay_get_walkable@plt>
test   %rax,%rax
je     1273 <ai_simulation_explosion+0x153>
mov    %r14d,%edi
mov    %ebp,%esi
mov    %r12d,%edx
call   1030 <ai_simulation_explosion_set_unwalkable@plt>
cmp    $0x2,%ebp
jl     1273 <ai_simulation_explosion+0x153>
lea    -0x1(%rbx),%eax
cmp    %r13d,%ebx
mov    %eax,%ebx
jg     1240 <ai_simulation_explosion+0x120>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @ai_simulation_explosion(i32 %0, i32 %1, i32 %2, i8 signext %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8 %3, i8* %8
store i32 0, i32* %9
store i32 0, i32* %10
%11 = load i32, i32* %5
store i32 %11, i32* %9
br label %12
12: ; preds = %33, %4
%13 = load i32, i32* %9
%14 = icmp slt i32 %13, 9
br i1 %14, label %15, label %26
15: ; preds = %12
%16 = load i32, i32* %9
%17 = load i32, i32* %5
%18 = load i32, i32* %7
%19 = add nsw i32 %17, %18
%20 = icmp slt i32 %16, %19
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = load i32, i32* %9
%23 = load i32, i32* %6
%24 = call i64 @gameplay_get_walkable(i32 %22, i32 %23, i32 1)
%25 = icmp ne i64 %24, 0
br label %26
26: ; preds = %21, %15, %12
%27 = phi i1 [ false, %15 ], [ false, %12 ], [ %25, %21 ]
br i1 %27, label %28, label %36
28: ; preds = %26
%29 = load i32, i32* %9
%30 = load i32, i32* %6
%31 = load i8, i8* %8
%32 = call i32 @ai_simulation_explosion_set_unwalkable(i32 %29, i32 %30, i8 signext %31)
br label %33
33: ; preds = %28
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %12
36: ; preds = %26
%37 = load i32, i32* %5
%38 = sub nsw i32 %37, 1
store i32 %38, i32* %9
br label %39
39: ; preds = %60, %36
%40 = load i32, i32* %9
%41 = icmp sgt i32 %40, 0
br i1 %41, label %42, label %53
42: ; preds = %39
%43 = load i32, i32* %9
%44 = load i32, i32* %5
%45 = load i32, i32* %7
%46 = sub nsw i32 %44, %45
%47 = icmp sgt i32 %43, %46
br i1 %47, label %48, label %53
48: ; preds = %42
%49 = load i32, i32* %9
%50 = load i32, i32* %6
%51 = call i64 @gameplay_get_walkable(i32 %49, i32 %50, i32 1)
%52 = icmp ne i64 %51, 0
br label %53
53: ; preds = %48, %42, %39
%54 = phi i1 [ false, %42 ], [ false, %39 ], [ %52, %48 ]
br i1 %54, label %55, label %63
55: ; preds = %53
%56 = load i32, i32* %9
%57 = load i32, i32* %6
%58 = load i8, i8* %8
%59 = call i32 @ai_simulation_explosion_set_unwalkable(i32 %56, i32 %57, i8 signext %58)
br label %60
60: ; preds = %55
%61 = load i32, i32* %9
%62 = add nsw i32 %61, -1
store i32 %62, i32* %9
br label %39
63: ; preds = %53
%64 = load i32, i32* %6
store i32 %64, i32* %10
br label %65
65: ; preds = %86, %63
%66 = load i32, i32* %10
%67 = icmp slt i32 %66, 9
br i1 %67, label %68, label %79
68: ; preds = %65
%69 = load i32, i32* %10
%70 = load i32, i32* %6
%71 = load i32, i32* %7
%72 = add nsw i32 %70, %71
%73 = icmp slt i32 %69, %72
br i1 %73, label %74, label %79
74: ; preds = %68
%75 = load i32, i32* %5
%76 = load i32, i32* %10
%77 = call i64 @gameplay_get_walkable(i32 %75, i32 %76, i32 1)
%78 = icmp ne i64 %77, 0
br label %79
79: ; preds = %74, %68, %65
%80 = phi i1 [ false, %68 ], [ false, %65 ], [ %78, %74 ]
br i1 %80, label %81, label %89
81: ; preds = %79
%82 = load i32, i32* %5
%83 = load i32, i32* %10
%84 = load i8, i8* %8
%85 = call i32 @ai_simulation_explosion_set_unwalkable(i32 %82, i32 %83, i8 signext %84)
br label %86
86: ; preds = %81
%87 = load i32, i32* %10
%88 = add nsw i32 %87, 1
store i32 %88, i32* %10
br label %65
89: ; preds = %79
%90 = load i32, i32* %6
%91 = sub nsw i32 %90, 1
store i32 %91, i32* %10
br label %92
92: ; preds = %113, %89
%93 = load i32, i32* %10
%94 = icmp sgt i32 %93, 0
br i1 %94, label %95, label %106
95: ; preds = %92
%96 = load i32, i32* %10
%97 = load i32, i32* %6
%98 = load i32, i32* %7
%99 = sub nsw i32 %97, %98
%100 = icmp sgt i32 %96, %99
br i1 %100, label %101, label %106
101: ; preds = %95
%102 = load i32, i32* %5
%103 = load i32, i32* %10
%104 = call i64 @gameplay_get_walkable(i32 %102, i32 %103, i32 1)
%105 = icmp ne i64 %104, 0
br label %106
106: ; preds = %101, %95, %92
%107 = phi i1 [ false, %95 ], [ false, %92 ], [ %105, %101 ]
br i1 %107, label %108, label %116
108: ; preds = %106
%109 = load i32, i32* %5
%110 = load i32, i32* %10
%111 = load i8, i8* %8
%112 = call i32 @ai_simulation_explosion_set_unwalkable(i32 %109, i32 %110, i8 signext %111)
br label %113
113: ; preds = %108
%114 = load i32, i32* %10
%115 = add nsw i32 %114, -1
store i32 %115, i32* %10
br label %92
116: ; preds = %106
ret void
}

LLVM IR (-O2):
define void @ai_simulation_explosion(i32 %0, i32 %1, i32 %2, i8 signext %3) {
%5 = add nsw i32 %2, %0
%6 = icmp slt i32 %0, 9
%7 = icmp sgt i32 %2, 0
%8 = and i1 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %4, %13
%10 = phi i32 [ %15, %13 ], [ %0, %4 ]
%11 = tail call i64 @gameplay_get_walkable(i32 %10, i32 %1, i32 1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %9
%14 = tail call i32 @ai_simulation_explosion_set_unwalkable(i32 %10, i32 %1, i8 signext %3)
%15 = add nsw i32 %10, 1
%16 = icmp slt i32 %10, 8
%17 = icmp slt i32 %15, %5
%18 = select i1 %16, i1 %17, i1 false
br i1 %18, label %9, label %19
19: ; preds = %9, %13, %4
%20 = sub nsw i32 %0, %2
%21 = add nsw i32 %0, -1
%22 = icmp sgt i32 %0, 1
%23 = icmp sgt i32 %21, %20
%24 = select i1 %22, i1 %23, i1 false
br i1 %24, label %25, label %35
25: ; preds = %19, %29
%26 = phi i32 [ %31, %29 ], [ %21, %19 ]
%27 = tail call i64 @gameplay_get_walkable(i32 %26, i32 %1, i32 1)
%28 = icmp eq i64 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %25
%30 = tail call i32 @ai_simulation_explosion_set_unwalkable(i32 %26, i32 %1, i8 signext %3)
%31 = add nsw i32 %26, -1
%32 = icmp sgt i32 %26, 1
%33 = icmp sgt i32 %31, %20
%34 = select i1 %32, i1 %33, i1 false
br i1 %34, label %25, label %35
35: ; preds = %25, %29, %19
%36 = add nsw i32 %2, %1
%37 = icmp slt i32 %1, 9
%38 = and i1 %37, %7
br i1 %38, label %39, label %49
39: ; preds = %35, %43
%40 = phi i32 [ %45, %43 ], [ %1, %35 ]
%41 = tail call i64 @gameplay_get_walkable(i32 %0, i32 %40, i32 1)
%42 = icmp eq i64 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %39
%44 = tail call i32 @ai_simulation_explosion_set_unwalkable(i32 %0, i32 %40, i8 signext %3)
%45 = add nsw i32 %40, 1
%46 = icmp slt i32 %40, 8
%47 = icmp slt i32 %45, %36
%48 = select i1 %46, i1 %47, i1 false
br i1 %48, label %39, label %49
49: ; preds = %39, %43, %35
%50 = sub nsw i32 %1, %2
%51 = add nsw i32 %1, -1
%52 = icmp sgt i32 %1, 1
%53 = icmp sgt i32 %51, %50
%54 = select i1 %52, i1 %53, i1 false
br i1 %54, label %55, label %65
55: ; preds = %49, %59
%56 = phi i32 [ %61, %59 ], [ %51, %49 ]
%57 = tail call i64 @gameplay_get_walkable(i32 %0, i32 %56, i32 1)
%58 = icmp eq i64 %57, 0
br i1 %58, label %65, label %59
59: ; preds = %55
%60 = tail call i32 @ai_simulation_explosion_set_unwalkable(i32 %0, i32 %56, i8 signext %3)
%61 = add nsw i32 %56, -1
%62 = icmp sgt i32 %56, 1
%63 = icmp sgt i32 %61, %50
%64 = select i1 %62, i1 %63, i1 false
br i1 %64, label %55, label %65
65: ; preds = %55, %59, %49
ret void
}