#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 */
float atof(char *);
float drand48();
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
float *load_mock_file(char *, int *);
int /*<<< orphan*/ srand48(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char **argv) {
  int n_points;
  float *r, *phi, *theta;
  float *x, *y, *z, *mass;
  float mass_filter, frac;
  float tmp;
  int n_in;
  int i;
  FILE *out;
  if (argc != 8) {
    fprintf(
        stderr, "USAGE: %s\n",
        "./cat2ngl.x x_file y_file z_file m_file ngl_file m_filter fraction");
    exit(1);
  }
  x = load_mock_file(argv[1], &n_points);
  y = load_mock_file(argv[2], &n_points);
  z = load_mock_file(argv[3], &n_points);
  mass = load_mock_file(argv[4], &n_points);
  mass_filter = atof(argv[6]);
  frac = atof(argv[7]);
  fprintf(stdout, "Filtering with mass:%e\n", mass_filter);
  fprintf(stdout, "Filtering a fraction:%f\n", frac);
  if (!(out = fopen(argv[5], "w"))) {
    fprintf(stderr, "Problem opening file %s\n", argv[5]);
    exit(1);
  }
  srand48(n_points);
  n_in = 0;
  for (i = 0; i < n_points; i++) {
    tmp = drand48();
    if ((mass[i] > mass_filter) && (tmp < frac)) {
      fprintf(out, "%f %f %f\n", x[i], y[i], z[i]);
      n_in++;
    }
  }
  fprintf(stdout, "The number of selected points is %d\n", n_in);
  fclose(out);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x8,-0x8(%rbp)
je     11c8 <main+0x48>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
lea    0xe54(%rip),%rdx
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <load_mock_file@plt>
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <load_mock_file@plt>
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <load_mock_file@plt>
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <load_mock_file@plt>
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rdi
call   1030 <atof@plt>
movss  %xmm0,-0x58(%rbp)
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
movss  -0x54(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf5(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
movss  -0x58(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xded(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
lea    0xdf0(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x70(%rbp)
cmp    $0x0,%rax
jne    12cb <main+0x14b>
mov    0x2d37(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdx
lea    0xdc7(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x14(%rbp),%edi
call   1070 <srand48@plt>
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
mov    -0x64(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1386 <main+0x206>
mov    $0x0,%al
call   10a0 <drand48@plt>
movss  %xmm0,-0x5c(%rbp)
mov    -0x50(%rbp),%rax
movslq -0x64(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
ucomiss -0x54(%rbp),%xmm0
jbe    1373 <main+0x1f3>
movss  -0x5c(%rbp),%xmm1
movss  -0x58(%rbp),%xmm0
ucomiss %xmm1,%xmm0
jbe    1373 <main+0x1f3>
mov    -0x70(%rbp),%rax
mov    %eax,%edi
mov    -0x38(%rbp),%rax
movslq -0x64(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x40(%rbp),%rax
movslq -0x64(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm1
cvtss2sd %xmm1,%xmm1
mov    -0x48(%rbp),%rax
movslq -0x64(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xd37(%rip),%rsi
mov    $0x3,%al
call   1060 <fprintf@plt>
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    1378 <main+0x1f8>
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    12e1 <main+0x161>
mov    0x2c4b(%rip),%rax
mov    (%rax),%edi
mov    -0x60(%rbp),%edx
lea    0xd0b(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x70(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x8,%edi
jne    130a <main+0x18a>
mov    %rsi,%rbp
mov    0x8(%rsi),%rdi
lea    0x4(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <load_mock_file@plt>
mov    %rax,0x10(%rsp)
mov    0x10(%rbp),%rdi
mov    %rbx,%rsi
call   1050 <load_mock_file@plt>
mov    %rax,%r15
mov    0x18(%rbp),%rdi
mov    %rbx,%rsi
call   1050 <load_mock_file@plt>
mov    %rax,%r12
mov    0x20(%rbp),%rdi
mov    %rbx,%rsi
call   1050 <load_mock_file@plt>
mov    %rax,%rbx
mov    0x30(%rbp),%rdi
call   1030 <atof@plt>
movss  %xmm0,0xc(%rsp)
mov    0x38(%rbp),%rdi
call   1030 <atof@plt>
movss  %xmm0,0x8(%rsp)
mov    0x2dd6(%rip),%r14
mov    (%r14),%edi
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe38(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    (%r14),%edi
movss  0x8(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe35(%rip),%rsi
mov    $0x1,%al
call   1060 <fprintf@plt>
mov    0x28(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1323 <main+0x1a3>
mov    %rax,%r13
mov    0x4(%rsp),%edi
call   1070 <srand48@plt>
cmpl   $0x0,0x4(%rsp)
jle    12d6 <main+0x156>
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    127e <main+0xfe>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r14
movslq 0x4(%rsp),%rax
cmp    %rax,%r14
jge    12d8 <main+0x158>
xor    %eax,%eax
call   10a0 <drand48@plt>
movss  (%rbx,%r14,4),%xmm1
ucomiss 0xc(%rsp),%xmm1
jbe    1270 <main+0xf0>
movss  0x8(%rsp),%xmm1
ucomiss %xmm0,%xmm1
jbe    1270 <main+0xf0>
mov    0x10(%rsp),%rax
movss  (%rax,%r14,4),%xmm0
cvtss2sd %xmm0,%xmm0
movss  (%r15,%r14,4),%xmm1
cvtss2sd %xmm1,%xmm1
movss  (%r12,%r14,4),%xmm2
cvtss2sd %xmm2,%xmm2
mov    %r13d,%edi
lea    0xdd0(%rip),%rsi
mov    $0x3,%al
call   1060 <fprintf@plt>
add    $0x1,%ebp
jmp    1270 <main+0xf0>
xor    %ebp,%ebp
mov    0x2cf9(%rip),%rax
mov    (%rax),%edi
lea    0xdbc(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    %r13,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ccf(%rip),%rax
mov    (%rax),%edi
lea    0xce6(%rip),%rsi
lea    0xcea(%rip),%rdx
jmp    1337 <main+0x1b7>
mov    0x2cb6(%rip),%rax
mov    (%rax),%edi
mov    0x28(%rbp),%rdx
lea    0xd4a(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [11 x i8] c"USAGE: %s\0A\00"
@.str.1 = [67 x i8] c"./cat2ngl.x x_file y_file z_file m_file ngl_file m_filter fraction\00"
@stdout = global i32 0
@.str.2 = [24 x i8] c"Filtering with mass:%e\0A\00"
@.str.3 = [25 x i8] c"Filtering a fraction:%f\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [25 x i8] c"Problem opening file %s\0A\00"
@.str.6 = [10 x i8] c"%f %f %f\0A\00"
@.str.7 = [37 x i8] c"The number of selected points is %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca float*
%8 = alloca float*
%9 = alloca float*
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca float*
%14 = alloca float
%15 = alloca float
%16 = alloca float
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 8
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call float* @load_mock_file(i8* %29, i32* %6)
store float* %30, float** %10
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call float* @load_mock_file(i8* %33, i32* %6)
store float* %34, float** %11
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 3
%37 = load i8*, i8** %36
%38 = call float* @load_mock_file(i8* %37, i32* %6)
store float* %38, float** %12
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 4
%41 = load i8*, i8** %40
%42 = call float* @load_mock_file(i8* %41, i32* %6)
store float* %42, float** %13
%43 = load i8**, i8*** %5
%44 = getelementptr inbounds i8*, i8** %43, i64 6
%45 = load i8*, i8** %44
%46 = call float @atof(i8* %45)
store float %46, float* %14
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 7
%49 = load i8*, i8** %48
%50 = call float @atof(i8* %49)
store float %50, float* %15
%51 = load i32, i32* @stdout
%52 = load float, float* %14
%53 = fpext float %52 to double
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), double %53)
%55 = load i32, i32* @stdout
%56 = load float, float* %15
%57 = fpext float %56 to double
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %57)
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 5
%61 = load i8*, i8** %60
%62 = call i32* @fopen(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %62, i32** %19
%63 = icmp ne i32* %62, null
br i1 %63, label %71, label %64
64: ; preds = %26
%65 = load i32, i32* @stderr
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 5
%68 = load i8*, i8** %67
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %65, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %68)
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %26
%72 = load i32, i32* %6
%73 = call i32 @srand48(i32 %72)
store i32 0, i32* %17
store i32 0, i32* %18
br label %74
74: ; preds = %116, %71
%75 = load i32, i32* %18
%76 = load i32, i32* %6
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %119
78: ; preds = %74
%79 = call float (...) @drand48()
store float %79, float* %16
%80 = load float*, float** %13
%81 = load i32, i32* %18
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds float, float* %80, i64 %82
%84 = load float, float* %83
%85 = load float, float* %14
%86 = fcmp ogt float %84, %85
br i1 %86, label %87, label %115
87: ; preds = %78
%88 = load float, float* %16
%89 = load float, float* %15
%90 = fcmp olt float %88, %89
br i1 %90, label %91, label %115
91: ; preds = %87
%92 = load i32*, i32** %19
%93 = ptrtoint i32* %92 to i32
%94 = load float*, float** %10
%95 = load i32, i32* %18
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds float, float* %94, i64 %96
%98 = load float, float* %97
%99 = fpext float %98 to double
%100 = load float*, float** %11
%101 = load i32, i32* %18
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds float, float* %100, i64 %102
%104 = load float, float* %103
%105 = fpext float %104 to double
%106 = load float*, float** %12
%107 = load i32, i32* %18
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds float, float* %106, i64 %108
%110 = load float, float* %109
%111 = fpext float %110 to double
%112 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), double %99, double %105, double %111)
%113 = load i32, i32* %17
%114 = add nsw i32 %113, 1
store i32 %114, i32* %17
br label %115
115: ; preds = %91, %87, %78
br label %116
116: ; preds = %115
%117 = load i32, i32* %18
%118 = add nsw i32 %117, 1
store i32 %118, i32* %18
br label %74
119: ; preds = %74
%120 = load i32, i32* @stdout
%121 = load i32, i32* %17
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %121)
%123 = load i32*, i32** %19
%124 = call i32 @fclose(i32* %123)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [11 x i8] c"USAGE: %s\0A\00"
@.str.1 = [67 x i8] c"./cat2ngl.x x_file y_file z_file m_file ngl_file m_filter fraction\00"
@stdout = global i32 0
@.str.2 = [24 x i8] c"Filtering with mass:%e\0A\00"
@.str.3 = [25 x i8] c"Filtering a fraction:%f\0A\00"
@.str.4 = [2 x i8] c"w\00"
@.str.5 = [25 x i8] c"Problem opening file %s\0A\00"
@.str.6 = [10 x i8] c"%f %f %f\0A\00"
@.str.7 = [37 x i8] c"The number of selected points is %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i32 %0, 8
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call float* @load_mock_file(i8* %12, i32* %3)
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = call float* @load_mock_file(i8* %15, i32* %3)
%17 = getelementptr inbounds i8*, i8** %1, i64 3
%18 = load i8*, i8** %17
%19 = call float* @load_mock_file(i8* %18, i32* %3)
%20 = getelementptr inbounds i8*, i8** %1, i64 4
%21 = load i8*, i8** %20
%22 = call float* @load_mock_file(i8* %21, i32* %3)
%23 = getelementptr inbounds i8*, i8** %1, i64 6
%24 = load i8*, i8** %23
%25 = call float @atof(i8* %24)
%26 = getelementptr inbounds i8*, i8** %1, i64 7
%27 = load i8*, i8** %26
%28 = call float @atof(i8* %27)
%29 = load i32, i32* @stdout
%30 = fpext float %25 to double
%31 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), double %30)
%32 = load i32, i32* @stdout
%33 = fpext float %28 to double
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), double %33)
%35 = getelementptr inbounds i8*, i8** %1, i64 5
%36 = load i8*, i8** %35
%37 = call i32* @fopen(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp eq i32* %37, null
br i1 %38, label %39, label %44
39: ; preds = %10
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %35
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %40, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %10
%45 = load i32, i32* %3
%46 = call i32 @srand48(i32 %45)
%47 = load i32, i32* %3
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %79
49: ; preds = %44
%50 = ptrtoint i32* %37 to i64
%51 = trunc i64 %50 to i32
br label %52
52: ; preds = %49, %73
%53 = phi i64 [ 0, %49 ], [ %75, %73 ]
%54 = phi i32 [ 0, %49 ], [ %74, %73 ]
%55 = call float (...) @drand48()
%56 = getelementptr inbounds float, float* %22, i64 %53
%57 = load float, float* %56
%58 = fcmp ogt float %57, %25
%59 = fcmp olt float %55, %28
%60 = select i1 %58, i1 %59, i1 false
br i1 %60, label %61, label %73
61: ; preds = %52
%62 = getelementptr inbounds float, float* %13, i64 %53
%63 = load float, float* %62
%64 = fpext float %63 to double
%65 = getelementptr inbounds float, float* %16, i64 %53
%66 = load float, float* %65
%67 = fpext float %66 to double
%68 = getelementptr inbounds float, float* %19, i64 %53
%69 = load float, float* %68
%70 = fpext float %69 to double
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), double %64, double %67, double %70)
%72 = add nsw i32 %54, 1
br label %73
73: ; preds = %52, %61
%74 = phi i32 [ %72, %61 ], [ %54, %52 ]
%75 = add nuw nsw i64 %53, 1
%76 = load i32, i32* %3
%77 = sext i32 %76 to i64
%78 = icmp slt i64 %75, %77
br i1 %78, label %52, label %79
79: ; preds = %73, %44
%80 = phi i32 [ 0, %44 ], [ %74, %73 ]
%81 = load i32, i32* @stdout
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %80)
%83 = call i32 @fclose(i32* %37)
ret i32 0
}