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


x86 assembly (clang, -O0):
<array_print_f>:
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     11d7 <array_print_f+0xc7>
jmp    113c <array_print_f+0x2c>
mov    -0x20(%rbp),%eax
sub    $0x52,%eax
jne    125e <array_print_f+0x14e>
jmp    114d <array_print_f+0x3d>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    11c4 <array_print_f+0xb4>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    11a8 <array_print_f+0x98>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
imul   -0x8(%rbp),%ecx
add    -0x1c(%rbp),%ecx
mov    %ecx,%ecx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1167 <array_print_f+0x57>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1154 <array_print_f+0x44>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125e <array_print_f+0x14e>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jae    1250 <array_print_f+0x140>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1234 <array_print_f+0x124>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    -0x1c(%rbp),%edx
imul   -0x4(%rbp),%edx
add    %edx,%ecx
mov    %ecx,%ecx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f1 <array_print_f+0xe1>
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11de <array_print_f+0xce>
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_print_f>:
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     11c1 <array_print_f+0xa1>
cmp    $0x43,%ecx
jne    124a <array_print_f+0x12a>
test   %r12d,%r12d
je     1232 <array_print_f+0x112>
mov    %esi,%eax
mov    %rax,0x8(%rsp)
xor    %r14d,%r14d
lea    0xe9c(%rip),%r15
jmp    118b <array_print_f+0x6b>
cs nopw 0x0(%rax,%rax,1)
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%r14d
cmp    %r12d,%r14d
mov    0x4(%rsp),%esi
je     1232 <array_print_f+0x112>
test   %esi,%esi
je     1170 <array_print_f+0x50>
mov    0x8(%rsp),%rbp
mov    %r14d,%r13d
nopw   0x0(%rax,%rax,1)
mov    %r13d,%eax
movss  (%rbx,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    %r12d,%r13d
add    $0xffffffffffffffff,%rbp
jne    11a0 <array_print_f+0x80>
jmp    1170 <array_print_f+0x50>
test   %r12d,%r12d
je     1232 <array_print_f+0x112>
mov    %esi,%eax
mov    %rax,0x10(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xe24(%rip),%r15
xor    %ebp,%ebp
jmp    11fa <array_print_f+0xda>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%esi
add    %esi,0x8(%rsp)
cmp    %r12d,%ebp
je     1232 <array_print_f+0x112>
test   %esi,%esi
je     11e0 <array_print_f+0xc0>
mov    0x10(%rsp),%r14
mov    0x8(%rsp),%r13d
nopl   0x0(%rax,%rax,1)
mov    %r13d,%eax
movss  (%rbx,%rax,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x1,%r13d
add    $0xffffffffffffffff,%r14
jne    1210 <array_print_f+0xf0>
jmp    11e0 <array_print_f+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 = [7 x i8] c"% .3f \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @array_print_f(i32 %0, i32 %1, float* %2, i8 signext %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca float*
%8 = alloca i8
%9 = alloca i32
%10 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store float* %2, float** %7
store i8 %3, i8* %8
%11 = load i8, i8* %8
%12 = sext i8 %11 to i32
switch i32 %12, label %77 [
i32 82, label %13
i32 67, label %45
]
13: ; preds = %4
store i32 0, i32* %9
br label %14
14: ; preds = %40, %13
%15 = load i32, i32* %9
%16 = load i32, i32* %5
%17 = icmp ult i32 %15, %16
br i1 %17, label %18, label %43
18: ; preds = %14
store i32 0, i32* %10
br label %19
19: ; preds = %35, %18
%20 = load i32, i32* %10
%21 = load i32, i32* %6
%22 = icmp ult i32 %20, %21
br i1 %22, label %23, label %38
23: ; preds = %19
%24 = load float*, float** %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 float, float* %24, i64 %30
%32 = load float, float* %31
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %33)
br label %35
35: ; preds = %23
%36 = load i32, i32* %10
%37 = add i32 %36, 1
store i32 %37, i32* %10
br label %19
38: ; preds = %19
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38
%41 = load i32, i32* %9
%42 = add i32 %41, 1
store i32 %42, i32* %9
br label %14
43: ; preds = %14
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %77
45: ; preds = %4
store i32 0, i32* %9
br label %46
46: ; preds = %72, %45
%47 = load i32, i32* %9
%48 = load i32, i32* %5
%49 = icmp ult i32 %47, %48
br i1 %49, label %50, label %75
50: ; preds = %46
store i32 0, i32* %10
br label %51
51: ; preds = %67, %50
%52 = load i32, i32* %10
%53 = load i32, i32* %6
%54 = icmp ult i32 %52, %53
br i1 %54, label %55, label %70
55: ; preds = %51
%56 = load float*, float** %7
%57 = load i32, i32* %9
%58 = load i32, i32* %10
%59 = load i32, i32* %5
%60 = mul i32 %58, %59
%61 = add i32 %57, %60
%62 = zext i32 %61 to i64
%63 = getelementptr inbounds float, float* %56, i64 %62
%64 = load float, float* %63
%65 = fpext float %64 to double
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %65)
br label %67
67: ; preds = %55
%68 = load i32, i32* %10
%69 = add i32 %68, 1
store i32 %69, i32* %10
br label %51
70: ; preds = %51
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %72
72: ; preds = %70
%73 = load i32, i32* %9
%74 = add i32 %73, 1
store i32 %74, i32* %9
br label %46
75: ; preds = %46
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %77
77: ; preds = %4, %75, %43
ret void
}

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