#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 */
scalar_t__ AreaClear(int, int, int, int);
int /*<<< orphan*/ GuessCoords(int *, int *);
int /*<<< orphan*/ MakeSquare(int, int, int, int);
int rand();
int BuildSquare(void) {
  int x, y, w, h;
  GuessCoords(&x, &y);
  w = rand() % 9 + 7;
  h = rand() % 9 + 7;
  if (AreaClear(x - 1, y - 1, w + 2, h + 2)) {
    MakeSquare(x, y, w, h);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<BuildSquare>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <GuessCoords@plt>
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
add    $0x7,%edx
mov    %edx,-0x10(%rbp)
mov    $0x0,%al
call   1060 <rand@plt>
mov    $0x9,%ecx
cltd
idiv   %ecx
add    $0x7,%edx
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%edi
sub    $0x1,%edi
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
mov    -0x10(%rbp),%edx
add    $0x2,%edx
mov    -0x14(%rbp),%ecx
add    $0x2,%ecx
call   1040 <AreaClear@plt>
cmp    $0x0,%rax
je     11c3 <BuildSquare+0x83>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
call   1030 <MakeSquare@plt>
movl   $0x1,-0x4(%rbp)
jmp    11ca <BuildSquare+0x8a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BuildSquare>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <GuessCoords@plt>
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebx
cltq
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,8),%r15d
xor    %eax,%eax
call   1060 <rand@plt>
mov    %eax,%ebp
cltq
imul   $0x38e38e39,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x21,%rax
add    %ecx,%eax
lea    (%rax,%rax,8),%r12d
mov    0xc(%rsp),%edi
add    $0xffffffff,%edi
mov    0x8(%rsp),%esi
add    $0xffffffff,%esi
mov    %r15d,%eax
neg    %eax
lea    (%rbx,%rax,1),%edx
add    $0x9,%edx
mov    %r12d,%eax
neg    %eax
lea    (%rax,%rbp,1),%ecx
add    $0x9,%ecx
call   1040 <AreaClear@plt>
test   %rax,%rax
je     11f5 <BuildSquare+0xb5>
sub    %r15d,%ebx
sub    %r12d,%ebp
add    $0x7,%ebp
add    $0x7,%ebx
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   1030 <MakeSquare@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @BuildSquare() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = call i32 @GuessCoords(i32* %2, i32* %3)
%7 = call i32 (...) @rand()
%8 = srem i32 %7, 9
%9 = add nsw i32 %8, 7
store i32 %9, i32* %4
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 9
%12 = add nsw i32 %11, 7
store i32 %12, i32* %5
%13 = load i32, i32* %2
%14 = sub nsw i32 %13, 1
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 1
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 2
%19 = load i32, i32* %5
%20 = add nsw i32 %19, 2
%21 = call i64 @AreaClear(i32 %14, i32 %16, i32 %18, i32 %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %29
23: ; preds = %0
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = load i32, i32* %4
%27 = load i32, i32* %5
%28 = call i32 @MakeSquare(i32 %24, i32 %25, i32 %26, i32 %27)
store i32 1, i32* %1
br label %30
29: ; preds = %0
store i32 0, i32* %1
br label %30
30: ; preds = %29, %23
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
define i32 @BuildSquare() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 @GuessCoords(i32* %1, i32* %2)
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 9
%8 = call i32 (...) @rand()
%9 = srem i32 %8, 9
%10 = load i32, i32* %1
%11 = add nsw i32 %10, -1
%12 = load i32, i32* %2
%13 = add nsw i32 %12, -1
%14 = add nsw i32 %7, 9
%15 = add nsw i32 %9, 9
%16 = call i64 @AreaClear(i32 %11, i32 %13, i32 %14, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %24, label %18
18: ; preds = %0
%19 = add nsw i32 %9, 7
%20 = add nsw i32 %7, 7
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = call i32 @MakeSquare(i32 %21, i32 %22, i32 %20, i32 %19)
br label %24
24: ; preds = %0, %18
%25 = phi i32 [ 1, %18 ], [ 0, %0 ]
ret i32 %25
}