#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 < k; i++) {
        x = m * rand() * 100;
        fprintf(fp, "%f ", x);
      }
      for (i = 0; i < 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    136e <main+0x1ee>
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    1369 <main+0x1e9>
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
cmp    -0x14(%rbp),%eax
jge    12df <main+0x15f>
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  0xd5b(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x28(%rbp),%rdi
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd57(%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
cmp    -0x18(%rbp),%eax
jge    1349 <main+0x1c9>
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  0xcf1(%rip),%xmm1
mulss  %xmm1,%xmm0
movss  %xmm0,-0x3c(%rbp)
mov    -0x28(%rbp),%rdi
movss  -0x3c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xced(%rip),%rsi
mov    $0x1,%al
call   1050 <fprintf@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12e6 <main+0x166>
mov    -0x28(%rbp),%rdi
lea    0xcd1(%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    13aa <main+0x22a>
lea    0xcb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xcc7(%rip),%rdi
call   1030 <puts@plt>
lea    0xcd9(%rip),%rdi
call   1030 <puts@plt>
lea    0xce6(%rip),%rdi
call   1030 <puts@plt>
lea    0xd28(%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    $0x18,%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     12e0 <main+0x160>
mov    0x2e37(%rip),%rax
movsd  (%rax),%xmm0
addsd  0xe43(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    0x8(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,0x14(%rsp)
mov    0x10(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%r13d
mov    0x18(%rbx),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
mov    0x20(%rbx),%rdi
lea    0xe44(%rip),%rsi
call   1080 <fopen@plt>
mov    %ebp,0x10(%rsp)
test   %ebp,%ebp
jle    131c <main+0x19c>
mov    %rax,%rbx
movsd  0xdf2(%rip),%xmm0
divsd  0x8(%rsp),%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xdee(%rip),%r14
xor    %r12d,%r12d
jmp    124c <main+0xcc>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0x1,%r12d
cmp    0x10(%rsp),%r12d
je     131c <main+0x19c>
mov    %rbx,%rdi
lea    0xdb6(%rip),%rsi
mov    0x14(%rsp),%ebp
mov    %ebp,%edx
mov    %r13d,%ecx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %ebp,%r15d
test   %ebp,%ebp
jle    129c <main+0x11c>
nopl   (%rax)
xor    %eax,%eax
call   10a0 <rand@plt>
mulss  0x8(%rsp),%xmm0
mulss  0xd83(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0xffffffff,%r15d
jne    1270 <main+0xf0>
mov    %r13d,%ebp
test   %r13d,%r13d
jle    1230 <main+0xb0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %eax,%eax
call   10a0 <rand@plt>
mulss  0x8(%rsp),%xmm0
mulss  0xd43(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
add    $0xffffffff,%ebp
jne    12b0 <main+0x130>
jmp    1230 <main+0xb0>
lea    0xd30(%rip),%rdi
call   1030 <puts@plt>
lea    0xd45(%rip),%rdi
call   1030 <puts@plt>
lea    0xd57(%rip),%rdi
call   1030 <puts@plt>
lea    0xd64(%rip),%rdi
call   1030 <puts@plt>
lea    0xda6(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%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 %96
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 = %92, %46
%48 = load i32, i32* %9
%49 = load i32, i32* %8
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %95
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 = %69, %51
%57 = load i32, i32* %13
%58 = load i32, i32* %6
%59 = icmp slt i32 %57, %58
br i1 %59, label %60, label %72
60: ; preds = %56
%61 = load float, float* %12
%62 = call float (...) @rand()
%63 = fmul float %61, %62
%64 = fmul float %63, 1.000000e+02
store float %64, float* %14
%65 = load i32*, i32** %10
%66 = load float, float* %14
%67 = fpext float %66 to double
%68 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %67)
br label %69
69: ; preds = %60
%70 = load i32, i32* %13
%71 = add nsw i32 %70, 1
store i32 %71, i32* %13
br label %56
72: ; preds = %56
store i32 0, i32* %13
br label %73
73: ; preds = %86, %72
%74 = load i32, i32* %13
%75 = load i32, i32* %7
%76 = icmp slt i32 %74, %75
br i1 %76, label %77, label %89
77: ; preds = %73
%78 = load float, float* %12
%79 = call float (...) @rand()
%80 = fmul float %78, %79
%81 = fmul float %80, 1.000000e+02
store float %81, float* %14
%82 = load i32*, i32** %10
%83 = load float, float* %14
%84 = fpext float %83 to double
%85 = call i32 (i32*, i8*, ...) @fprintf(i32* %82, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %84)
br label %86
86: ; preds = %77
%87 = load i32, i32* %13
%88 = add nsw i32 %87, 1
store i32 %88, i32* %13
br label %73
89: ; preds = %73
%90 = load i32*, i32** %10
%91 = call i32 (i32*, i8*, ...) @fprintf(i32* %90, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %92
92: ; preds = %89
%93 = load i32, i32* %9
%94 = add nsw i32 %93, 1
store i32 %94, i32* %9
br label %47
95: ; preds = %47
br label %102
96: ; preds = %2
%97 = call i32 @puts(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%98 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%99 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%100 = call i32 @puts(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str.8, i64 0, i64 0))
%101 = call i32 @puts(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.9, i64 0, i64 0))
br label %102
102: ; preds = %96, %95
%103 = load i32, i32* %3
ret i32 %103
}

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 %54
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 %60
25: ; preds = %11
%26 = icmp sgt i32 %14, 0
%27 = icmp sgt i32 %17, 0
br label %28
28: ; preds = %25, %50
%29 = phi i32 [ 0, %25 ], [ %52, %50 ]
%30 = 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 %26, label %32, label %31
31: ; preds = %32, %28
br i1 %27, label %41, label %50
32: ; preds = %28, %32
%33 = phi i32 [ %39, %32 ], [ 0, %28 ]
%34 = tail call float (...) @rand()
%35 = fmul float %34, %9
%36 = fmul float %35, 1.000000e+02
%37 = fpext float %36 to double
%38 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %37)
%39 = add nuw nsw i32 %33, 1
%40 = icmp eq i32 %39, %14
br i1 %40, label %31, label %32
41: ; preds = %31, %41
%42 = phi i32 [ %48, %41 ], [ 0, %31 ]
%43 = tail call float (...) @rand()
%44 = fmul float %43, %9
%45 = fmul float %44, 1.000000e+02
%46 = fpext float %45 to double
%47 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %23, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), double %46)
%48 = add nuw nsw i32 %42, 1
%49 = icmp eq i32 %48, %17
br i1 %49, label %50, label %41
50: ; preds = %41, %31
%51 = tail call i32 @fputc(i32 10, i32* %23)
%52 = add nuw nsw i32 %29, 1
%53 = icmp eq i32 %52, %20
br i1 %53, label %60, label %28
54: ; preds = %2
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0))
%57 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0))
%58 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @.str.8, i64 0, i64 0))
%59 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str.9, i64 0, i64 0))
br label %60
60: ; preds = %50, %11, %54
ret i32 0
}