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


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    0xeac(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1213 <prtdata+0xe3>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1200 <prtdata+0xd0>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%ecx
imul   -0x8(%rbp),%ecx
movslq %ecx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
lea    0xe56(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11db <prtdata+0xab>
mov    -0x30(%rbp),%rdi
lea    0xe39(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11ed <prtdata+0xbd>
mov    -0x30(%rbp),%rdi
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
jmp    11f2 <prtdata+0xc2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1177 <prtdata+0x47>
jmp    1205 <prtdata+0xd5>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1164 <prtdata+0x34>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@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,%r15
mov    %esi,%r12d
mov    %rdi,0x8(%rsp)
lea    0xea0(%rip),%rsi
mov    %r8,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %r12d,%r12d
jle    1206 <prtdata+0xc6>
mov    0x8(%rsp),%rax
lea    -0x1(%rax),%ebp
mov    %r12d,%ecx
mov    %eax,%r14d
mov    %rcx,0x18(%rsp)
lea    0x0(,%rcx,8),%rax
mov    %rax,0x10(%rsp)
xor    %eax,%eax
lea    0xe65(%rip),%r13
jmp    11b5 <prtdata+0x75>
nop
mov    0x20(%rsp),%rax
add    $0x1,%rax
add    0x10(%rsp),%r15
cmp    0x18(%rsp),%rax
je     1206 <prtdata+0xc6>
mov    %rax,0x20(%rsp)
cmpl   $0x0,0x8(%rsp)
jle    11a0 <prtdata+0x60>
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  (%r15,%r12,8),%xmm0
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
cmp    %r12,%rbp
mov    $0x20,%edi
mov    $0xa,%eax
cmove  %eax,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x1,%r12
cmp    %r12,%r14
jne    11d0 <prtdata+0x90>
jmp    11a0 <prtdata+0x60>
mov    %rbx,%rdi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

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

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