#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__ COLS;
int FALSE;
scalar_t__ LINES;
int TRUE;
int getrandom(scalar_t__);
int mvinch(int, int);
int /*<<< orphan*/ mvprintw(int, int, char *);
void random_dollar() {
  int dollar_y, dollar_x;
  bool placed = FALSE;
  do {
    dollar_y = 2 + getrandom(LINES - 2);
    dollar_x = 1 + getrandom(COLS - 2);
    if (mvinch(dollar_y, dollar_x) == 32) {
      placed = TRUE;
    }
  } while (!placed);
  mvprintw(dollar_y, dollar_x, "$");
}


x86 assembly (clang, -O0):
<random_dollar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%rdi
sub    $0x2,%rdi
call   1040 <getrandom@plt>
add    $0x2,%eax
mov    %eax,-0x4(%rbp)
mov    0x2e74(%rip),%rax
mov    (%rax),%rdi
sub    $0x2,%rdi
call   1040 <getrandom@plt>
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <mvinch@plt>
cmp    $0x20,%eax
jne    1196 <random_dollar+0x66>
mov    0x2e4f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
jmp    119b <random_dollar+0x6b>
cmpl   $0x0,-0xc(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1144 <random_dollar+0x14>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    0xe47(%rip),%rdx
call   1050 <mvprintw@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_dollar>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2e86(%rip),%rax
mov    (%rax),%r13d
mov    0x2e9c(%rip),%r14
mov    (%r14),%rdi
add    $0xfffffffffffffffe,%rdi
call   1040 <getrandom@plt>
mov    %eax,%ebx
add    $0x2,%ebx
mov    0x2e74(%rip),%r15
mov    (%r15),%rdi
add    $0xfffffffffffffffe,%rdi
call   1040 <getrandom@plt>
mov    %eax,%ebp
add    $0x1,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <mvinch@plt>
mov    0x2e5b(%rip),%r12
cmp    $0x20,%eax
jne    118e <random_dollar+0x5e>
mov    (%r12),%r13d
test   %r13d,%r13d
jne    11d7 <random_dollar+0xa7>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r14),%rdi
add    $0xfffffffffffffffe,%rdi
call   1040 <getrandom@plt>
mov    %eax,%ebx
add    $0x2,%ebx
mov    (%r15),%rdi
add    $0xfffffffffffffffe,%rdi
call   1040 <getrandom@plt>
mov    %eax,%ebp
add    $0x1,%ebp
mov    %ebx,%edi
mov    %ebp,%esi
call   1030 <mvinch@plt>
cmp    $0x20,%eax
jne    11a0 <random_dollar+0x70>
cmpl   $0x0,(%r12)
je     11a0 <random_dollar+0x70>
lea    0xe22(%rip),%rdx
mov    %ebx,%edi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <mvprintw@plt>

LLVM IR (-O0):
@FALSE = global i32 0
@LINES = global i64 0
@COLS = global i64 0
@TRUE = global i32 0
@.str = [2 x i8] c"$\00"
define void @random_dollar() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @FALSE
store i32 %4, i32* %3
br label %5
5: ; preds = %21, %0
%6 = load i64, i64* @LINES
%7 = sub nsw i64 %6, 2
%8 = call i32 @getrandom(i64 %7)
%9 = add nsw i32 2, %8
store i32 %9, i32* %1
%10 = load i64, i64* @COLS
%11 = sub nsw i64 %10, 2
%12 = call i32 @getrandom(i64 %11)
%13 = add nsw i32 1, %12
store i32 %13, i32* %2
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = call i32 @mvinch(i32 %14, i32 %15)
%17 = icmp eq i32 %16, 32
br i1 %17, label %18, label %20
18: ; preds = %5
%19 = load i32, i32* @TRUE
store i32 %19, i32* %3
br label %20
20: ; preds = %18, %5
br label %21
21: ; preds = %20
%22 = load i32, i32* %3
%23 = icmp ne i32 %22, 0
%24 = xor i1 %23, true
br i1 %24, label %5, label %25
25: ; preds = %21
%26 = load i32, i32* %1
%27 = load i32, i32* %2
%28 = call i32 @mvprintw(i32 %26, i32 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@FALSE = global i32 0
@LINES = global i64 0
@COLS = global i64 0
@TRUE = global i32 0
@.str = [2 x i8] c"$\00"
define void @random_dollar() {
%1 = load i32, i32* @FALSE
%2 = load i64, i64* @LINES
%3 = add nsw i64 %2, -2
%4 = tail call i32 @getrandom(i64 %3)
%5 = add nsw i32 %4, 2
%6 = load i64, i64* @COLS
%7 = add nsw i64 %6, -2
%8 = tail call i32 @getrandom(i64 %7)
%9 = add nsw i32 %8, 1
%10 = tail call i32 @mvinch(i32 %5, i32 %9)
%11 = icmp eq i32 %10, 32
%12 = load i32, i32* @TRUE
%13 = select i1 %11, i32 %12, i32 %1
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %0, %15
%16 = load i64, i64* @LINES
%17 = add nsw i64 %16, -2
%18 = tail call i32 @getrandom(i64 %17)
%19 = add nsw i32 %18, 2
%20 = load i64, i64* @COLS
%21 = add nsw i64 %20, -2
%22 = tail call i32 @getrandom(i64 %21)
%23 = add nsw i32 %22, 1
%24 = tail call i32 @mvinch(i32 %19, i32 %23)
%25 = icmp ne i32 %24, 32
%26 = load i32, i32* @TRUE
%27 = icmp eq i32 %26, 0
%28 = select i1 %25, i1 true, i1 %27
br i1 %28, label %15, label %29
29: ; preds = %15, %0
%30 = phi i32 [ %5, %0 ], [ %19, %15 ]
%31 = phi i32 [ %9, %0 ], [ %23, %15 ]
%32 = tail call i32 @mvprintw(i32 %30, i32 %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}