#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 printimatw(int *a, int m, int n, int w) {
  int i, j, jmod;
  for (i = 0; i < m; i++) {
    for (j = 0; j < n; j++) {
      printf("%5d ", a[i * n + j]);
      jmod = (j + 1) % w;
      if ((jmod == 0) && (j < (n - 1))) {
        printf("  ...\n");
      }
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<printimatw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11d2 <printimatw+0xc2>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11b6 <printimatw+0xa6>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x14(%rbp)
mov    %edx,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    11a3 <printimatw+0x93>
mov    -0x1c(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11a3 <printimatw+0x93>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a8 <printimatw+0x98>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113f <printimatw+0x2f>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112c <printimatw+0x1c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printimatw>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,0x8(%rsp)
test   %esi,%esi
jle    11ec <printimatw+0xbc>
mov    %ecx,%r13d
mov    %rdi,%rbx
mov    0x8(%rsp),%rcx
lea    -0x1(%rcx),%eax
movslq %eax,%r14
movslq %ecx,%rax
mov    %esi,%ecx
mov    %rcx,0x10(%rsp)
mov    %eax,%r12d
shl    $0x2,%rax
mov    %rax,0x18(%rsp)
xor    %eax,%eax
jmp    119f <printimatw+0x6f>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x20(%rsp),%rax
add    $0x1,%rax
add    0x18(%rsp),%rbx
cmp    0x10(%rsp),%rax
je     11ec <printimatw+0xbc>
mov    %rax,0x20(%rsp)
cmpl   $0x0,0x8(%rsp)
jle    1180 <printimatw+0x50>
xor    %r15d,%r15d
jmp    11b5 <printimatw+0x85>
cmp    %r15,%r12
je     1180 <printimatw+0x50>
mov    %r15,%rbp
mov    (%rbx,%r15,4),%esi
lea    0xe3d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%r15
mov    %r15d,%eax
cltd
idiv   %r13d
test   %edx,%edx
jne    11b0 <printimatw+0x80>
cmp    %r14,%rbp
jge    11b0 <printimatw+0x80>
lea    0xe20(%rip),%rdi
call   1040 <puts@plt>
jmp    11b0 <printimatw+0x80>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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