#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 *, double);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
void save(double (*cls)[6], int *ass, int n, int k, char *output) {
  char name[100] = {'\0'};
  int i;
  snprintf(name, 100, "%s/assign", output);
  FILE *fp = fopen(name, "w");
  for (i = 0; i < n; i++) {
    fprintf(fp, "%d\n", ass[i]);
  }
  fclose(fp);
  snprintf(name, 100, "%s/centers", output);
  fp = fopen(name, "w");
  for (i = 0; i < k; i++) {
    fprintf(fp, "%.8f\t", cls[i][0]);
    fprintf(fp, "%.8f\t", cls[i][1]);
    fprintf(fp, "%.8f\t", cls[i][2]);
    fprintf(fp, "%.8f\t", cls[i][3]);
    fprintf(fp, "%.8f\t", cls[i][4]);
    fprintf(fp, "%.8f\n", cls[i][5]);
  }
  fclose(fp);
}


x86 assembly (clang, -O0):
<save>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x64,%esi
lea    0xe69(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x90(%rbp),%rdi
lea    0xe60(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xa0(%rbp)
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1206 <save+0xb6>
mov    -0xa0(%rbp),%rdi
mov    -0x10(%rbp),%rax
movslq -0x94(%rbp),%rcx
cvtsi2sdl (%rax,%rcx,4),%xmm0
lea    0xe1f(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11c0 <save+0x70>
mov    -0xa0(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x64,%esi
lea    0xde7(%rip),%rdx
call   1040 <snprintf@plt>
lea    -0x90(%rbp),%rdi
lea    0xdce(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0xa0(%rbp)
movl   $0x0,-0x94(%rbp)
mov    -0x94(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1370 <save+0x220>
mov    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x94(%rbp),%rcx
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
lea    0xd96(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x94(%rbp),%rcx
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm0
lea    0xd6c(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x94(%rbp),%rcx
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm0
lea    0xd42(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x94(%rbp),%rcx
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movsd  0x18(%rax),%xmm0
lea    0xd18(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x94(%rbp),%rcx
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movsd  0x20(%rax),%xmm0
lea    0xcee(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x8(%rbp),%rax
movslq -0x94(%rbp),%rcx
imul   $0x30,%rcx,%rcx
add    %rcx,%rax
movsd  0x28(%rax),%xmm0
lea    0xcca(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1252 <save+0x102>
mov    -0xa0(%rbp),%rdi
call   1030 <fclose@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %ecx,0x4(%rsp)
mov    %edx,%r12d
mov    %rsi,%r13
mov    %rdi,%r15
xorpd  %xmm0,%xmm0
movapd %xmm0,0x60(%rsp)
movapd %xmm0,0x50(%rsp)
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x30(%rsp)
movapd %xmm0,0x20(%rsp)
movapd %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0xe6e(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x64,%esi
mov    %r8,0x8(%rsp)
mov    %r8,%rcx
call   1040 <snprintf@plt>
lea    0xe57(%rip),%rsi
mov    %rbp,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbp
test   %r12d,%r12d
jle    11ee <save+0xae>
mov    %r12d,%r14d
xor    %ebx,%ebx
lea    0xe3d(%rip),%r12
nop
xorps  %xmm0,%xmm0
cvtsi2sdl 0x0(%r13,%rbx,4),%xmm0
mov    %rbp,%rdi
mov    %r12,%rsi
call   1050 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11d0 <save+0x90>
mov    %rbp,%rdi
call   1030 <fclose@plt>
lea    0xe13(%rip),%rdx
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x64,%esi
mov    0x8(%rsp),%rcx
call   1040 <snprintf@plt>
lea    0xdef(%rip),%rsi
mov    %rbp,%rdi
call   1060 <fopen@plt>
mov    %rax,%rbp
mov    0x4(%rsp),%eax
test   %eax,%eax
jle    12c4 <save+0x184>
mov    %eax,%eax
shl    $0x4,%rax
lea    (%rax,%rax,2),%r12
xor    %ebx,%ebx
lea    0xdd6(%rip),%r14
lea    0xdd5(%rip),%r13
nopl   0x0(%rax)
movsd  (%r15,%rbx,1),%xmm0
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
movsd  0x8(%r15,%rbx,1),%xmm0
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
movsd  0x10(%r15,%rbx,1),%xmm0
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
movsd  0x18(%r15,%rbx,1),%xmm0
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
movsd  0x20(%r15,%rbx,1),%xmm0
mov    %rbp,%rdi
mov    %r14,%rsi
call   1050 <fprintf@plt>
movsd  0x28(%r15,%rbx,1),%xmm0
mov    %rbp,%rdi
mov    %r13,%rsi
call   1050 <fprintf@plt>
add    $0x30,%rbx
cmp    %rbx,%r12
jne    1250 <save+0x110>
mov    %rbp,%rdi
call   1030 <fclose@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"%s/assign\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [11 x i8] c"%s/centers\00"
@.str.4 = [6 x i8] c"%.8f\09\00"
@.str.5 = [6 x i8] c"%.8f\0A\00"
define void @save([6 x double]* nocapture %0, i32* nocapture %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca [100 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%8 = call i32 @snprintf(i8* %7, i32 100, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %4)
%9 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp sgt i32 %2, 0
br i1 %10, label %11, label %21
11: ; preds = %5
%12 = zext i32 %2 to i64
br label %13
13: ; preds = %11, %13
%14 = phi i64 [ 0, %11 ], [ %19, %13 ]
%15 = getelementptr inbounds i32, i32* %1, i64 %14
%16 = load i32, i32* %15
%17 = sitofp i32 %16 to double
%18 = call i32 @fprintf(i32* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %17)
%19 = add nuw nsw i64 %14, 1
%20 = icmp eq i64 %19, %12
br i1 %20, label %21, label %13
21: ; preds = %13, %5
%22 = call i32 @fclose(i32* %9)
%23 = call i32 @snprintf(i8* %7, i32 100, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%24 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp sgt i32 %3, 0
br i1 %25, label %26, label %50
26: ; preds = %21
%27 = zext i32 %3 to i64
br label %28
28: ; preds = %26, %28
%29 = phi i64 [ 0, %26 ], [ %48, %28 ]
%30 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 %29, i64 0
%31 = load double, double* %30
%32 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %31)
%33 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 %29, i64 1
%34 = load double, double* %33
%35 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %34)
%36 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 %29, i64 2
%37 = load double, double* %36
%38 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %37)
%39 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 %29, i64 3
%40 = load double, double* %39
%41 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %40)
%42 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 %29, i64 4
%43 = load double, double* %42
%44 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double %43)
%45 = getelementptr inbounds [6 x double], [6 x double]* %0, i64 %29, i64 5
%46 = load double, double* %45
%47 = call i32 @fprintf(i32* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double %46)
%48 = add nuw nsw i64 %29, 1
%49 = icmp eq i64 %48, %27
br i1 %49, label %50, label %28
50: ; preds = %28, %21
%51 = call i32 @fclose(i32* %24)
ret void
}