#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 /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int inside(double, double);
int /*<<< orphan*/ printf(char *, int);
double rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void box(double NumPoints, double xmin, double xmax, double ymin, double ymax) {
  FILE *fl_in, *fl_ex;
  int i, j = 0, k = 0;
  double dx = xmax - xmin;
  double dy = ymax - ymin;
  double x, y;
  srand(time(NULL));
  fl_in = fopen("in_pts.tec", "w");
  fl_ex = fopen("ex_pts.tec", "w");
  fprintf(fl_in, "                                  \n");
  fprintf(fl_ex, "                                  \n");
  for (i = 0; i < NumPoints; i++) {
    x = rand() * dx / RAND_MAX + xmin;
    y = rand() * dy / RAND_MAX + ymin;
    if (inside(x, y) == 1) {
      fprintf(fl_in, "%30.30f %30.30f\n", x, y);
      j++;
    } else {
      fprintf(fl_ex, "%30.30f %30.30f\n", x, y);
      k++;
    }
  }
  printf("\nTotal No. of Points Checked: %d\n", i);
  fseek(fl_in, 0, SEEK_SET);
  fseek(fl_ex, 0, SEEK_SET);
  fprintf(fl_in, "ZONE T=INTERIOR I=%d", j);
  fprintf(fl_ex, "ZONE T=EXTERIOR I=%d", k);
  fseek(fl_in, 0, SEEK_END);
  fseek(fl_ex, 0, SEEK_END);
  fclose(fl_in);
  fclose(fl_ex);
}


x86 assembly (clang, -O0):
<box>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x28(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe0c(%rip),%rdi
lea    0xe10(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x30(%rbp)
lea    0xe02(%rip),%rdi
lea    0xdf9(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x38(%rbp),%rdi
lea    0xde0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,-0x3c(%rbp)
cvtsi2sdl -0x3c(%rbp),%xmm1
movsd  -0x8(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1316 <box+0x186>
mov    $0x0,%al
call   10b0 <rand@plt>
mulsd  -0x50(%rbp),%xmm0
mov    0x2d73(%rip),%rax
divsd  (%rax),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    $0x0,%al
call   10b0 <rand@plt>
mulsd  -0x58(%rbp),%xmm0
mov    0x2d52(%rip),%rax
divsd  (%rax),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
call   1050 <inside@plt>
cmp    $0x1,%eax
jne    12de <box+0x14e>
mov    -0x30(%rbp),%rdi
movsd  -0x60(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
lea    0xd73(%rip),%rsi
mov    $0x2,%al
call   1070 <fprintf@plt>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    1303 <box+0x173>
mov    -0x38(%rbp),%rdi
movsd  -0x60(%rbp),%xmm0
movsd  -0x68(%rbp),%xmm1
lea    0xd49(%rip),%rsi
mov    $0x2,%al
call   1070 <fprintf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1308 <box+0x178>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1246 <box+0xb6>
mov    -0x3c(%rbp),%esi
lea    0xd2d(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    0x2ca0(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x38(%rbp),%rdi
mov    0x2c8c(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%edx
lea    0xd14(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x44(%rbp),%edx
lea    0xd14(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    0x2c66(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x38(%rbp),%rdi
mov    0x2c52(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<box>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movsd  %xmm4,0x10(%rsp)
movsd  %xmm3,0x30(%rsp)
movsd  %xmm2,0x8(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x38(%rsp)
xor    %r12d,%r12d
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe1c(%rip),%rdi
lea    0xe20(%rip),%rbx
mov    %rbx,%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbp
lea    0xe10(%rip),%rdi
mov    %rbx,%rsi
call   10a0 <fopen@plt>
mov    %rax,%r15
lea    0xe09(%rip),%rbx
mov    $0x23,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %rbp,0x20(%rsp)
mov    %rbp,%rcx
call   10b0 <fwrite@plt>
mov    $0x23,%esi
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %r15,%rcx
call   10b0 <fwrite@plt>
xorpd  %xmm0,%xmm0
movsd  0x38(%rsp),%xmm1
ucomisd %xmm0,%xmm1
mov    $0x0,%ebp
mov    $0x0,%ebx
jbe    134a <box+0x1aa>
movsd  0x8(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x30(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
mov    0x2d59(%rip),%r14
lea    0xdae(%rip),%r13
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r12d,%r12d
jmp    12d3 <box+0x133>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13,%rsi
movsd  0x18(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
mov    $0x2,%al
call   1070 <fprintf@plt>
add    $0x1,%r12d
add    $0x1,%ebx
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x38(%rsp),%xmm1
ucomisd %xmm0,%xmm1
jbe    134a <box+0x1aa>
xor    %eax,%eax
call   10c0 <rand@plt>
mulsd  0x8(%rsp),%xmm0
divsd  (%r14),%xmm0
addsd  0x28(%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %eax,%eax
call   10c0 <rand@plt>
movapd %xmm0,%xmm1
mulsd  0x10(%rsp),%xmm1
divsd  (%r14),%xmm1
addsd  0x30(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
movsd  %xmm1,0x40(%rsp)
call   1050 <inside@plt>
cmp    $0x1,%eax
jne    12a0 <box+0x100>
mov    0x20(%rsp),%rdi
mov    %r13,%rsi
movsd  0x18(%rsp),%xmm0
movsd  0x40(%rsp),%xmm1
mov    $0x2,%al
call   1070 <fprintf@plt>
add    $0x1,%ebp
jmp    12bd <box+0x11d>
lea    0xcfc(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    0x2c71(%rip),%r14
mov    (%r14),%edx
mov    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    (%r14),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
lea    0xcea(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
lea    0xcec(%rip),%rsi
mov    %r15,%rdi
mov    %r12d,%edx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    0x2c3c(%rip),%rbp
mov    0x0(%rbp),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    0x0(%rbp),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r15,%rdi
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fclose@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"in_pts.tec\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [11 x i8] c"ex_pts.tec\00"
@.str.3 = [36 x i8] c" \0A\00"
@RAND_MAX = global double 0.000000e+00
@.str.4 = [17 x i8] c"%30.30f %30.30f\0A\00"
@.str.5 = [34 x i8] c"\0ATotal No. of Points Checked: %d\0A\00"
@SEEK_SET = global i32 0
@.str.6 = [21 x i8] c"ZONE T=INTERIOR I=%d\00"
@.str.7 = [21 x i8] c"ZONE T=EXTERIOR I=%d\00"
@SEEK_END = global i32 0
define void @box(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca double
%17 = alloca double
%18 = alloca double
%19 = alloca double
store double %0, double* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
store i32 0, i32* %14
store i32 0, i32* %15
%20 = load double, double* %8
%21 = load double, double* %7
%22 = fsub double %20, %21
store double %22, double* %16
%23 = load double, double* %10
%24 = load double, double* %9
%25 = fsub double %23, %24
store double %25, double* %17
%26 = call i32 @time(i32* null)
%27 = call i32 @srand(i32 %26)
%28 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %28, i32** %11
%29 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %29, i32** %12
%30 = load i32*, i32** %11
%31 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%32 = load i32*, i32** %12
%33 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %13
br label %34
34: ; preds = %73, %5
%35 = load i32, i32* %13
%36 = sitofp i32 %35 to double
%37 = load double, double* %6
%38 = fcmp olt double %36, %37
br i1 %38, label %39, label %76
39: ; preds = %34
%40 = call double (...) @rand()
%41 = load double, double* %16
%42 = fmul double %40, %41
%43 = load double, double* @RAND_MAX
%44 = fdiv double %42, %43
%45 = load double, double* %7
%46 = fadd double %44, %45
store double %46, double* %18
%47 = call double (...) @rand()
%48 = load double, double* %17
%49 = fmul double %47, %48
%50 = load double, double* @RAND_MAX
%51 = fdiv double %49, %50
%52 = load double, double* %9
%53 = fadd double %51, %52
store double %53, double* %19
%54 = load double, double* %18
%55 = load double, double* %19
%56 = call i32 @inside(double %54, double %55)
%57 = icmp eq i32 %56, 1
br i1 %57, label %58, label %65
58: ; preds = %39
%59 = load i32*, i32** %11
%60 = load double, double* %18
%61 = load double, double* %19
%62 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %60, double %61)
%63 = load i32, i32* %14
%64 = add nsw i32 %63, 1
store i32 %64, i32* %14
br label %72
65: ; preds = %39
%66 = load i32*, i32** %12
%67 = load double, double* %18
%68 = load double, double* %19
%69 = call i32 (i32*, i8*, ...) @fprintf(i32* %66, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %67, double %68)
%70 = load i32, i32* %15
%71 = add nsw i32 %70, 1
store i32 %71, i32* %15
br label %72
72: ; preds = %65, %58
br label %73
73: ; preds = %72
%74 = load i32, i32* %13
%75 = add nsw i32 %74, 1
store i32 %75, i32* %13
br label %34
76: ; preds = %34
%77 = load i32, i32* %13
%78 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %77)
%79 = load i32*, i32** %11
%80 = load i32, i32* @SEEK_SET
%81 = call i32 @fseek(i32* %79, i32 0, i32 %80)
%82 = load i32*, i32** %12
%83 = load i32, i32* @SEEK_SET
%84 = call i32 @fseek(i32* %82, i32 0, i32 %83)
%85 = load i32*, i32** %11
%86 = load i32, i32* %14
%87 = call i32 (i32*, i8*, ...) @fprintf(i32* %85, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %86)
%88 = load i32*, i32** %12
%89 = load i32, i32* %15
%90 = call i32 (i32*, i8*, ...) @fprintf(i32* %88, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %89)
%91 = load i32*, i32** %11
%92 = load i32, i32* @SEEK_END
%93 = call i32 @fseek(i32* %91, i32 0, i32 %92)
%94 = load i32*, i32** %12
%95 = load i32, i32* @SEEK_END
%96 = call i32 @fseek(i32* %94, i32 0, i32 %95)
%97 = load i32*, i32** %11
%98 = call i32 @fclose(i32* %97)
%99 = load i32*, i32** %12
%100 = call i32 @fclose(i32* %99)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"in_pts.tec\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [11 x i8] c"ex_pts.tec\00"
@.str.3 = [36 x i8] c" \0A\00"
@RAND_MAX = global double 0.000000e+00
@.str.4 = [17 x i8] c"%30.30f %30.30f\0A\00"
@.str.5 = [34 x i8] c"\0ATotal No. of Points Checked: %d\0A\00"
@SEEK_SET = global i32 0
@.str.6 = [21 x i8] c"ZONE T=INTERIOR I=%d\00"
@.str.7 = [21 x i8] c"ZONE T=EXTERIOR I=%d\00"
@SEEK_END = global i32 0
define void @box(double %0, double %1, double %2, double %3, double %4) {
%6 = fsub double %2, %1
%7 = fsub double %4, %3
%8 = tail call i32 @time(i32* null)
%9 = tail call i32 @srand(i32 %8)
%10 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%11 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 35, i64 1, i32* %10)
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i64 35, i64 1, i32* %11)
%14 = fcmp ogt double %0, 0.000000e+00
br i1 %14, label %15, label %43
15: ; preds = %5, %37
%16 = phi i32 [ %40, %37 ], [ 0, %5 ]
%17 = phi i32 [ %39, %37 ], [ 0, %5 ]
%18 = phi i32 [ %38, %37 ], [ 0, %5 ]
%19 = tail call double (...) @rand()
%20 = fmul double %6, %19
%21 = load double, double* @RAND_MAX
%22 = fdiv double %20, %21
%23 = fadd double %22, %1
%24 = tail call double (...) @rand()
%25 = fmul double %7, %24
%26 = load double, double* @RAND_MAX
%27 = fdiv double %25, %26
%28 = fadd double %27, %3
%29 = tail call i32 @inside(double %23, double %28)
%30 = icmp eq i32 %29, 1
br i1 %30, label %31, label %34
31: ; preds = %15
%32 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %23, double %28)
%33 = add nsw i32 %17, 1
br label %37
34: ; preds = %15
%35 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %23, double %28)
%36 = add nsw i32 %18, 1
br label %37
37: ; preds = %31, %34
%38 = phi i32 [ %18, %31 ], [ %36, %34 ]
%39 = phi i32 [ %33, %31 ], [ %17, %34 ]
%40 = add nuw nsw i32 %16, 1
%41 = sitofp i32 %40 to double
%42 = fcmp olt double %41, %0
br i1 %42, label %15, label %43
43: ; preds = %37, %5
%44 = phi i32 [ 0, %5 ], [ %38, %37 ]
%45 = phi i32 [ 0, %5 ], [ %39, %37 ]
%46 = phi i32 [ 0, %5 ], [ %40, %37 ]
%47 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i32 %46)
%48 = load i32, i32* @SEEK_SET
%49 = tail call i32 @fseek(i32* %10, i32 0, i32 %48)
%50 = load i32, i32* @SEEK_SET
%51 = tail call i32 @fseek(i32* %11, i32 0, i32 %50)
%52 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %10, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0), i32 %45)
%53 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %44)
%54 = load i32, i32* @SEEK_END
%55 = tail call i32 @fseek(i32* %10, i32 0, i32 %54)
%56 = load i32, i32* @SEEK_END
%57 = tail call i32 @fseek(i32* %11, i32 0, i32 %56)
%58 = tail call i32 @fclose(i32* %10)
%59 = tail call i32 @fclose(i32* %11)
ret void
}