#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 */
scalar_t__ areEqual(unsigned int *, unsigned int *, short);
int /*<<< orphan*/ buildLine(unsigned int *, short, int);
int /*<<< orphan*/ copy(unsigned int *, unsigned int *, short);
int /*<<< orphan*/ dumpLine(unsigned int *, short, int);
int /*<<< orphan*/ printf(char *);
void dumpMem(short wordsperline) {
  unsigned int prevLine[wordsperline];
  unsigned int currLine[wordsperline];
  int address = 0;
  buildLine(prevLine, wordsperline, address);
  dumpLine(prevLine, wordsperline, address);
  int star = 0;
  for (address = wordsperline; address < 16384; address += wordsperline) {
    buildLine(currLine, wordsperline, address);
    if (areEqual(prevLine, currLine, wordsperline)) {
      if (!star) {
        printf("*\n");
        star = 1;
      }
    } else {
      printf("\n");
      dumpLine(currLine, wordsperline, address);
      star = 0;
    }
    copy(prevLine, currLine, wordsperline);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<dumpMem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%edx
mov    %edx,%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %edx,%ecx
lea    0xf(,%rcx,4),%edx
mov    %edx,%ecx
and    $0xfffffff0,%ecx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
movzwl -0x2(%rbp),%edx
mov    %edx,%eax
mov    %edx,%ecx
lea    0xf(,%rcx,4),%edx
mov    %edx,%ecx
and    $0xfffffff0,%ecx
mov    %ecx,%edx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x2(%rbp),%ax
mov    -0x24(%rbp),%edx
movswl %ax,%esi
call   1050 <buildLine@plt>
mov    -0x30(%rbp),%rdi
mov    -0x2(%rbp),%ax
mov    -0x24(%rbp),%edx
movswl %ax,%esi
call   1070 <dumpLine@plt>
movl   $0x0,-0x28(%rbp)
movswl -0x2(%rbp),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x4000,-0x24(%rbp)
jge    128c <dumpMem+0x13c>
mov    -0x38(%rbp),%rdi
mov    -0x2(%rbp),%ax
mov    -0x24(%rbp),%edx
movswl %ax,%esi
call   1050 <buildLine@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
movswl -0x2(%rbp),%edx
call   1060 <areEqual@plt>
cmp    $0x0,%rax
je     1246 <dumpMem+0xf6>
cmpl   $0x0,-0x28(%rbp)
jne    1241 <dumpMem+0xf1>
lea    0xdcb(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x28(%rbp)
jmp    126c <dumpMem+0x11c>
lea    0xdb4(%rip),%rdi
call   1030 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x2(%rbp),%ax
mov    -0x24(%rbp),%edx
movswl %ax,%esi
call   1070 <dumpLine@plt>
movl   $0x0,-0x28(%rbp)
mov    -0x38(%rbp),%rsi
mov    -0x30(%rbp),%rdi
movswl -0x2(%rbp),%edx
call   1040 <copy@plt>
movswl -0x2(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11e9 <dumpMem+0x99>
lea    0xd6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpMem>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r14d
movzwl %r14w,%eax
lea    0xf(,%rax,4),%eax
and    $0xfffffff0,%eax
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
movl   $0x0,-0x30(%rbp)
mov    %r15,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   1060 <buildLine@plt>
mov    %r15,%rdi
mov    %r14d,%esi
xor    %edx,%edx
call   1080 <dumpLine@plt>
mov    %r14d,-0x2c(%rbp)
cmp    $0x3fff,%r14d
jg     1258 <dumpMem+0xf8>
mov    -0x2c(%rbp),%r14d
movswl %r14w,%r13d
mov    %r15,-0x38(%rbp)
mov    -0x38(%rbp),%rbx
jmp    121d <dumpMem+0xbd>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r14d,%edx
call   1080 <dumpLine@plt>
xor    %r15d,%r15d
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1050 <copy@plt>
add    -0x2c(%rbp),%r14d
mov    %r15d,-0x30(%rbp)
mov    %rbx,%r15
cmp    $0x4000,%r14d
jge    1258 <dumpMem+0xf8>
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r14d,%edx
call   1060 <buildLine@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
call   1070 <areEqual@plt>
test   %rax,%rax
je     11e0 <dumpMem+0x80>
mov    $0x1,%r15d
cmpl   $0x0,-0x30(%rbp)
jne    11fb <dumpMem+0x9b>
lea    0xdaf(%rip),%rdi
call   1040 <puts@plt>
jmp    11fb <dumpMem+0x9b>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@str = [2 x i8] c"*\00"
define void @dumpMem(i16 signext %0) {
%2 = zext i16 %0 to i64
%3 = alloca i32, i64 %2
%4 = alloca i32, i64 %2
%5 = call i32 @buildLine(i32* %3, i16 signext %0, i32 0)
%6 = call i32 @dumpLine(i32* %3, i16 signext %0, i32 0)
%7 = sext i16 %0 to i32
%8 = icmp slt i16 %0, 16384
br i1 %8, label %9, label %27
9: ; preds = %1, %22
%10 = phi i32 [ %23, %22 ], [ 0, %1 ]
%11 = phi i32 [ %25, %22 ], [ %7, %1 ]
%12 = call i32 @buildLine(i32* %4, i16 signext %0, i32 %11)
%13 = call i64 @areEqual(i32* %3, i32* %4, i16 signext %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %9
%16 = icmp eq i32 %10, 0
br i1 %16, label %17, label %22
17: ; preds = %15
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %22
19: ; preds = %9
%20 = call i32 @putchar(i32 10)
%21 = call i32 @dumpLine(i32* %4, i16 signext %0, i32 %11)
br label %22
22: ; preds = %15, %17, %19
%23 = phi i32 [ 1, %15 ], [ 1, %17 ], [ 0, %19 ]
%24 = call i32 @copy(i32* %3, i32* %4, i16 signext %0)
%25 = add nsw i32 %11, %7
%26 = icmp slt i32 %25, 16384
br i1 %26, label %9, label %27
27: ; preds = %22, %1
%28 = call i32 @putchar(i32 10)
ret void
}