#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 */
double RAND_MAX;
int atoi(char *);
int /*<<< orphan*/ error(char *, char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ puts(char *);
float const rand();
int /*<<< orphan*/ srand(unsigned int);
scalar_t__ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  srand((unsigned)time(NULL));
  int k, n, numiter, iter;
  FILE *fp;
  char *fname = NULL;
  const float m = 1.0 / (RAND_MAX + 1.0);
  if (argc > 4) {
    k = atoi(argv[1]);
    n = atoi(argv[2]);
    numiter = atoi(argv[3]);
    fname = argv[4];
    if ((fp = fopen(fname, "w")) < 0) {
      error("Can't open %s", fname);
    }
    for (iter = 0; iter < numiter; iter++) {
      int i;
      float x;
      fprintf(fp, "%d %d ", k, n);
      for (i = 0; i < 2 * k; i++) {
        x = m * rand() * 100;
        fprintf(fp, "%f ", x);
      }
      for (i = 0; i < 2 * n; i++) {
        x = m * rand() * 100;
        fprintf(fp, "%f ", x);
      }
      fprintf(fp, "\n");
    }
  } else {
    puts("arguments must be included below");
    puts("1: k; the number of centroids");
    puts("2: n; the number of data");
    puts("3: numiter; the number of dataset(which include k, n, and data for "
         "each line)");
    puts("4: fname; output file name (which contains k, n, and data, for "
         "kmeans input)");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movq   $0x0,-0x30(%rbp)
movsd  0xe4a(%rip),%xmm1
mov    0x2e2b(%rip),%rax
addsd  (%rax),%xmm1
movsd  0xe37(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x34(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    1378 <main+0x1f8>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1090 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe1f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jae    124a <main+0xca>
mov    -0x30(%rbp),%rsi
lea    0xdc7(%rip),%rdi
call   1070 <error@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1373 <main+0x1f3>
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xdac(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x14(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    12e4 <main+0x164>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
movaps %xmm0,%xmm1
movss  -0x40(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  0xd56(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x28(%rbp),%rdi
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd52(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    127c <main+0xfc>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    -0x18(%rbp),%ecx
shl    $0x1,%ecx
cmp    %ecx,%eax
jge    1353 <main+0x1d3>
movss  -0x34(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
movaps %xmm0,%xmm1
movss  -0x44(%rbp),%xmm0
mulss  %xmm1,%xmm0
movss  0xce7(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x28(%rbp),%rdi
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xce3(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12eb <main+0x16b>
mov    -0x28(%rbp),%rdi
lea    0xcc7(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1251 <main+0xd1>
jmp    13b4 <main+0x234>
lea    0xca8(%rip),%rdi
call   1030 <puts@plt>
lea    0xcbd(%rip),%rdi
call   1030 <puts@plt>
lea    0xccf(%rip),%rdi
call   1030 <puts@plt>
lea    0xcdc(%rip),%rdi
call   1030 <puts@plt>
lea    0xd1e(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cmp    $0x5,%ebp
jl     1310 <main+0x190>
mov    0x2e37(%rip),%rax
movsd  (%rax),%xmm0
addsd  0xe43(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x8(%rbx),%rdi
call   1090 <atoi@plt>
mov    %rax,0x20(%rsp)
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%r13d
mov    0x18(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%r14d
mov    0x20(%rbx),%rdi
lea    0xe42(%rip),%rsi
call   1080 <fopen@plt>
mov    %r14d,0x1c(%rsp)
test   %r14d,%r14d
jle    134c <main+0x1cc>
mov    %rax,%rbp
movsd  0xdee(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
mov    0x20(%rsp),%rax
add    %eax,%eax
cmp    $0x2,%eax
mov    $0x1,%ecx
cmovl  %ecx,%eax
mov    %eax,0x18(%rsp)
lea    0x0(%r13,%r13,1),%eax
cmp    $0x2,%eax
cmovge %eax,%ecx
mov    %ecx,0x14(%rsp)
lea    0xdc5(%rip),%r14
xor    %r12d,%r12d
jmp    127c <main+0xfc>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0xa,%edi
mov    %rbp,%rsi
call   1040 <fputc@plt>
add    $0x1,%r12d
cmp    0x1c(%rsp),%r12d
je     134c <main+0x1cc>
mov    %rbp,%rdi
lea    0xd86(%rip),%rsi
mov    0x20(%rsp),%rbx
mov    %ebx,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x18(%rsp),%r15d
test   %ebx,%ebx
jle    12cc <main+0x14c>
xor    %eax,%eax
call   10a0 <rand@plt>
mulss  0x8(%rsp),%xmm0
mulss  0xd53(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0xffffffff,%r15d
jne    12a0 <main+0x120>
mov    0x14(%rsp),%ebx
test   %r13d,%r13d
jle    1260 <main+0xe0>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   10a0 <rand@plt>
mulss  0x8(%rsp),%xmm0
mulss  0xd13(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbp,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0xffffffff,%ebx
jne    12e0 <main+0x160>
jmp    1260 <main+0xe0>
lea    0xd00(%rip),%rdi
call   1030 <puts@plt>
lea    0xd15(%rip),%rdi
call   1030 <puts@plt>
lea    0xd27(%rip),%rdi
call   1030 <puts@plt>
lea    0xd34(%rip),%rdi
call   1030 <puts@plt>
lea    0xd76(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
@.str = [2 x i8] c"w\00"
@.str.1 = [14 x i8] c"Can't open %s\00"
@.str.2 = [7 x i8] c"%d %d \00"
@.str.3 = [4 x i8] c"%f \00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [33 x i8] c"arguments must be included below\00"
@.str.6 = [30 x i8] c"1: k; the number of centroids\00"
@.str.7 = [25 x i8] c"2: n; the number of data\00"
@.str.8 = [78 x i8] c"3: numiter; the number of dataset(which include k, n, and data for each line)\00"
@.str.9 = [77 x i8] c"4: fname; output file name (which contains k, n, and data, for kmeans input)\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i8*
%12 = alloca float
%13 = alloca i32
%14 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%15 = call i64 @time(i32* null)
%16 = trunc i64 %15 to i32
%17 = call i32 @srand(i32 %16)
store i8* null, i8** %11
%18 = load double, double* @RAND_MAX
%19 = fadd double %18, 1.000000e+00
%20 = fdiv double 1.000000e+00, %19
%21 = fptrunc double %20 to float
store float %21, float* %12
%22 = load i32, i32* %4
%23 = icmp sgt i32 %22, 4
br i1 %23, label %24, label %98
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %6
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %7
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 3
%35 = load i8*, i8** %34
%36 = call i32 @atoi(i8* %35)
store i32 %36, i32* %8
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 4
%39 = load i8*, i8** %38
store i8* %39, i8** %11
%40 = load i8*, i8** %11
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %41, i32** %10
%42 = icmp ult i32* %41, null
br i1 %42, label %43, label %46
43: ; preds = %24
%44 = load i8*, i8** %11
%45 = call i32 @error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %44)
br label %46
46: ; preds = %43, %24
store i32 0, i32* %9
br label %47
47: ; preds = %94, %46
%48 = load i32, i32* %9
%49 = load i32, i32* %8
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %97
51: ; preds = %47
%52 = load i32*, i32** %10
%53 = load i32, i32* %6
%54 = load i32, i32* %7
%55 = call i32 (i32*, i8*, ...) @fprintf(i32* %52, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %53, i32 %54)
store i32 0, i32* %13
br label %56
56: ; preds = %70, %51
%57 = load i32, i32* %13
%58 = load i32, i32* %6
%59 = mul nsw i32 2, %58
%60 = icmp slt i32 %57, %59
br i1 %60, label %61, label %73
61: ; preds = %56
%62 = load float, float* %12
%63 = call float (...) @rand()
%64 = fmul float %62, %63
%65 = fmul float %64, 1.000000e+02
store float %65, float* %14
%66 = load i32*, i32** %10
%67 = load float, float* %14
%68 = fpext float %67 to double
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %68)
br label %70
70: ; preds = %61
%71 = load i32, i32* %13
%72 = add nsw i32 %71, 1
store i32 %72, i32* %13
br label %56
73: ; preds = %56
store i32 0, i32* %13
br label %74
74: ; preds = %88, %73
%75 = load i32, i32* %13
%76 = load i32, i32* %7
%77 = mul nsw i32 2, %76
%78 = icmp slt i32 %75, %77
br i1 %78, label %79, label %91
79: ; preds = %74
%80 = load float, float* %12
%81 = call float (...) @rand()
%82 = fmul float %80, %81
%83 = fmul float %82, 1.000000e+02
store float %83, float* %14
%84 = load i32*, i32** %10
%85 = load float, float* %14
%86 = fpext float %85 to double
%87 = call i32 (i32*, i8*, ...) @fprintf(i32* %84, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %86)
br label %88
88: ; preds = %79
%89 = load i32, i32* %13
%90 = add nsw i32 %89, 1
store i32 %90, i32* %13
br label %74
91: ; preds = %74
%92 = load i32*, i32** %10
%93 = call i32 (i32*, i8*, ...) @fprintf(i32* %92, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %94
94: ; preds = %91
%95 = load i32, i32* %9
%96 = add nsw i32 %95, 1
store i32 %96, i32* %9
br label %47
97: ; preds = %47
br label %104
98: ; preds = %2
%99 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%100 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%101 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%102 = call i32 @puts(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.8, i64 0, i64 0))
%103 = call i32 @puts(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.9, i64 0, i64 0))
br label %104
104: ; preds = %98, %97
%105 = load i32, i32* %3
ret i32 %105
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
@.str = [2 x i8] c"w\00"
@.str.2 = [7 x i8] c"%d %d \00"
@.str.3 = [4 x i8] c"%f \00"
@.str.5 = [33 x i8] c"arguments must be included below\00"
@.str.6 = [30 x i8] c"1: k; the number of centroids\00"
@.str.7 = [25 x i8] c"2: n; the number of data\00"
@.str.8 = [78 x i8] c"3: numiter; the number of dataset(which include k, n, and data for each line)\00"
@.str.9 = [77 x i8] c"4: fname; output file name (which contains k, n, and data, for kmeans input)\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = tail call i64 @time(i32* null)
%4 = trunc i64 %3 to i32
%5 = tail call i32 @srand(i32 %4)
%6 = load double, double* @RAND_MAX
%7 = fadd double %6, 1.000000e+00
%8 = fdiv double 1.000000e+00, %7
%9 = fptrunc double %8 to float
%10 = icmp sgt i32 %0, 4
br i1 %10, label %11, label %58
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = tail call i32 @atoi(i8* %16)
%18 = getelementptr inbounds i8*, i8** %1, i64 3
%19 = load i8*, i8** %18
%20 = tail call i32 @atoi(i8* %19)
%21 = getelementptr inbounds i8*, i8** %1, i64 4
%22 = load i8*, i8** %21
%23 = tail call i32* @fopen(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%24 = icmp sgt i32 %20, 0
br i1 %24, label %25, label %64
25: ; preds = %11
%26 = shl i32 %14, 1
%27 = icmp sgt i32 %14, 0
%28 = shl i32 %17, 1
%29 = icmp sgt i32 %17, 0
%30 = call i32 @llvm.smax.i32(i32 %26, i32 1)
%31 = call i32 @llvm.smax.i32(i32 %28, i32 1)
br label %32
32: ; preds = %25, %54
%33 = phi i32 [ 0, %25 ], [ %56, %54 ]
%34 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %17)
br i1 %27, label %36, label %35
35: ; preds = %36, %32
br i1 %29, label %45, label %54
36: ; preds = %32, %36
%37 = phi i32 [ %43, %36 ], [ 0, %32 ]
%38 = tail call float (...) @rand()
%39 = fmul float %38, %9
%40 = fmul float %39, 1.000000e+02
%41 = fpext float %40 to double
%42 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %41)
%43 = add nuw nsw i32 %37, 1
%44 = icmp eq i32 %43, %30
br i1 %44, label %35, label %36
45: ; preds = %35, %45
%46 = phi i32 [ %52, %45 ], [ 0, %35 ]
%47 = tail call float (...) @rand()
%48 = fmul float %47, %9
%49 = fmul float %48, 1.000000e+02
%50 = fpext float %49 to double
%51 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %50)
%52 = add nuw nsw i32 %46, 1
%53 = icmp eq i32 %52, %31
br i1 %53, label %54, label %45
54: ; preds = %45, %35
%55 = tail call i32 @fputc(i32 10, i32* %23)
%56 = add nuw nsw i32 %33, 1
%57 = icmp eq i32 %56, %20
br i1 %57, label %64, label %32
58: ; preds = %2
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%60 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%61 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%62 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str.8, i64 0, i64 0))
%63 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.9, i64 0, i64 0))
br label %64
64: ; preds = %54, %11, %58
ret i32 0
}