#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 */
char EOF;
double atof(char *);
int atoi(char *);
double drand48();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
char getopt(int, char **, char *);
double sqrt(double);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  extern char *optarg;
  char c;
  FILE *outfile;
  double rho = 0.8;
  int n = 1024;
  double rx, ry;
  double vx, vy;
  int m, i, j;
  double L, dL;
  while ((c = getopt(argc, argv, "n:d:")) != EOF) {
    switch (c) {
    case 'n':
      n = atoi(optarg);
      break;
    case 'd':
      rho = atof(optarg);
      break;
    default:
      fprintf(stderr, "Unknown option\n");
      break;
    }
  }
  L = sqrt(rho / (double)n);
  m = (int)sqrt((double)n);
  dL = L / m;
  outfile = fopen("test.conf", "w");
  for (i = 0; i < m; i++) {
    rx = -0.5 * L + dL * (double)i;
    for (j = 0; j < m; j++) {
      ry = -0.5 * L + dL * (double)j;
      vx = 2.0 * drand48() - 1.0;
      vy = 2.0 * drand48() - 1.0;
      fprintf(outfile, "%e %e %e %e\n", rx, ry, vx, vy);
    }
  }
  fclose(outfile);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movsd  0xe5f(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x400,-0x2c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe5d(%rip),%rdx
call   1070 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e1b(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     124b <main+0xcb>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x74(%rbp)
sub    $0x64,%eax
je     1215 <main+0x95>
jmp    11ed <main+0x6d>
mov    -0x74(%rbp),%eax
sub    $0x6e,%eax
jne    122e <main+0xae>
jmp    11fe <main+0x7e>
mov    0x2dd3(%rip),%rax
mov    (%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    1246 <main+0xc6>
mov    0x2dbc(%rip),%rax
mov    (%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1246 <main+0xc6>
mov    0x2d9b(%rip),%rax
movslq (%rax),%rdi
lea    0xdde(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    11ad <main+0x2d>
movsd  -0x28(%rbp),%xmm0
cvtsi2sdl -0x2c(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1090 <sqrt@plt>
movsd  %xmm0,-0x68(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
call   1090 <sqrt@plt>
cvttsd2si %xmm0,%eax
mov    %eax,-0x54(%rbp)
movsd  -0x68(%rbp),%xmm0
cvtsi2sdl -0x54(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
lea    0xd9f(%rip),%rdi
lea    0xda2(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x58(%rbp)
mov    -0x58(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    1393 <main+0x213>
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
cvtsi2sdl -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd3c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x54(%rbp),%eax
jge    1380 <main+0x200>
movsd  -0x68(%rbp),%xmm0
movsd  -0x70(%rbp),%xmm1
cvtsi2sdl -0x5c(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xd01(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    $0x0,%al
call   10a0 <drand48@plt>
addsd  %xmm0,%xmm0
movsd  0xce9(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    $0x0,%al
call   10a0 <drand48@plt>
addsd  %xmm0,%xmm0
movsd  0xccd(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x20(%rbp),%rdi
movsd  -0x38(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
lea    0xcce(%rip),%rsi
mov    $0x4,%al
call   1050 <fprintf@plt>
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    12e0 <main+0x160>
jmp    1385 <main+0x205>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    12a5 <main+0x125>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xe76(%rip),%rdx
call   1070 <getopt@plt>
mov    0x2e32(%rip),%r13
cmp    0x0(%r13),%al
jne    11ea <main+0x5a>
movsd  0xe3c(%rip),%xmm0
mov    $0x400,%r14d
cvtsi2sd %r14d,%xmm1
divsd  %xmm1,%xmm0
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     1280 <main+0xf0>
sqrtsd %xmm0,%xmm0
jmp    1293 <main+0x103>
mov    $0x400,%r14d
movsd  0xe08(%rip),%xmm0
mov    0x2dd9(%rip),%r12
lea    0xe1a(%rip),%r15
jmp    1248 <main+0xb8>
nopl   0x0(%rax,%rax,1)
mov    0x2db9(%rip),%rax
movslq (%rax),%rcx
mov    $0xf,%esi
mov    $0x1,%edx
lea    0xdfa(%rip),%rdi
call   10a0 <fwrite@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1070 <getopt@plt>
cmp    0x0(%r13),%al
movsd  (%rsp),%xmm0
je     11ca <main+0x3a>
movsbl %al,%eax
cmp    $0x64,%eax
je     1270 <main+0xe0>
movsd  %xmm0,(%rsp)
cmp    $0x6e,%eax
jne    1210 <main+0x80>
mov    (%r12),%rdi
call   1080 <atoi@plt>
mov    %eax,%r14d
jmp    1230 <main+0xa0>
nopl   0x0(%rax,%rax,1)
mov    (%r12),%rdi
call   1030 <atof@plt>
movsd  %xmm0,(%rsp)
jmp    1230 <main+0xa0>
movsd  %xmm1,(%rsp)
call   1090 <sqrt@plt>
xorpd  %xmm2,%xmm2
movsd  (%rsp),%xmm1
movsd  %xmm0,0x18(%rsp)
ucomisd %xmm2,%xmm1
jb     12a8 <main+0x118>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    12b1 <main+0x121>
movapd %xmm1,%xmm0
call   1090 <sqrt@plt>
movapd %xmm0,(%rsp)
cvttsd2si %xmm0,%r14d
lea    0xd73(%rip),%rdi
lea    0xd76(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%rbx
test   %r14d,%r14d
movsd  0x18(%rsp),%xmm1
jle    13e7 <main+0x257>
cvttpd2dq (%rsp),%xmm0
cvtdq2pd %xmm0,%xmm0
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
xorpd  %xmm0,%xmm0
mulsd  0xd0b(%rip),%xmm1
lea    0xd3d(%rip),%r12
xor    %r15d,%r15d
movsd  %xmm1,0x18(%rsp)
movsd  %xmm2,0x28(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movapd %xmm2,%xmm3
movsd  %xmm0,0x20(%rsp)
mulsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,0x30(%rsp)
mov    %r14d,%ebp
xorpd  %xmm4,%xmm4
nop
movsd  %xmm4,(%rsp)
mulsd  %xmm4,%xmm2
addsd  %xmm1,%xmm2
movsd  %xmm2,0x40(%rsp)
xor    %eax,%eax
call   10b0 <drand48@plt>
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
movsd  0xca6(%rip),%xmm0
addsd  %xmm0,%xmm1
movsd  %xmm1,0x38(%rsp)
xor    %eax,%eax
call   10b0 <drand48@plt>
movapd %xmm0,%xmm3
addsd  %xmm0,%xmm3
addsd  0xc85(%rip),%xmm3
mov    %rbx,%rdi
mov    %r12,%rsi
movsd  0x30(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
movsd  0x38(%rsp),%xmm2
mov    $0x4,%al
call   1050 <fprintf@plt>
movsd  (%rsp),%xmm4
movsd  0xc61(%rip),%xmm3
movsd  0x28(%rsp),%xmm2
movsd  0x18(%rsp),%xmm1
addsd  %xmm3,%xmm4
add    $0xffffffff,%ebp
jne    1340 <main+0x1b0>
movsd  0x20(%rsp),%xmm0
addsd  %xmm3,%xmm0
add    $0x1,%r15d
cmp    %r14d,%r15d
jne    1320 <main+0x190>
mov    %rbx,%rdi
call   1040 <fclose@plt>
mov    $0x1,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"n:d:\00"
@EOF = global i8 0
@optarg = external global i8*
@stderr = global i32 0
@.str.1 = [16 x i8] c"Unknown option\0A\00"
@.str.2 = [10 x i8] c"test.conf\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [13 x i8] c"%e %e %e %e\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32*
%8 = alloca double
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca double
%18 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store double 8.000000e-01, double* %8
store i32 1024, i32* %9
br label %19
19: ; preds = %41, %2
%20 = load i32, i32* %4
%21 = load i8**, i8*** %5
%22 = call signext i8 @getopt(i32 %20, i8** %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8 %22, i8* %6
%23 = sext i8 %22 to i32
%24 = load i8, i8* @EOF
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %23, %25
br i1 %26, label %27, label %42
27: ; preds = %19
%28 = load i8, i8* %6
%29 = sext i8 %28 to i32
switch i32 %29, label %36 [
i32 110, label %30
i32 100, label %33
]
30: ; preds = %27
%31 = load i8*, i8** @optarg
%32 = call i32 @atoi(i8* %31)
store i32 %32, i32* %9
br label %41
33: ; preds = %27
%34 = load i8*, i8** @optarg
%35 = call double @atof(i8* %34)
store double %35, double* %8
br label %41
36: ; preds = %27
%37 = load i32, i32* @stderr
%38 = sext i32 %37 to i64
%39 = inttoptr i64 %38 to i32*
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
br label %41
41: ; preds = %36, %33, %30
br label %19
42: ; preds = %19
%43 = load double, double* %8
%44 = load i32, i32* %9
%45 = sitofp i32 %44 to double
%46 = fdiv double %43, %45
%47 = call double @sqrt(double %46)
store double %47, double* %17
%48 = load i32, i32* %9
%49 = sitofp i32 %48 to double
%50 = call double @sqrt(double %49)
%51 = fptosi double %50 to i32
store i32 %51, i32* %14
%52 = load double, double* %17
%53 = load i32, i32* %14
%54 = sitofp i32 %53 to double
%55 = fdiv double %52, %54
store double %55, double* %18
%56 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %56, i32** %7
store i32 0, i32* %15
br label %57
57: ; preds = %93, %42
%58 = load i32, i32* %15
%59 = load i32, i32* %14
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %96
61: ; preds = %57
%62 = load double, double* %17
%63 = load double, double* %18
%64 = load i32, i32* %15
%65 = sitofp i32 %64 to double
%66 = fmul double %63, %65
%67 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %62, double %66)
store double %67, double* %10
store i32 0, i32* %16
br label %68
68: ; preds = %89, %61
%69 = load i32, i32* %16
%70 = load i32, i32* %14
%71 = icmp slt i32 %69, %70
br i1 %71, label %72, label %92
72: ; preds = %68
%73 = load double, double* %17
%74 = load double, double* %18
%75 = load i32, i32* %16
%76 = sitofp i32 %75 to double
%77 = fmul double %74, %76
%78 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %73, double %77)
store double %78, double* %11
%79 = call double (...) @drand48()
%80 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %79, double -1.000000e+00)
store double %80, double* %12
%81 = call double (...) @drand48()
%82 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %81, double -1.000000e+00)
store double %82, double* %13
%83 = load i32*, i32** %7
%84 = load double, double* %10
%85 = load double, double* %11
%86 = load double, double* %12
%87 = load double, double* %13
%88 = call i32 (i32*, i8*, ...) @fprintf(i32* %83, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), double %84, double %85, double %86, double %87)
br label %89
89: ; preds = %72
%90 = load i32, i32* %16
%91 = add nsw i32 %90, 1
store i32 %91, i32* %16
br label %68
92: ; preds = %68
br label %93
93: ; preds = %92
%94 = load i32, i32* %15
%95 = add nsw i32 %94, 1
store i32 %95, i32* %15
br label %57
96: ; preds = %57
%97 = load i32*, i32** %7
%98 = call i32 @fclose(i32* %97)
ret i32 1
}

LLVM IR (-O2):
@.str = [5 x i8] c"n:d:\00"
@EOF = global i8 0
@optarg = external global i8*
@stderr = global i32 0
@.str.1 = [16 x i8] c"Unknown option\0A\00"
@.str.2 = [10 x i8] c"test.conf\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [13 x i8] c"%e %e %e %e\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %28, label %6
6: ; preds = %2, %22
%7 = phi i8 [ %25, %22 ], [ %3, %2 ]
%8 = phi double [ %24, %22 ], [ 8.000000e-01, %2 ]
%9 = phi i32 [ %23, %22 ], [ 1024, %2 ]
%10 = sext i8 %7 to i32
switch i32 %10, label %17 [
i32 110, label %11
i32 100, label %14
]
11: ; preds = %6
%12 = load i8*, i8** @optarg
%13 = tail call i32 @atoi(i8* %12)
br label %22
14: ; preds = %6
%15 = load i8*, i8** @optarg
%16 = tail call double @atof(i8* %15)
br label %22
17: ; preds = %6
%18 = load i32, i32* @stderr
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i32*
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64 15, i64 1, i32* %20)
br label %22
22: ; preds = %17, %14, %11
%23 = phi i32 [ %9, %17 ], [ %9, %14 ], [ %13, %11 ]
%24 = phi double [ %8, %17 ], [ %16, %14 ], [ %8, %11 ]
%25 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%26 = load i8, i8* @EOF
%27 = icmp eq i8 %25, %26
br i1 %27, label %28, label %6
28: ; preds = %22, %2
%29 = phi i32 [ 1024, %2 ], [ %23, %22 ]
%30 = phi double [ 8.000000e-01, %2 ], [ %24, %22 ]
%31 = sitofp i32 %29 to double
%32 = fdiv double %30, %31
%33 = tail call double @sqrt(double %32)
%34 = tail call double @sqrt(double %31)
%35 = fptosi double %34 to i32
%36 = sitofp i32 %35 to double
%37 = fdiv double %33, %36
%38 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp sgt i32 %35, 0
br i1 %39, label %40, label %60
40: ; preds = %28, %57
%41 = phi i32 [ %58, %57 ], [ 0, %28 ]
%42 = sitofp i32 %41 to double
%43 = fmul double %37, %42
%44 = tail call double @llvm.fmuladd.f64(double %33, double -5.000000e-01, double %43)
br label %45
45: ; preds = %40, %45
%46 = phi i32 [ %55, %45 ], [ 0, %40 ]
%47 = sitofp i32 %46 to double
%48 = fmul double %37, %47
%49 = tail call double @llvm.fmuladd.f64(double %33, double -5.000000e-01, double %48)
%50 = tail call double (...) @drand48()
%51 = tail call double @llvm.fmuladd.f64(double %50, double 2.000000e+00, double -1.000000e+00)
%52 = tail call double (...) @drand48()
%53 = tail call double @llvm.fmuladd.f64(double %52, double 2.000000e+00, double -1.000000e+00)
%54 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), double %44, double %49, double %51, double %53)
%55 = add nuw nsw i32 %46, 1
%56 = icmp eq i32 %55, %35
br i1 %56, label %57, label %45
57: ; preds = %45
%58 = add nuw nsw i32 %41, 1
%59 = icmp eq i32 %58, %35
br i1 %59, label %60, label %40
60: ; preds = %57, %28
%61 = tail call i32 @fclose(i32* %38)
ret i32 1
}