#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void mcdetector_out_array_ascii(long m, long n, double *p, FILE *f,
                                char istransposed) {
  if (f) {
    int i, j;
    for (j = 0; j < n; j++) {
      for (i = 0; i < m; i++) {
        fprintf(f, "%.10g ", p[!istransposed ? i * n + j : j * m + i]);
      }
      fprintf(f, "\n");
    }
  }
}


x86 assembly (clang, -O0):
<mcdetector_out_array_ascii>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %r8b,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %al,-0x21(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11fc <mcdetector_out_array_ascii+0xec>
movl   $0x0,-0x2c(%rbp)
movslq -0x2c(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    11f7 <mcdetector_out_array_ascii+0xe7>
movl   $0x0,-0x28(%rbp)
movslq -0x28(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    11d7 <mcdetector_out_array_ascii+0xc7>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpb   $0x0,-0x21(%rbp)
jne    1196 <mcdetector_out_array_ascii+0x86>
movslq -0x28(%rbp),%rax
imul   -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
jmp    11aa <mcdetector_out_array_ascii+0x9a>
movslq -0x2c(%rbp),%rax
imul   -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    -0x48(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe3e(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1155 <mcdetector_out_array_ascii+0x45>
mov    -0x20(%rbp),%rdi
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1140 <mcdetector_out_array_ascii+0x30>
jmp    11fc <mcdetector_out_array_ascii+0xec>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mcdetector_out_array_ascii>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r8d,0x14(%rsp)
mov    %rdx,0x28(%rsp)
test   %rcx,%rcx
je     120d <mcdetector_out_array_ascii+0xed>
test   %rsi,%rsi
jle    120d <mcdetector_out_array_ascii+0xed>
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    %rdi,0x20(%rsp)
mov    %rsi,0x30(%rsp)
jmp    11a6 <mcdetector_out_array_ascii+0x86>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
mov    %rcx,%rsi
mov    %rcx,%rbx
call   1030 <fputc@plt>
mov    0x8(%rsp),%rcx
add    $0x1,%rcx
mov    0x20(%rsp),%rdi
add    %rdi,0x18(%rsp)
mov    %rcx,%rax
mov    %rcx,0x8(%rsp)
cmp    %rbp,%rcx
mov    %rbx,%rcx
mov    %rbp,%rsi
je     120d <mcdetector_out_array_ascii+0xed>
test   %rdi,%rdi
mov    0x14(%rsp),%ebx
mov    0x28(%rsp),%rdi
mov    %rsi,%rbp
lea    0xe44(%rip),%r15
jle    1170 <mcdetector_out_array_ascii+0x50>
mov    0x20(%rsp),%r12
mov    0x18(%rsp),%r13
mov    0x8(%rsp),%r14
nopl   (%rax)
test   %bl,%bl
mov    %r13,%rax
cmove  %r14,%rax
movsd  (%rdi,%rax,8),%xmm0
mov    %rcx,%rdi
mov    %r15,%rsi
mov    $0x1,%al
mov    %rcx,%rbp
call   1040 <fprintf@plt>
mov    0x28(%rsp),%rdi
mov    %rbp,%rcx
mov    0x30(%rsp),%rbp
add    %rbp,%r14
add    $0x1,%r13
add    $0xffffffffffffffff,%r12
jne    11d0 <mcdetector_out_array_ascii+0xb0>
jmp    1170 <mcdetector_out_array_ascii+0x50>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%.10g \00"
define void @mcdetector_out_array_ascii(i64 %0, i64 %1, double* nocapture %2, i32* %3, i8 signext %4) {
%6 = icmp ne i32* %3, null
%7 = icmp sgt i64 %1, 0
%8 = and i1 %6, %7
br i1 %8, label %9, label %31
9: ; preds = %5
%10 = icmp sgt i64 %0, 0
%11 = icmp eq i8 %4, 0
br label %12
12: ; preds = %9, %27
%13 = phi i64 [ 0, %9 ], [ %29, %27 ]
br i1 %10, label %14, label %27
14: ; preds = %12
%15 = mul nsw i64 %13, %0
br label %16
16: ; preds = %14, %16
%17 = phi i64 [ 0, %14 ], [ %25, %16 ]
%18 = mul nsw i64 %17, %1
%19 = add nsw i64 %18, %13
%20 = add nsw i64 %17, %15
%21 = select i1 %11, i64 %19, i64 %20
%22 = getelementptr inbounds double, double* %2, i64 %21
%23 = load double, double* %22
%24 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %23)
%25 = add nuw nsw i64 %17, 1
%26 = icmp eq i64 %25, %0
br i1 %26, label %27, label %16
27: ; preds = %16, %12
%28 = tail call i32 @fputc(i32 10, i32* %3)
%29 = add nuw nsw i64 %13, 1
%30 = icmp eq i64 %29, %1
br i1 %30, label %31, label %12
31: ; preds = %27, %5
ret void
}