#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 COLS;
int LINES;
int /*<<< orphan*/ clear();
int /*<<< orphan*/ mvaddch(int, int, char);
int /*<<< orphan*/ mvaddstr(int, int, char *);
int rand();
int /*<<< orphan*/ refresh();
void screen() {
  int r, c, n;
  int i;
  clear();
  i = (rand() % (100));
  for (n = 0; n < i; n++) {
    r = (rand() % (LINES - 3)) + 1;
    c = (rand() % (COLS));
    mvaddch(r, c, '.');
  }
  mvaddstr(LINES - 1 - 1, 21, "TORPEDOES           FUEL           TIME");
  refresh();
}


x86 assembly (clang, -O0):
<screen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <clear@plt>
mov    $0x0,%al
call   1070 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d2 <screen+0x82>
mov    $0x0,%al
call   1070 <rand@plt>
mov    0x2e56(%rip),%rcx
mov    (%rcx),%ecx
sub    $0x3,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x4(%rbp)
mov    $0x0,%al
call   1070 <rand@plt>
mov    0x2e32(%rip),%rcx
cltd
idivl  (%rcx)
mov    %edx,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x2e,%edx
call   1040 <mvaddch@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1178 <screen+0x28>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
sub    $0x1,%edi
sub    $0x1,%edi
mov    $0x15,%esi
lea    0xe13(%rip),%rdx
call   1050 <mvaddstr@plt>
mov    $0x0,%al
call   1030 <refresh@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<screen>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1060 <clear@plt>
xor    %eax,%eax
call   1070 <rand@plt>
movslq %eax,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
test   %ebx,%ebx
jle    11d1 <screen+0x81>
mov    0x2e5c(%rip),%r14
mov    0x2e4d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1070 <rand@plt>
mov    (%r14),%ecx
add    $0xfffffffd,%ecx
cltd
idiv   %ecx
lea    0x1(%rdx),%ebp
xor    %eax,%eax
call   1070 <rand@plt>
cltd
idivl  (%r15)
mov    %ebp,%edi
mov    %edx,%esi
mov    $0x2e,%edx
call   1040 <mvaddch@plt>
add    $0xffffffff,%ebx
jne    11a0 <screen+0x50>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
add    $0xfffffffe,%edi
lea    0xe1c(%rip),%rdx
mov    $0x15,%esi
call   1050 <mvaddstr@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <refresh@plt>

LLVM IR (-O0):
@LINES = global i32 0
@COLS = global i32 0
@.str = [40 x i8] c"TORPEDOES FUEL TIME\00"
define void @screen() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (...) @clear()
%6 = call i32 (...) @rand()
%7 = srem i32 %6, 100
store i32 %7, i32* %4
store i32 0, i32* %3
br label %8
8: ; preds = %24, %0
%9 = load i32, i32* %3
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %27
12: ; preds = %8
%13 = call i32 (...) @rand()
%14 = load i32, i32* @LINES
%15 = sub nsw i32 %14, 3
%16 = srem i32 %13, %15
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
%18 = call i32 (...) @rand()
%19 = load i32, i32* @COLS
%20 = srem i32 %18, %19
store i32 %20, i32* %2
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = call i32 @mvaddch(i32 %21, i32 %22, i8 signext 46)
br label %24
24: ; preds = %12
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %8
27: ; preds = %8
%28 = load i32, i32* @LINES
%29 = sub nsw i32 %28, 1
%30 = sub nsw i32 %29, 1
%31 = call i32 @mvaddstr(i32 %30, i32 21, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%32 = call i32 (...) @refresh()
ret void
}

LLVM IR (-O2):
@LINES = global i32 0
@COLS = global i32 0
@.str = [40 x i8] c"TORPEDOES FUEL TIME\00"
define void @screen() {
%1 = tail call i32 (...) @clear()
%2 = tail call i32 (...) @rand()
%3 = srem i32 %2, 100
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %18
5: ; preds = %0, %5
%6 = phi i32 [ %16, %5 ], [ 0, %0 ]
%7 = tail call i32 (...) @rand()
%8 = load i32, i32* @LINES
%9 = add nsw i32 %8, -3
%10 = srem i32 %7, %9
%11 = add nsw i32 %10, 1
%12 = tail call i32 (...) @rand()
%13 = load i32, i32* @COLS
%14 = srem i32 %12, %13
%15 = tail call i32 @mvaddch(i32 %11, i32 %14, i8 signext 46)
%16 = add nuw nsw i32 %6, 1
%17 = icmp eq i32 %16, %3
br i1 %17, label %18, label %5
18: ; preds = %5, %0
%19 = load i32, i32* @LINES
%20 = add nsw i32 %19, -2
%21 = tail call i32 @mvaddstr(i32 %20, i32 21, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%22 = tail call i32 (...) @refresh()
ret void
}