#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
void prtdata(int nx, int ny, int ts, double *u1, char *fname) {
  int ix, iy;
  FILE *fp;
  fp = fopen(fname, "w");
  for (iy = ny - 1; iy >= 0; iy--) {
    for (ix = 0; ix <= nx - 1; ix++) {
      fprintf(fp, "%8.3f,", *(u1 + ix * ny + iy));
      if (ix != nx - 1) {
        fprintf(fp, " ");
      } else {
        fprintf(fp, "\n");
      }
    }
  }
  fclose(fp);
  printf(" %s\n", fname);
}


x86 assembly (clang, -O0):
<prtdata>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe9c(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jl     1228 <prtdata+0xe8>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jg     1215 <prtdata+0xd5>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
imul   -0x8(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe41(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11f0 <prtdata+0xb0>
mov    -0x30(%rbp),%rdi
lea    0xe25(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1202 <prtdata+0xc2>
mov    -0x30(%rbp),%rdi
lea    0xe13(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1207 <prtdata+0xc7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1187 <prtdata+0x47>
jmp    121a <prtdata+0xda>
mov    -0x28(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x28(%rbp)
jmp    1176 <prtdata+0x36>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rsi
lea    0xdcf(%rip),%rdi
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prtdata>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%r12
mov    %esi,%r13d
mov    %rdi,(%rsp)
lea    0xe91(%rip),%rsi
mov    %r8,0x10(%rsp)
mov    %r8,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %r13d,%r13d
jle    122b <prtdata+0xdb>
mov    (%rsp),%rax
lea    -0x1(%rax),%ecx
mov    %rcx,0x20(%rsp)
mov    %r13d,%ecx
mov    %eax,%r13d
lea    -0x8(%r12,%rcx,8),%rax
mov    %rax,0x8(%rsp)
lea    0x0(,%rcx,8),%r14
lea    0xe4f(%rip),%rbp
jmp    11d8 <prtdata+0x88>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x18(%rsp),%rcx
lea    -0x1(%rcx),%rax
addq   $0xfffffffffffffff8,0x8(%rsp)
cmp    $0x2,%rcx
mov    %rax,%rcx
jl     122b <prtdata+0xdb>
mov    %rcx,0x18(%rsp)
cmpl   $0x0,(%rsp)
jle    11c0 <prtdata+0x70>
mov    0x8(%rsp),%r12
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
movsd  (%r12),%xmm0
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
cmp    %r15,0x20(%rsp)
mov    $0x20,%edi
mov    $0xa,%eax
cmove  %eax,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0x1,%r15
add    %r14,%r12
cmp    %r15,%r13
jne    11f0 <prtdata+0xa0>
jmp    11c0 <prtdata+0x70>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xdcf(%rip),%rdi
mov    0x10(%rsp),%rsi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <printf@plt>

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

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