#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*/ fill_rect(int, int, int, int, char);
size_t rand();
int screen_height();
int screen_width();
int /*<<< orphan*/ show_screen();
size_t strlen(char *);
void demo() {
  int x = rand() % screen_width() / 2;
  int y = rand() % screen_height() / 2;
  int w = rand() % (screen_width() - x);
  int h = rand() % (screen_height() - y);
  char *chars = "~!@#$%^&*-+";
  char ch = chars[rand() % strlen(chars)];
  fill_rect(x, y, w, h, ch);
  fill_rect(1, 1, 1, 1, '#');
  show_screen();
}


x86 assembly (clang, -O0):
<demo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    $0x0,%al
call   1080 <rand@plt>
mov    %rax,-0x50(%rbp)
mov    $0x0,%al
call   1060 <screen_width@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rcx
xor    %edx,%edx
div    %rcx
shr    $0x1,%rdx
mov    %edx,%eax
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    %rax,-0x48(%rbp)
mov    $0x0,%al
call   1030 <screen_height@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
xor    %edx,%edx
div    %rcx
shr    $0x1,%rdx
mov    %edx,%eax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    %rax,-0x40(%rbp)
mov    $0x0,%al
call   1060 <screen_width@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
sub    -0x4(%rbp),%ecx
movslq %ecx,%rcx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1030 <screen_height@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
sub    -0x8(%rbp),%ecx
movslq %ecx,%rcx
xor    %edx,%edx
div    %rcx
mov    %edx,%eax
mov    %eax,-0x10(%rbp)
lea    0xdef(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
xor    %edx,%edx
div    %rcx
mov    -0x28(%rbp),%rax
mov    (%rax,%rdx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
movsbl -0x19(%rbp),%r8d
call   1070 <fill_rect@plt>
mov    $0x1,%ecx
mov    $0x23,%r8d
mov    %ecx,%edi
mov    %ecx,%esi
mov    %ecx,%edx
call   1070 <fill_rect@plt>
mov    $0x0,%al
call   1050 <show_screen@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<demo>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <screen_width@plt>
mov    %eax,%ecx
movslq %eax,%rsi
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     1187 <demo+0x37>
mov    %rbx,%rax
xor    %edx,%edx
div    %rsi
mov    %rdx,%r14
jmp    1190 <demo+0x40>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%r14d
shr    %r14
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <screen_height@plt>
mov    %eax,%ecx
movslq %eax,%rsi
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     11c2 <demo+0x72>
mov    %rbx,%rax
xor    %edx,%edx
div    %rsi
mov    %rdx,%r12
jmp    11cb <demo+0x7b>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%r12d
shr    %r12
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <screen_width@plt>
mov    %eax,%ecx
sub    %r14d,%ecx
movslq %ecx,%rsi
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     1200 <demo+0xb0>
mov    %rbx,%rax
xor    %edx,%edx
div    %rsi
mov    %rdx,%r15
jmp    1209 <demo+0xb9>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%r15d
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <screen_height@plt>
mov    %eax,%ecx
sub    %r12d,%ecx
movslq %ecx,%rsi
mov    %rbx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     123b <demo+0xeb>
mov    %rbx,%rax
xor    %edx,%edx
div    %rsi
mov    %rdx,%rbx
jmp    1243 <demo+0xf3>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %edx,%ebx
xor    %eax,%eax
call   1070 <rand@plt>
mov    %rax,%rcx
movabs $0x2e8ba2e8ba2e8ba3,%rdx
a2 8b 2e
mul    %rdx
shr    %rdx
lea    (%rdx,%rdx,4),%rax
lea    (%rdx,%rax,2),%rax
sub    %rax,%rcx
lea    0xd91(%rip),%rax
movsbl (%rax,%rcx,1),%r8d
mov    %r14d,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %ebx,%ecx
call   1060 <fill_rect@plt>
mov    $0x1,%edi
mov    $0x1,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
mov    $0x23,%r8d
call   1060 <fill_rect@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <show_screen@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"~!@#$%^&*-+\00"
define void @demo() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
%7 = call i64 (...) @rand()
%8 = call i32 (...) @screen_width()
%9 = sext i32 %8 to i64
%10 = urem i64 %7, %9
%11 = udiv i64 %10, 2
%12 = trunc i64 %11 to i32
store i32 %12, i32* %1
%13 = call i64 (...) @rand()
%14 = call i32 (...) @screen_height()
%15 = sext i32 %14 to i64
%16 = urem i64 %13, %15
%17 = udiv i64 %16, 2
%18 = trunc i64 %17 to i32
store i32 %18, i32* %2
%19 = call i64 (...) @rand()
%20 = call i32 (...) @screen_width()
%21 = load i32, i32* %1
%22 = sub nsw i32 %20, %21
%23 = sext i32 %22 to i64
%24 = urem i64 %19, %23
%25 = trunc i64 %24 to i32
store i32 %25, i32* %3
%26 = call i64 (...) @rand()
%27 = call i32 (...) @screen_height()
%28 = load i32, i32* %2
%29 = sub nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = urem i64 %26, %30
%32 = trunc i64 %31 to i32
store i32 %32, i32* %4
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %5
%33 = load i8*, i8** %5
%34 = call i64 (...) @rand()
%35 = load i8*, i8** %5
%36 = call i64 @strlen(i8* %35)
%37 = urem i64 %34, %36
%38 = getelementptr inbounds i8, i8* %33, i64 %37
%39 = load i8, i8* %38
store i8 %39, i8* %6
%40 = load i32, i32* %1
%41 = load i32, i32* %2
%42 = load i32, i32* %3
%43 = load i32, i32* %4
%44 = load i8, i8* %6
%45 = call i32 @fill_rect(i32 %40, i32 %41, i32 %42, i32 %43, i8 signext %44)
%46 = call i32 @fill_rect(i32 1, i32 1, i32 1, i32 1, i8 signext 35)
%47 = call i32 (...) @show_screen()
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"~!@#$%^&*-+\00"
define void @demo() {
%1 = tail call i64 (...) @rand()
%2 = tail call i32 (...) @screen_width()
%3 = sext i32 %2 to i64
%4 = urem i64 %1, %3
%5 = lshr i64 %4, 1
%6 = trunc i64 %5 to i32
%7 = tail call i64 (...) @rand()
%8 = tail call i32 (...) @screen_height()
%9 = sext i32 %8 to i64
%10 = urem i64 %7, %9
%11 = lshr i64 %10, 1
%12 = trunc i64 %11 to i32
%13 = tail call i64 (...) @rand()
%14 = tail call i32 (...) @screen_width()
%15 = sub nsw i32 %14, %6
%16 = sext i32 %15 to i64
%17 = urem i64 %13, %16
%18 = trunc i64 %17 to i32
%19 = tail call i64 (...) @rand()
%20 = tail call i32 (...) @screen_height()
%21 = sub nsw i32 %20, %12
%22 = sext i32 %21 to i64
%23 = urem i64 %19, %22
%24 = trunc i64 %23 to i32
%25 = tail call i64 (...) @rand()
%26 = urem i64 %25, 11
%27 = getelementptr inbounds [12 x i8], [12 x i8]* @.str, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = tail call i32 @fill_rect(i32 %6, i32 %12, i32 %18, i32 %24, i8 signext %28)
%30 = tail call i32 @fill_rect(i32 1, i32 1, i32 1, i32 1, i8 signext 35)
%31 = tail call i32 (...) @show_screen()
ret void
}