#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 *, int);
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);
  printf("%s correspond to data generated at time step %d.\n", fname, ts);
}


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)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1223 <prtdata+0xe3>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1210 <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    0xe46(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     11eb <prtdata+0xab>
mov    -0x30(%rbp),%rdi
lea    0xe29(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    11fd <prtdata+0xbd>
mov    -0x30(%rbp),%rdi
lea    0xe44(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1202 <prtdata+0xc2>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1187 <prtdata+0x47>
jmp    1215 <prtdata+0xd5>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1174 <prtdata+0x34>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x20(%rbp),%rsi
mov    -0xc(%rbp),%edx
lea    0xdd0(%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    $0x38,%rsp
mov    %rcx,%rbp
mov    %edx,0xc(%rsp)
mov    %esi,%r13d
mov    %rdi,0x10(%rsp)
lea    0xe8c(%rip),%rsi
mov    %r8,0x18(%rsp)
mov    %r8,%rdi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %r13d,%r13d
jle    1227 <prtdata+0xd7>
mov    0x10(%rsp),%rax
lea    -0x1(%rax),%r14d
mov    %r13d,%ecx
mov    %eax,%r12d
mov    %rcx,0x28(%rsp)
lea    0x0(,%rcx,8),%rax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
lea    0xe4b(%rip),%r15
jmp    11d5 <prtdata+0x85>
nopl   0x0(%rax)
mov    0x30(%rsp),%rax
add    $0x1,%rax
add    0x20(%rsp),%rbp
cmp    0x28(%rsp),%rax
je     1227 <prtdata+0xd7>
mov    %rax,0x30(%rsp)
cmpl   $0x0,0x10(%rsp)
jle    11c0 <prtdata+0x70>
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0x0(%rbp,%r13,8),%xmm0
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
cmp    %r13,%r14
mov    $0x20,%edi
mov    $0xa,%eax
cmove  %eax,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0x1,%r13
cmp    %r13,%r12
jne    11f0 <prtdata+0xa0>
jmp    11c0 <prtdata+0x70>
mov    %rbx,%rdi
call   1030 <fclose@plt>
lea    0xdd4(%rip),%rdi
mov    0x18(%rsp),%rsi
mov    0xc(%rsp),%edx
add    $0x38,%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 = [8 x i8] c"%8.3f, \00"
@.str.2 = [2 x i8] c" \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [50 x i8] c"%s correspond to data generated at time step %d.\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)
%59 = load i8*, i8** %10
%60 = load i32, i32* %8
%61 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* %59, i32 %60)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [8 x i8] c"%8.3f, \00"
@.str.4 = [50 x i8] c"%s correspond to data generated at time step %d.\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 %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)
%35 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0), i8* %4, i32 %2)
ret void
}