#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_ld(const unsigned int m, const unsigned int n,
                    const long double *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("% .3Le ", A[i * n + j]);
      printf("\n");
    }
    printf("\n");
    break;
  case 'C':
    for (i = 0; i < m; i++) {
      for (j = 0; j < n; j++)
        printf("% .3Le ", A[i + j * m]);
      printf("\n");
    }
    printf("\n");
    break;
  }
}


x86 assembly (clang, -O0):
<array_print_ld>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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     11dc <array_print_ld+0xcc>
jmp    113c <array_print_ld+0x2c>
mov    -0x20(%rbp),%eax
sub    $0x52,%eax
jne    1266 <array_print_ld+0x156>
jmp    114d <array_print_ld+0x3d>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11c9 <array_print_ld+0xb9>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    11ad <array_print_ld+0x9d>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    -0x8(%rbp),%edx
imul   %edx,%ecx
mov    -0x1c(%rbp),%edx
add    %edx,%ecx
shl    $0x4,%rcx
fldt   (%rax,%rcx,1)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xe68(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <array_print_ld+0x57>
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <array_print_ld+0x44>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1266 <array_print_ld+0x156>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1258 <array_print_ld+0x148>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    123c <array_print_ld+0x12c>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%edx
mov    -0x4(%rbp),%esi
imul   %esi,%edx
add    %edx,%ecx
shl    $0x4,%rcx
fldt   (%rax,%rcx,1)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xdd9(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f6 <array_print_ld+0xe6>
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e3 <array_print_ld+0xd3>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_print_ld>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %edi,%r12d
cmp    $0x52,%ecx
mov    %esi,0x14(%rsp)
je     11c2 <array_print_ld+0xa2>
cmp    $0x43,%ecx
jne    125b <array_print_ld+0x13b>
test   %r12d,%r12d
je     1243 <array_print_ld+0x123>
mov    %esi,%eax
mov    %rax,0x18(%rsp)
lea    0xe9f(%rip),%r15
xor    %r14d,%r14d
jmp    118b <array_print_ld+0x6b>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
cmp    %r12d,%r14d
mov    0x14(%rsp),%esi
je     1243 <array_print_ld+0x123>
test   %esi,%esi
je     1170 <array_print_ld+0x50>
mov    0x18(%rsp),%rbp
mov    %r14d,%r13d
nopw   0x0(%rax,%rax,1)
mov    %r13d,%eax
shl    $0x4,%rax
fldt   (%rbx,%rax,1)
fstpt  (%rsp)
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    %r12d,%r13d
add    $0xffffffffffffffff,%rbp
jne    11a0 <array_print_ld+0x80>
jmp    1170 <array_print_ld+0x50>
test   %r12d,%r12d
je     1243 <array_print_ld+0x123>
mov    %esi,%eax
mov    %rax,0x20(%rsp)
lea    0xe2b(%rip),%r15
movl   $0x0,0x18(%rsp)
xor    %ebp,%ebp
jmp    120a <array_print_ld+0xea>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0x14(%rsp),%esi
add    %esi,0x18(%rsp)
cmp    %r12d,%ebp
je     1243 <array_print_ld+0x123>
test   %esi,%esi
je     11f0 <array_print_ld+0xd0>
mov    0x20(%rsp),%r14
mov    0x18(%rsp),%r13d
nopl   0x0(%rax,%rax,1)
mov    %r13d,%eax
shl    $0x4,%rax
fldt   (%rbx,%rax,1)
fstpt  (%rsp)
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r13d
add    $0xffffffffffffffff,%r14
jne    1220 <array_print_ld+0x100>
jmp    11f0 <array_print_ld+0xd0>
mov    $0xa,%edi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"% .3Le \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @array_print_ld(i32 %0, i32 %1, x86_fp80* %2, i8 signext %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca x86_fp80*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store x86_fp80* %2, x86_fp80** %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 x86_fp80*, x86_fp80** %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 x86_fp80, x86_fp80* %24, i64 %30
%32 = load x86_fp80, x86_fp80* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), x86_fp80 %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 x86_fp80*, x86_fp80** %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 x86_fp80, x86_fp80* %55, i64 %61
%63 = load x86_fp80, x86_fp80* %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), x86_fp80 %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"% .3Le \00"
define void @array_print_ld(i32 %0, i32 %1, x86_fp80* 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 x86_fp80, x86_fp80* %2, i64 %24
%26 = load x86_fp80, x86_fp80* %25
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), x86_fp80 %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 x86_fp80, x86_fp80* %2, i64 %41
%43 = load x86_fp80, x86_fp80* %42
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), x86_fp80 %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
}