#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 array_print_l(const unsigned int m, const unsigned int n, const long *A,
                   const char layout) {
  unsigned int i, j;
  switch (layout) {
  case 'R':
    for (i = 0; i < m; i++) {
      for (j = 0; j < n; j++)
        printf("% 12ld ", A[i * n + j]);
      printf("\n");
    }
    printf("\n");
    break;
  case 'C':
    for (i = 0; i < m; i++) {
      for (j = 0; j < n; j++)
        printf("% 12ld ", A[i + j * m]);
      printf("\n");
    }
    printf("\n");
    break;
  }
}


x86 assembly (clang, -O0):
<array_print_l>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%eax
mov    %eax,-0x20(%rbp)
sub    $0x43,%eax
je     11d2 <array_print_l+0xc2>
jmp    113c <array_print_l+0x2c>
mov    -0x20(%rbp),%eax
sub    $0x52,%eax
jne    1254 <array_print_l+0x144>
jmp    114d <array_print_l+0x3d>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11bf <array_print_l+0xaf>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    11a3 <array_print_l+0x93>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x1c(%rbp),%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <array_print_l+0x57>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <array_print_l+0x44>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1254 <array_print_l+0x144>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1246 <array_print_l+0x136>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    122a <array_print_l+0x11a>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%edx
imul   -0x4(%rbp),%edx
add    %edx,%ecx
mov    %ecx,%ecx
mov    (%rax,%rcx,8),%rsi
lea    0xdeb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11ec <array_print_l+0xdc>
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11d9 <array_print_l+0xc9>
lea    0xdbb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_print_l>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %edi,%r12d
cmp    $0x52,%ecx
mov    %esi,0x4(%rsp)
je     11bc <array_print_l+0x9c>
cmp    $0x43,%ecx
jne    1245 <array_print_l+0x125>
test   %r12d,%r12d
je     122d <array_print_l+0x10d>
mov    %esi,%eax
mov    %rax,0x8(%rsp)
lea    0xea3(%rip),%r15
xor    %r14d,%r14d
jmp    118b <array_print_l+0x6b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
cmp    %r12d,%r14d
mov    0x4(%rsp),%esi
je     122d <array_print_l+0x10d>
test   %esi,%esi
je     1170 <array_print_l+0x50>
mov    0x8(%rsp),%rbp
mov    %r14d,%r13d
nopw   0x0(%rax,%rax,1)
mov    %r13d,%eax
mov    (%rbx,%rax,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    %r12d,%r13d
add    $0xffffffffffffffff,%rbp
jne    11a0 <array_print_l+0x80>
jmp    1170 <array_print_l+0x50>
test   %r12d,%r12d
je     122d <array_print_l+0x10d>
mov    %esi,%eax
mov    %rax,0x10(%rsp)
lea    0xe31(%rip),%r15
movl   $0x0,0x8(%rsp)
xor    %ebp,%ebp
jmp    11fa <array_print_l+0xda>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%esi
add    %esi,0x8(%rsp)
cmp    %r12d,%ebp
je     122d <array_print_l+0x10d>
test   %esi,%esi
je     11e0 <array_print_l+0xc0>
mov    0x10(%rsp),%r14
mov    0x8(%rsp),%r13d
nopl   0x0(%rax,%rax,1)
mov    %r13d,%eax
mov    (%rbx,%rax,8),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13d
add    $0xffffffffffffffff,%r14
jne    1210 <array_print_l+0xf0>
jmp    11e0 <array_print_l+0xc0>
mov    $0xa,%edi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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