#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 ceil(int);
int /*<<< orphan*/ printf(char *, ...);
void printframe(int width, int height, int *frame) {
  int rows = ceil(height / 8.0);
  printf("   |");
  int i = 0;
  for (int j = 0; j < width; j++) {
    if (j % 5 == 0)
      printf("%d", j / 5);
    else
      printf(" ");
    i++;
    if (i == 10)
      i = 0;
  }
  printf("|\n");
  printf("   ");
  for (int j = 0; j < width + 2; j++) {
    printf("-");
  }
  printf("\n");
  for (int j = 0; j < rows; j++) {
    int mask = 1;
    for (int b = 0; b < 8; b++) {
      printf("%03d|", j * 8 + b);
      for (int i = 0; i < width; i++) {
        if (*((frame + j * width) + i) & mask)
          printf("*");
        else
          printf("_");
      }
      printf("|\n");
      mask <<= 1;
    }
  }
  printf("   ");
  for (int j = 0; j < width + 2; j++) {
    printf("-");
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<printframe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xec1(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <ceil@plt>
mov    %eax,-0x14(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11e6 <printframe+0xc6>
mov    -0x1c(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11ab <printframe+0x8b>
mov    -0x1c(%rbp),%eax
mov    $0x5,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b9 <printframe+0x99>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0xa,-0x18(%rbp)
jne    11d3 <printframe+0xb3>
movl   $0x0,-0x18(%rbp)
jmp    11d8 <printframe+0xb8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116b <printframe+0x4b>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    1236 <printframe+0x116>
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1209 <printframe+0xe9>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    132d <printframe+0x20d>
movl   $0x1,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jge    131a <printframe+0x1fa>
mov    -0x24(%rbp),%esi
shl    $0x3,%esi
add    -0x2c(%rbp),%esi
lea    0xd9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    12f5 <printframe+0x1d5>
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x4(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
and    -0x28(%rbp),%eax
cmp    $0x0,%eax
je     12d4 <printframe+0x1b4>
lea    0xd57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e2 <printframe+0x1c2>
lea    0xd46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12e7 <printframe+0x1c7>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    128d <printframe+0x16d>
lea    0xd14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1265 <printframe+0x145>
jmp    131f <printframe+0x1ff>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    124b <printframe+0x12b>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x4(%rbp),%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
jge    136f <printframe+0x24f>
lea    0xcbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1342 <printframe+0x222>
lea    0xc9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printframe>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %edi,%ebp
cvtsi2sd %esi,%xmm0
mulsd  0xea1(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1050 <ceil@plt>
mov    %eax,%r15d
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,(%rsp)
test   %ebp,%ebp
jle    11cf <printframe+0x8f>
mov    $0xcccccccd,%r12d
lea    0xe7f(%rip),%r14
xor    %ebp,%ebp
jmp    11b2 <printframe+0x72>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
cmp    %ebp,(%rsp)
je     11cf <printframe+0x8f>
mov    %ebp,%esi
imul   %r12,%rsi
shr    $0x22,%rsi
lea    (%rsi,%rsi,4),%eax
cmp    %ebp,%eax
jne    11a0 <printframe+0x60>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11aa <printframe+0x6a>
lea    0xe35(%rip),%rdi
call   1040 <puts@plt>
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    (%rsp),%rax
lea    0x2(%rax),%r14d
cmp    $0xffffffff,%eax
jl     121f <printframe+0xdf>
cmp    $0x2,%r14d
mov    $0x1,%ebp
cmovge %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1210 <printframe+0xd0>
mov    %r14d,0xc(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r15d,%r15d
jle    12f2 <printframe+0x1b2>
mov    (%rsp),%rax
movslq %eax,%rcx
mov    %r15d,%edx
mov    %rdx,0x10(%rsp)
mov    %eax,%r12d
shl    $0x2,%rcx
mov    %rcx,0x18(%rsp)
xor    %eax,%eax
jmp    1275 <printframe+0x135>
cs nopw 0x0(%rax,%rax,1)
mov    0x20(%rsp),%rax
add    $0x1,%rax
add    0x18(%rsp),%rbx
cmp    0x10(%rsp),%rax
je     12f2 <printframe+0x1b2>
mov    %rax,0x20(%rsp)
lea    0x0(,%rax,8),%r13d
mov    $0x1,%r14d
xor    %r15d,%r15d
jmp    12a9 <printframe+0x169>
nopl   (%rax)
lea    0xd74(%rip),%rdi
call   1040 <puts@plt>
add    %r14d,%r14d
add    $0x1,%r15d
cmp    $0x8,%r15d
je     1260 <printframe+0x120>
lea    (%r15,%r13,1),%esi
lea    0xd60(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0x0,(%rsp)
jle    1290 <printframe+0x150>
xor    %ebp,%ebp
jmp    12de <printframe+0x19e>
cs nopw 0x0(%rax,%rax,1)
nop
call   1030 <putchar@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
je     1290 <printframe+0x150>
mov    (%rbx,%rbp,4),%eax
mov    $0x5f,%edi
and    %r14d,%eax
je     12d0 <printframe+0x190>
mov    $0x2a,%edi
jmp    12d0 <printframe+0x190>
lea    0xd17(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmpl   $0xffffffff,(%rsp)
jl     132f <printframe+0x1ef>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
mov    $0x1,%ebx
cmovge %eax,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebx
jne    1320 <printframe+0x1e0>
mov    $0xa,%edi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@.str = [5 x i8] c" |\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [3 x i8] c"|\0A\00"
@.str.4 = [4 x i8] c" \00"
@.str.5 = [2 x i8] c"-\00"
@.str.6 = [2 x i8] c"\0A\00"
@.str.7 = [6 x i8] c"%03d|\00"
@.str.8 = [2 x i8] c"*\00"
@.str.9 = [2 x i8] c"_\00"
define void @printframe(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%16 = load i32, i32* %5
%17 = sitofp i32 %16 to double
%18 = fdiv double %17, 8.000000e+00
%19 = fptosi double %18 to i32
%20 = call i32 @ceil(i32 %19)
store i32 %20, i32* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
store i32 0, i32* %9
br label %22
22: ; preds = %43, %3
%23 = load i32, i32* %9
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %46
26: ; preds = %22
%27 = load i32, i32* %9
%28 = srem i32 %27, 5
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i32, i32* %9
%32 = sdiv i32 %31, 5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %36
34: ; preds = %26
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %30
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
%39 = load i32, i32* %8
%40 = icmp eq i32 %39, 10
br i1 %40, label %41, label %42
41: ; preds = %36
store i32 0, i32* %8
br label %42
42: ; preds = %41, %36
br label %43
43: ; preds = %42
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
store i32 %45, i32* %9
br label %22
46: ; preds = %22
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %10
br label %49
49: ; preds = %56, %46
%50 = load i32, i32* %10
%51 = load i32, i32* %4
%52 = add nsw i32 %51, 2
%53 = icmp slt i32 %50, %52
br i1 %53, label %54, label %59
54: ; preds = %49
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %56
56: ; preds = %54
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
br label %49
59: ; preds = %49
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %11
br label %61
61: ; preds = %109, %59
%62 = load i32, i32* %11
%63 = load i32, i32* %7
%64 = icmp slt i32 %62, %63
br i1 %64, label %65, label %112
65: ; preds = %61
store i32 1, i32* %12
store i32 0, i32* %13
br label %66
66: ; preds = %105, %65
%67 = load i32, i32* %13
%68 = icmp slt i32 %67, 8
br i1 %68, label %69, label %108
69: ; preds = %66
%70 = load i32, i32* %11
%71 = mul nsw i32 %70, 8
%72 = load i32, i32* %13
%73 = add nsw i32 %71, %72
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %73)
store i32 0, i32* %14
br label %75
75: ; preds = %98, %69
%76 = load i32, i32* %14
%77 = load i32, i32* %4
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %101
79: ; preds = %75
%80 = load i32*, i32** %6
%81 = load i32, i32* %11
%82 = load i32, i32* %4
%83 = mul nsw i32 %81, %82
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds i32, i32* %80, i64 %84
%86 = load i32, i32* %14
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds i32, i32* %85, i64 %87
%89 = load i32, i32* %88
%90 = load i32, i32* %12
%91 = and i32 %89, %90
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %95
93: ; preds = %79
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
br label %97
95: ; preds = %79
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0))
br label %97
97: ; preds = %95, %93
br label %98
98: ; preds = %97
%99 = load i32, i32* %14
%100 = add nsw i32 %99, 1
store i32 %100, i32* %14
br label %75
101: ; preds = %75
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%103 = load i32, i32* %12
%104 = shl i32 %103, 1
store i32 %104, i32* %12
br label %105
105: ; preds = %101
%106 = load i32, i32* %13
%107 = add nsw i32 %106, 1
store i32 %107, i32* %13
br label %66
108: ; preds = %66
br label %109
109: ; preds = %108
%110 = load i32, i32* %11
%111 = add nsw i32 %110, 1
store i32 %111, i32* %11
br label %61
112: ; preds = %61
%113 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %15
br label %114
114: ; preds = %121, %112
%115 = load i32, i32* %15
%116 = load i32, i32* %4
%117 = add nsw i32 %116, 2
%118 = icmp slt i32 %115, %117
br i1 %118, label %119, label %124
119: ; preds = %114
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %121
121: ; preds = %119
%122 = load i32, i32* %15
%123 = add nsw i32 %122, 1
store i32 %123, i32* %15
br label %114
124: ; preds = %114
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c" |\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.4 = [4 x i8] c" \00"
@.str.7 = [6 x i8] c"%03d|\00"
@str.10 = [2 x i8] c"|\00"
define void @printframe(i32 %0, i32 %1, i32* nocapture %2) {
%4 = sitofp i32 %1 to double
%5 = fmul double %4, 1.250000e-01
%6 = fptosi double %5 to i32
%7 = tail call i32 @ceil(i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = icmp sgt i32 %0, 0
br i1 %9, label %17, label %10
10: ; preds = %26, %3
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.10, i64 0, i64 0))
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%13 = add i32 %0, 2
%14 = icmp sgt i32 %0, -2
br i1 %14, label %15, label %29
15: ; preds = %10
%16 = call i32 @llvm.smax.i32(i32 %13, i32 1)
br label %36
17: ; preds = %3, %26
%18 = phi i32 [ %27, %26 ], [ 0, %3 ]
%19 = urem i32 %18, 5
%20 = udiv i32 %18, 5
%21 = icmp eq i32 %19, 0
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %20)
br label %26
24: ; preds = %17
%25 = tail call i32 @putchar(i32 32)
br label %26
26: ; preds = %24, %22
%27 = add nuw nsw i32 %18, 1
%28 = icmp eq i32 %27, %0
br i1 %28, label %10, label %17
29: ; preds = %36, %10
%30 = tail call i32 @putchar(i32 10)
%31 = icmp sgt i32 %7, 0
br i1 %31, label %32, label %47
32: ; preds = %29
%33 = sext i32 %0 to i64
%34 = zext i32 %7 to i64
%35 = zext i32 %0 to i64
br label %41
36: ; preds = %15, %36
%37 = phi i32 [ %39, %36 ], [ 0, %15 ]
%38 = tail call i32 @putchar(i32 45)
%39 = add nuw nsw i32 %37, 1
%40 = icmp eq i32 %39, %16
br i1 %40, label %29, label %36
41: ; preds = %32, %51
%42 = phi i64 [ 0, %32 ], [ %52, %51 ]
%43 = mul nsw i64 %42, %33
%44 = getelementptr inbounds i32, i32* %2, i64 %43
%45 = trunc i64 %42 to i32
%46 = shl i32 %45, 3
br label %54
47: ; preds = %51, %29
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br i1 %14, label %49, label %74
49: ; preds = %47
%50 = call i32 @llvm.smax.i32(i32 %13, i32 1)
br label %76
51: ; preds = %59
%52 = add nuw nsw i64 %42, 1
%53 = icmp eq i64 %52, %34
br i1 %53, label %47, label %41
54: ; preds = %41, %59
%55 = phi i32 [ 0, %41 ], [ %62, %59 ]
%56 = phi i32 [ 1, %41 ], [ %61, %59 ]
%57 = add nuw nsw i32 %55, %46
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0), i32 %57)
br i1 %9, label %64, label %59
59: ; preds = %64, %54
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.10, i64 0, i64 0))
%61 = shl i32 %56, 1
%62 = add nuw nsw i32 %55, 1
%63 = icmp eq i32 %62, 8
br i1 %63, label %51, label %54
64: ; preds = %54, %64
%65 = phi i64 [ %72, %64 ], [ 0, %54 ]
%66 = getelementptr inbounds i32, i32* %44, i64 %65
%67 = load i32, i32* %66
%68 = and i32 %67, %56
%69 = icmp eq i32 %68, 0
%70 = select i1 %69, i32 95, i32 42
%71 = tail call i32 @putchar(i32 %70)
%72 = add nuw nsw i64 %65, 1
%73 = icmp eq i64 %72, %35
br i1 %73, label %59, label %64
74: ; preds = %76, %47
%75 = tail call i32 @putchar(i32 10)
ret void
76: ; preds = %49, %76
%77 = phi i32 [ %79, %76 ], [ 0, %49 ]
%78 = tail call i32 @putchar(i32 45)
%79 = add nuw nsw i32 %77, 1
%80 = icmp eq i32 %79, %50
br i1 %80, label %74, label %76
}