#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 */
long atoi(char *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, char *);
long rand_long();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  long i, j, ran_num;
  if (argc < 2) {
    printf("Usage: %s num_points\n", argv[0]);
    return 0;
  }
  long num_point = atoi(argv[1]);
  FILE *f1 = NULL;
  f1 = fopen("kmeans-input.301", "w");
  srand(0);
  for (i = 0; i < num_point; i++) {
    for (j = 0; j < 4; j++) {
      ran_num = rand_long();
      ran_num = ran_num / 16L;
      fprintf(f1, "%d ", ran_num);
    }
    fprintf(f1, "\n");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119f <main+0x3f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe72(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1266 <main+0x106>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %rax,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
lea    0xe57(%rip),%rdi
lea    0xe61(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
xor    %edi,%edi
call   1050 <srand@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x30(%rbp),%rax
jge    1266 <main+0x106>
movq   $0x0,-0x20(%rbp)
cmpq   $0x4,-0x20(%rbp)
jge    1243 <main+0xe3>
mov    $0x0,%al
call   1040 <rand_long@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x10,%ecx
cqto
idiv   %rcx
mov    %rax,-0x28(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11f4 <main+0x94>
mov    -0x38(%rbp),%rdi
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11de <main+0x7e>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
cmp    $0x1,%edi
jg     118e <main+0x1e>
mov    (%rsi),%rsi
lea    0xe7c(%rip),%rdi
call   1030 <printf@plt>
jmp    1273 <main+0x103>
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %rax,%rbx
lea    0xe75(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r14
xor    %edi,%edi
call   1060 <srand@plt>
test   %rbx,%rbx
jle    1273 <main+0x103>
lea    0xe62(%rip),%r15
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand_long@plt>
lea    0xf(%rax),%rdx
test   %rax,%rax
cmovns %rax,%rdx
sar    $0x4,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
call   1040 <rand_long@plt>
lea    0xf(%rax),%rdx
test   %rax,%rax
cmovns %rax,%rdx
sar    $0x4,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
call   1040 <rand_long@plt>
lea    0xf(%rax),%rdx
test   %rax,%rax
cmovns %rax,%rdx
sar    $0x4,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
xor    %eax,%eax
call   1040 <rand_long@plt>
lea    0xf(%rax),%rdx
test   %rax,%rax
cmovns %rax,%rdx
sar    $0x4,%rdx
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0xa,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
add    $0xffffffffffffffff,%rbx
jne    11d0 <main+0x60>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Usage: %s num_points\0A\00"
@.str.1 = [17 x i8] c"kmeans-input.301\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %16)
store i32 0, i32* %3
br label %49
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i64 @atoi(i8* %21)
store i64 %22, i64* %9
store i32* null, i32** %10
%23 = call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %23, i32** %10
%24 = call i32 @srand(i32 0)
store i64 0, i64* %6
br label %25
25: ; preds = %46, %18
%26 = load i64, i64* %6
%27 = load i64, i64* %9
%28 = icmp slt i64 %26, %27
br i1 %28, label %29, label %49
29: ; preds = %25
store i64 0, i64* %7
br label %30
30: ; preds = %40, %29
%31 = load i64, i64* %7
%32 = icmp slt i64 %31, 4
br i1 %32, label %33, label %43
33: ; preds = %30
%34 = call i64 (...) @rand_long()
store i64 %34, i64* %8
%35 = load i64, i64* %8
%36 = sdiv i64 %35, 16
store i64 %36, i64* %8
%37 = load i32*, i32** %10
%38 = load i64, i64* %8
%39 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %38)
br label %40
40: ; preds = %33
%41 = load i64, i64* %7
%42 = add nsw i64 %41, 1
store i64 %42, i64* %7
br label %30
43: ; preds = %30
%44 = load i32*, i32** %10
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %43
%47 = load i64, i64* %6
%48 = add nsw i64 %47, 1
store i64 %48, i64* %6
br label %25
49: ; preds = %13, %25
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [22 x i8] c"Usage: %s num_points\0A\00"
@.str.1 = [17 x i8] c"kmeans-input.301\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %31
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @atoi(i8* %9)
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @srand(i32 0)
%13 = icmp sgt i64 %10, 0
br i1 %13, label %14, label %31
14: ; preds = %7, %14
%15 = phi i64 [ %29, %14 ], [ 0, %7 ]
%16 = tail call i64 (...) @rand_long()
%17 = sdiv i64 %16, 16
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %17)
%19 = tail call i64 (...) @rand_long()
%20 = sdiv i64 %19, 16
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %20)
%22 = tail call i64 (...) @rand_long()
%23 = sdiv i64 %22, 16
%24 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %23)
%25 = tail call i64 (...) @rand_long()
%26 = sdiv i64 %25, 16
%27 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %26)
%28 = tail call i32 @fputc(i32 10, i32* %11)
%29 = add nuw nsw i64 %15, 1
%30 = icmp eq i64 %29, %10
br i1 %30, label %31, label %14
31: ; preds = %14, %7, %4
ret i32 0
}