#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*/ printf(char *, ...);
void print_map(short *map, int c, int r) {
  for (int i = 0; i < c << 1; i++)
    printf("-");
  printf("\n");
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      printf("%hd ", map[i * c + j]);
    }
    printf("\n");
  }
  for (int i = 0; i < c << 1; i++)
    printf("-");
  printf("\n");
}


x86 assembly (clang, -O0):
<print_map>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1156 <print_map+0x46>
lea    0xebf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1129 <print_map+0x19>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11d7 <print_map+0xc7>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11bb <print_map+0xab>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movswl (%rax,%rcx,2),%esi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117e <print_map+0x6e>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116b <print_map+0x5b>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    120b <print_map+0xfb>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11de <print_map+0xce>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_map>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%r15d
mov    %rdi,%rbx
mov    %rsi,0x8(%rsp)
lea    (%rsi,%rsi,1),%r14d
test   %r14d,%r14d
jle    115f <print_map+0x3f>
mov    %r14d,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1150 <print_map+0x30>
mov    %r14d,0x4(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
test   %r15d,%r15d
jle    11ea <print_map+0xca>
mov    0x8(%rsp),%rax
movslq %eax,%rbp
mov    %r15d,%ecx
mov    %rcx,0x10(%rsp)
mov    %eax,%r14d
add    %rbp,%rbp
lea    0xe70(%rip),%r15
xor    %r13d,%r13d
jmp    11b8 <print_map+0x98>
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r13
add    %rbp,%rbx
cmp    0x10(%rsp),%r13
je     11ea <print_map+0xca>
cmpl   $0x0,0x8(%rsp)
jle    11a0 <print_map+0x80>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movswl (%rbx,%r12,2),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12
cmp    %r12,%r14
jne    11d0 <print_map+0xb0>
jmp    11a0 <print_map+0x80>
mov    0x4(%rsp),%ebp
test   %ebp,%ebp
jle    120f <print_map+0xef>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2d,%edi
call   1030 <putchar@plt>
add    $0xffffffff,%ebp
jne    1200 <print_map+0xe0>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
@.str.2 = [5 x i8] c"%hd \00"
define void @print_map(i16* nocapture %0, i32 %1, i32 %2) {
%4 = shl i32 %1, 1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %14, label %6
6: ; preds = %14, %3
%7 = tail call i32 @putchar(i32 10)
%8 = icmp sgt i32 %2, 0
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = icmp sgt i32 %1, 0
%11 = sext i32 %1 to i64
%12 = zext i32 %2 to i64
%13 = zext i32 %1 to i64
br label %19
14: ; preds = %3, %14
%15 = phi i32 [ %17, %14 ], [ 0, %3 ]
%16 = tail call i32 @putchar(i32 45)
%17 = add nuw nsw i32 %15, 1
%18 = icmp eq i32 %17, %4
br i1 %18, label %6, label %14
19: ; preds = %9, %24
%20 = phi i64 [ 0, %9 ], [ %26, %24 ]
br i1 %10, label %21, label %24
21: ; preds = %19
%22 = mul nsw i64 %20, %11
br label %28
23: ; preds = %24, %6
br i1 %5, label %39, label %37
24: ; preds = %28, %19
%25 = tail call i32 @putchar(i32 10)
%26 = add nuw nsw i64 %20, 1
%27 = icmp eq i64 %26, %12
br i1 %27, label %23, label %19
28: ; preds = %21, %28
%29 = phi i64 [ 0, %21 ], [ %35, %28 ]
%30 = add nsw i64 %29, %22
%31 = getelementptr inbounds i16, i16* %0, i64 %30
%32 = load i16, i16* %31
%33 = sext i16 %32 to i32
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = add nuw nsw i64 %29, 1
%36 = icmp eq i64 %35, %13
br i1 %36, label %24, label %28
37: ; preds = %39, %23
%38 = tail call i32 @putchar(i32 10)
ret void
39: ; preds = %23, %39
%40 = phi i32 [ %42, %39 ], [ 0, %23 ]
%41 = tail call i32 @putchar(i32 45)
%42 = add nuw nsw i32 %40, 1
%43 = icmp eq i32 %42, %4
br i1 %43, label %37, label %39
}