#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*/ clearscreen();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ usleep(int);
void do_display(int rmin, int rmax, int cmin, int cmax, short **grid) {
  int i, j;
  int delay = 800000;
  clearscreen();
  for (i = cmin; i <= cmax; i++)
    printf("-");
  printf("\n");
  for (i = rmin; i <= rmax; i++) {
    for (j = cmin; j <= cmax; j++)
      if (grid[i][j] == 0)
        printf(" ");
      else
        printf("x");
    printf("\n");
  }
  usleep(delay);
}


x86 assembly (clang, -O0):
<do_display>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8,-0x18(%rbp)
movl   $0xc3500,-0x24(%rbp)
mov    $0x0,%al
call   1030 <clearscreen@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1182 <do_display+0x52>
lea    0xe91(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    115c <do_display+0x2c>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1219 <do_display+0xe9>
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     11ff <do_display+0xcf>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x20(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
cmp    $0x0,%eax
jne    11e0 <do_display+0xb0>
lea    0xe2e(%rip),%rdi
call   1040 <printf@plt>
jmp    11ec <do_display+0xbc>
lea    0xe1f(%rip),%rdi
call   1040 <printf@plt>
jmp    11f1 <do_display+0xc1>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a6 <do_display+0x76>
lea    0xdfc(%rip),%rdi
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1194 <do_display+0x64>
mov    -0x24(%rbp),%edi
call   1050 <usleep@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_display>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,%rbx
mov    %ecx,%ebp
mov    %edx,%r12d
mov    %esi,0x8(%rsp)
mov    %edi,%r14d
xor    %eax,%eax
call   1040 <clearscreen@plt>
mov    %ebp,%r15d
cmp    %ebp,%r12d
jg     117f <do_display+0x4f>
mov    %r15d,%ebp
sub    %r12d,%ebp
add    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1170 <do_display+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmp    0x8(%rsp),%r14d
jle    11a8 <do_display+0x78>
mov    $0xc3500,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <usleep@plt>
movslq %r12d,%rax
mov    %rax,0x10(%rsp)
movslq %r14d,%rbp
addl   $0x1,0x8(%rsp)
mov    %r15d,%eax
sub    %r12d,%eax
add    $0x1,%eax
mov    %eax,0xc(%rsp)
jmp    11e4 <do_display+0xb4>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %ebp,0x8(%rsp)
je     1190 <do_display+0x60>
cmp    %r15d,%r12d
jg     11d0 <do_display+0xa0>
mov    0xc(%rsp),%r13d
mov    0x10(%rsp),%r14
jmp    120f <do_display+0xdf>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <putchar@plt>
add    $0x1,%r14
add    $0xffffffff,%r13d
je     11d0 <do_display+0xa0>
mov    (%rbx,%rbp,8),%rax
cmpw   $0x0,(%rax,%r14,2)
mov    $0x20,%edi
je     1200 <do_display+0xd0>
mov    $0x78,%edi
jmp    1200 <do_display+0xd0>

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"x\00"
define void @do_display(i32 %0, i32 %1, i32 %2, i32 %3, i16** %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i16**
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i16** %4, i16*** %10
store i32 800000, i32* %13
%14 = call i32 (...) @clearscreen()
%15 = load i32, i32* %8
store i32 %15, i32* %11
br label %16
16: ; preds = %22, %5
%17 = load i32, i32* %11
%18 = load i32, i32* %9
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20
%23 = load i32, i32* %11
%24 = add nsw i32 %23, 1
store i32 %24, i32* %11
br label %16
25: ; preds = %16
%26 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%27 = load i32, i32* %6
store i32 %27, i32* %11
br label %28
28: ; preds = %60, %25
%29 = load i32, i32* %11
%30 = load i32, i32* %7
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %63
32: ; preds = %28
%33 = load i32, i32* %8
store i32 %33, i32* %12
br label %34
34: ; preds = %55, %32
%35 = load i32, i32* %12
%36 = load i32, i32* %9
%37 = icmp sle i32 %35, %36
br i1 %37, label %38, label %58
38: ; preds = %34
%39 = load i16**, i16*** %10
%40 = load i32, i32* %11
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i16*, i16** %39, i64 %41
%43 = load i16*, i16** %42
%44 = load i32, i32* %12
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i16, i16* %43, i64 %45
%47 = load i16, i16* %46
%48 = sext i16 %47 to i32
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %38
%51 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %54
52: ; preds = %38
%53 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %54
54: ; preds = %52, %50
br label %55
55: ; preds = %54
%56 = load i32, i32* %12
%57 = add nsw i32 %56, 1
store i32 %57, i32* %12
br label %34
58: ; preds = %34
%59 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %60
60: ; preds = %58
%61 = load i32, i32* %11
%62 = add nsw i32 %61, 1
store i32 %62, i32* %11
br label %28
63: ; preds = %28
%64 = load i32, i32* %13
%65 = call i32 @usleep(i32 %64)
ret void
}

LLVM IR (-O2):
define void @do_display(i32 %0, i32 %1, i32 %2, i32 %3, i16** nocapture %4) {
%6 = tail call i32 (...) @clearscreen()
%7 = icmp sgt i32 %2, %3
br i1 %7, label %13, label %8
8: ; preds = %5, %8
%9 = phi i32 [ %11, %8 ], [ %2, %5 ]
%10 = tail call i32 @putchar(i32 45)
%11 = add i32 %9, 1
%12 = icmp eq i32 %9, %3
br i1 %12, label %13, label %8
13: ; preds = %8, %5
%14 = tail call i32 @putchar(i32 10)
%15 = icmp sgt i32 %0, %1
br i1 %15, label %41, label %16
16: ; preds = %13
%17 = sext i32 %2 to i64
%18 = add i32 %3, 1
%19 = sext i32 %0 to i64
%20 = add i32 %1, 1
br label %21
21: ; preds = %16, %36
%22 = phi i64 [ %19, %16 ], [ %38, %36 ]
br i1 %7, label %36, label %23
23: ; preds = %21
%24 = getelementptr inbounds i16*, i16** %4, i64 %22
br label %25
25: ; preds = %23, %25
%26 = phi i64 [ %17, %23 ], [ %33, %25 ]
%27 = load i16*, i16** %24
%28 = getelementptr inbounds i16, i16* %27, i64 %26
%29 = load i16, i16* %28
%30 = icmp eq i16 %29, 0
%31 = select i1 %30, i32 32, i32 120
%32 = tail call i32 @putchar(i32 %31)
%33 = add nsw i64 %26, 1
%34 = trunc i64 %33 to i32
%35 = icmp eq i32 %18, %34
br i1 %35, label %36, label %25
36: ; preds = %25, %21
%37 = tail call i32 @putchar(i32 10)
%38 = add nsw i64 %22, 1
%39 = trunc i64 %38 to i32
%40 = icmp eq i32 %20, %39
br i1 %40, label %41, label %21
41: ; preds = %36, %13
%42 = tail call i32 @usleep(i32 800000)
ret void
}