#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*/ *);
scalar_t__ ferror(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void writeascii_(char *fname, int *notok, float *data, int *rtrn, int *flag) {
  int nChannels, nFrames, i, j;
  FILE *fp;
  float *dptr;
  nChannels = notok[0];
  nFrames = notok[1];
  i = 0;
  do {
    if (fname[i] == ' ') {
      fname[i] = '\0';
      break;
    }
    i++;
  } while (fname[i]);
  if (flag) {
    if ((fp = fopen(fname, "w")) == NULL) {
      *rtrn = 0;
      return;
    }
  } else {
    if ((fp = fopen(fname, "a")) == NULL) {
      *rtrn = 0;
      return;
    }
  }
  for (i = 0; i < nChannels; i++) {
    dptr = data + i;
    for (j = 0; j < nFrames; j++) {
      fprintf(fp, "  %7.5E,", *dptr);
      dptr += nChannels;
    }
    fprintf(fp, "\n");
  }
  if (ferror(fp) != 0) {
    *rtrn = 0;
    return;
  }
  fclose(fp);
  *rtrn = 1;
  return;
}


x86 assembly (clang, -O0):
<writeascii_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    119c <writeascii_+0x5c>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    11b7 <writeascii_+0x77>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
jne    1176 <writeascii_+0x36>
cmpq   $0x0,-0x28(%rbp)
je     11f4 <writeascii_+0xb4>
mov    -0x8(%rbp),%rdi
lea    0xe33(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    11ef <writeascii_+0xaf>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    12f5 <writeascii_+0x1b5>
jmp    1226 <writeascii_+0xe6>
mov    -0x8(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    1221 <writeascii_+0xe1>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    12f5 <writeascii_+0x1b5>
jmp    1226 <writeascii_+0xe6>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12c0 <writeascii_+0x180>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    12a0 <writeascii_+0x160>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd8e(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x48(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x48(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1253 <writeascii_+0x113>
mov    -0x40(%rbp),%rdi
lea    0xd62(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    122d <writeascii_+0xed>
mov    -0x40(%rbp),%rdi
call   1030 <ferror@plt>
cmp    $0x0,%rax
je     12e2 <writeascii_+0x1a2>
mov    -0x20(%rbp),%rax
movl   $0x0,(%rax)
jmp    12f5 <writeascii_+0x1b5>
mov    -0x40(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x20(%rbp),%rax
movl   $0x1,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeascii_>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,%rbp
mov    %rdx,0x18(%rsp)
mov    (%rsi),%eax
mov    %rax,0x10(%rsp)
mov    0x4(%rsi),%eax
mov    %eax,0xc(%rsp)
mov    (%rdi),%cl
xor    %eax,%eax
nopl   0x0(%rax,%rax,1)
cmp    $0x20,%cl
je     11a0 <writeascii_+0x50>
movzbl 0x1(%rdi,%rax,1),%ecx
add    $0x1,%rax
test   %cl,%cl
jne    1180 <writeascii_+0x30>
test   %r8,%r8
je     11ab <writeascii_+0x5b>
lea    0xe62(%rip),%rsi
jmp    11b2 <writeascii_+0x62>
mov    %eax,%eax
movb   $0x0,(%rdi,%rax,1)
test   %r8,%r8
jne    1197 <writeascii_+0x47>
lea    0xe50(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1263 <writeascii_+0x113>
mov    %rbp,0x20(%rsp)
cmpl   $0x0,0x10(%rsp)
jle    1240 <writeascii_+0xf0>
mov    0x10(%rsp),%rax
lea    0x0(,%rax,4),%r14
xor    %r13d,%r13d
lea    0xe1e(%rip),%r12
jmp    120e <writeascii_+0xbe>
nopl   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
add    $0x1,%r13
addq   $0x4,0x18(%rsp)
cmp    0x10(%rsp),%r13
je     1240 <writeascii_+0xf0>
cmpl   $0x0,0xc(%rsp)
jle    11f0 <writeascii_+0xa0>
mov    0xc(%rsp),%ebp
mov    0x18(%rsp),%r15
xchg   %ax,%ax
movss  (%r15),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    %r14,%r15
add    $0xffffffff,%ebp
jne    1220 <writeascii_+0xd0>
jmp    11f0 <writeascii_+0xa0>
mov    %rbx,%rdi
call   1030 <ferror@plt>
xor    %ecx,%ecx
test   %rax,%rax
mov    0x20(%rsp),%rbp
jne    1265 <writeascii_+0x115>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0x1,%ecx
jmp    1265 <writeascii_+0x115>
xor    %ecx,%ecx
mov    %ecx,0x0(%rbp)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"w\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [9 x i8] c" %7.5E,\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @writeascii_(i8* %0, i32* %1, float* %2, i32* %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca float*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32*
%16 = alloca float*
store i8* %0, i8** %6
store i32* %1, i32** %7
store float* %2, float** %8
store i32* %3, i32** %9
store i32* %4, i32** %10
%17 = load i32*, i32** %7
%18 = getelementptr inbounds i32, i32* %17, i64 0
%19 = load i32, i32* %18
store i32 %19, i32* %11
%20 = load i32*, i32** %7
%21 = getelementptr inbounds i32, i32* %20, i64 1
%22 = load i32, i32* %21
store i32 %22, i32* %12
store i32 0, i32* %13
br label %23
23: ; preds = %39, %5
%24 = load i8*, i8** %6
%25 = load i32, i32* %13
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 32
br i1 %30, label %31, label %36
31: ; preds = %23
%32 = load i8*, i8** %6
%33 = load i32, i32* %13
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
store i8 0, i8* %35
br label %46
36: ; preds = %23
%37 = load i32, i32* %13
%38 = add nsw i32 %37, 1
store i32 %38, i32* %13
br label %39
39: ; preds = %36
%40 = load i8*, i8** %6
%41 = load i32, i32* %13
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = icmp ne i8 %44, 0
br i1 %45, label %23, label %46
46: ; preds = %39, %31
%47 = load i32*, i32** %10
%48 = icmp ne i32* %47, null
br i1 %48, label %49, label %56
49: ; preds = %46
%50 = load i8*, i8** %6
%51 = call i32* @fopen(i8* %50, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %51, i32** %15
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %55
53: ; preds = %49
%54 = load i32*, i32** %9
store i32 0, i32* %54
br label %106
55: ; preds = %49
br label %63
56: ; preds = %46
%57 = load i8*, i8** %6
%58 = call i32* @fopen(i8* %57, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %58, i32** %15
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = load i32*, i32** %9
store i32 0, i32* %61
br label %106
62: ; preds = %56
br label %63
63: ; preds = %62, %55
store i32 0, i32* %13
br label %64
64: ; preds = %93, %63
%65 = load i32, i32* %13
%66 = load i32, i32* %11
%67 = icmp slt i32 %65, %66
br i1 %67, label %68, label %96
68: ; preds = %64
%69 = load float*, float** %8
%70 = load i32, i32* %13
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds float, float* %69, i64 %71
store float* %72, float** %16
store i32 0, i32* %14
br label %73
73: ; preds = %87, %68
%74 = load i32, i32* %14
%75 = load i32, i32* %12
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %90
77: ; preds = %73
%78 = load i32*, i32** %15
%79 = load float*, float** %16
%80 = load float, float* %79
%81 = fpext float %80 to double
%82 = call i32 (i32*, i8*, ...) @fprintf(i32* %78, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %81)
%83 = load i32, i32* %11
%84 = load float*, float** %16
%85 = sext i32 %83 to i64
%86 = getelementptr inbounds float, float* %84, i64 %85
store float* %86, float** %16
br label %87
87: ; preds = %77
%88 = load i32, i32* %14
%89 = add nsw i32 %88, 1
store i32 %89, i32* %14
br label %73
90: ; preds = %73
%91 = load i32*, i32** %15
%92 = call i32 (i32*, i8*, ...) @fprintf(i32* %91, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %93
93: ; preds = %90
%94 = load i32, i32* %13
%95 = add nsw i32 %94, 1
store i32 %95, i32* %13
br label %64
96: ; preds = %64
%97 = load i32*, i32** %15
%98 = call i64 @ferror(i32* %97)
%99 = icmp ne i64 %98, 0
br i1 %99, label %100, label %102
100: ; preds = %96
%101 = load i32*, i32** %9
store i32 0, i32* %101
br label %106
102: ; preds = %96
%103 = load i32*, i32** %15
%104 = call i32 @fclose(i32* %103)
%105 = load i32*, i32** %9
store i32 1, i32* %105
br label %106
106: ; preds = %102, %100, %60, %53
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"w\00"
@.str.1 = [2 x i8] c"a\00"
@.str.2 = [9 x i8] c" %7.5E,\00"
define void @writeascii_(i8* nocapture %0, i32* nocapture %1, float* nocapture %2, i32* nocapture writeonly %3, i32* readnone %4) {
%6 = load i32, i32* %1
%7 = getelementptr inbounds i32, i32* %1, i64 1
%8 = load i32, i32* %7
%9 = load i8, i8* %0
br label %10
10: ; preds = %17, %5
%11 = phi i8 [ %20, %17 ], [ %9, %5 ]
%12 = phi i64 [ %18, %17 ], [ 0, %5 ]
%13 = icmp eq i8 %11, 32
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = and i64 %12, 4294967295
%16 = getelementptr inbounds i8, i8* %0, i64 %15
store i8 0, i8* %16
br label %22
17: ; preds = %10
%18 = add nuw i64 %12, 1
%19 = getelementptr inbounds i8, i8* %0, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %22, label %10
22: ; preds = %17, %14
%23 = icmp eq i32* %4, null
br i1 %23, label %27, label %24
24: ; preds = %22
%25 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %59, label %30
27: ; preds = %22
%28 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%29 = icmp eq i32* %28, null
br i1 %29, label %59, label %30
30: ; preds = %27, %24
%31 = phi i32* [ %25, %24 ], [ %28, %27 ]
%32 = icmp sgt i32 %6, 0
br i1 %32, label %33, label %54
33: ; preds = %30
%34 = icmp sgt i32 %8, 0
%35 = zext i32 %6 to i64
%36 = zext i32 %6 to i64
br label %37
37: ; preds = %33, %50
%38 = phi i64 [ 0, %33 ], [ %52, %50 ]
br i1 %34, label %39, label %50
39: ; preds = %37
%40 = getelementptr inbounds float, float* %2, i64 %38
br label %41
41: ; preds = %39, %41
%42 = phi float* [ %47, %41 ], [ %40, %39 ]
%43 = phi i32 [ %48, %41 ], [ 0, %39 ]
%44 = load float, float* %42
%45 = fpext float %44 to double
%46 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %45)
%47 = getelementptr inbounds float, float* %42, i64 %35
%48 = add nuw nsw i32 %43, 1
%49 = icmp eq i32 %48, %8
br i1 %49, label %50, label %41
50: ; preds = %41, %37
%51 = tail call i32 @fputc(i32 10, i32* %31)
%52 = add nuw nsw i64 %38, 1
%53 = icmp eq i64 %52, %36
br i1 %53, label %54, label %37
54: ; preds = %50, %30
%55 = tail call i64 @ferror(i32* %31)
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = tail call i32 @fclose(i32* %31)
br label %59
59: ; preds = %54, %27, %24, %57
%60 = phi i32 [ 1, %57 ], [ 0, %24 ], [ 0, %27 ], [ 0, %54 ]
store i32 %60, i32* %3
ret void
}