#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 */

/* Variables and functions */
double DBL_MAX;
double atof(char const *);
int atoi(char const *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, double);
double run(int, int, int, double, double, double, double, char const *);
int /*<<< orphan*/ stderr;
int main(int argc, const char **argv) {
  int N_X, N_Y;
  double min_x, max_x, min_y, max_y;
  if (argc != 8) {
    fprintf(
        stderr,
        "Need 8 arguments: N_X, N_Y, min_x, max_x, min_y, max_y, filename\n");
    return 1;
  }
  N_X = atoi(argv[1]);
  N_Y = atoi(argv[2]);
  min_x = atof(argv[3]);
  max_x = atof(argv[4]);
  min_y = atof(argv[5]);
  max_y = atof(argv[6]);
  double err_best = DBL_MAX;
  int L_best;
  for (int L = 25; L <= 600; L += 25) {
    double err = run(N_X, N_Y, L, min_x, max_x, min_y, max_y, argv[7]);
    if (err == 0) {
      fprintf(stderr, "An error occured\n");
      return 1;
    }
    if (err < err_best) {
      err_best = err;
      L_best = L;
    }
  }
  printf("%f\t\n", err_best);
  return 0;
}


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)
cmpl   $0x8,-0x8(%rbp)
je     1191 <main+0x41>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d4 <main+0x184>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x38(%rbp)
mov    0x2dd8(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x19,-0x48(%rbp)
cmpl   $0x258,-0x48(%rbp)
jg     12bc <main+0x16c>
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0x48(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm3
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rcx
call   1040 <run@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1285 <main+0x135>
jp     1285 <main+0x135>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12d4 <main+0x184>
movsd  -0x50(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12a9 <main+0x159>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x48(%rbp),%eax
mov    %eax,-0x44(%rbp)
jmp    12ae <main+0x15e>
mov    -0x48(%rbp),%eax
add    $0x19,%eax
mov    %eax,-0x48(%rbp)
jmp    1210 <main+0xc0>
movsd  -0x40(%rbp),%xmm0
lea    0xd8c(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x8,%edi
jne    122f <main+0xdf>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x18(%rsp)
mov    0x20(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x28(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x30(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,(%rsp)
mov    0x2e18(%rip),%rax
movsd  (%rax),%xmm1
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm1,0x20(%rsp)
add    $0x19,%ebp
mov    0x38(%rbx),%rcx
mov    %r14d,%edi
mov    %r15d,%esi
mov    %ebp,%edx
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movsd  (%rsp),%xmm3
call   1040 <run@plt>
ucomisd 0xdf7(%rip),%xmm0
jne    120d <main+0xbd>
jnp    1241 <main+0xf1>
minsd  0x20(%rsp),%xmm0
movapd %xmm0,%xmm1
cmp    $0x240,%ebp
jb     11d0 <main+0x80>
lea    0xe36(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
jmp    125b <main+0x10b>
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xdc9(%rip),%rsi
jmp    1251 <main+0x101>
mov    0x2d98(%rip),%rax
mov    (%rax),%edi
lea    0xdf9(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [66 x i8] c"Need 8 arguments: N_X, N_Y, min_x, max_x, min_y, max_y, filename\0A\00"
@DBL_MAX = global double 0.000000e+00
@.str.1 = [18 x i8] c"An error occured\0A\00"
@.str.2 = [5 x i8] c"%f\09\0A\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 double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca i32
%14 = alloca i32
%15 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 8
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %81
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %6
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %7
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 3
%32 = load i8*, i8** %31
%33 = call double @atof(i8* %32)
store double %33, double* %8
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 4
%36 = load i8*, i8** %35
%37 = call double @atof(i8* %36)
store double %37, double* %9
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 5
%40 = load i8*, i8** %39
%41 = call double @atof(i8* %40)
store double %41, double* %10
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 6
%44 = load i8*, i8** %43
%45 = call double @atof(i8* %44)
store double %45, double* %11
%46 = load double, double* @DBL_MAX
store double %46, double* %12
store i32 25, i32* %14
br label %47
47: ; preds = %75, %21
%48 = load i32, i32* %14
%49 = icmp sle i32 %48, 600
br i1 %49, label %50, label %78
50: ; preds = %47
%51 = load i32, i32* %6
%52 = load i32, i32* %7
%53 = load i32, i32* %14
%54 = load double, double* %8
%55 = load double, double* %9
%56 = load double, double* %10
%57 = load double, double* %11
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 7
%60 = load i8*, i8** %59
%61 = call double @run(i32 %51, i32 %52, i32 %53, double %54, double %55, double %56, double %57, i8* %60)
store double %61, double* %15
%62 = load double, double* %15
%63 = fcmp oeq double %62, 0.000000e+00
br i1 %63, label %64, label %67
64: ; preds = %50
%65 = load i32, i32* @stderr
%66 = call i32 @fprintf(i32 %65, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %81
67: ; preds = %50
%68 = load double, double* %15
%69 = load double, double* %12
%70 = fcmp olt double %68, %69
br i1 %70, label %71, label %74
71: ; preds = %67
%72 = load double, double* %15
store double %72, double* %12
%73 = load i32, i32* %14
store i32 %73, i32* %13
br label %74
74: ; preds = %71, %67
br label %75
75: ; preds = %74
%76 = load i32, i32* %14
%77 = add nsw i32 %76, 25
store i32 %77, i32* %14
br label %47
78: ; preds = %47
%79 = load double, double* %12
%80 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %79)
store i32 0, i32* %3
br label %81
81: ; preds = %78, %64, %18
%82 = load i32, i32* %3
ret i32 %82
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [66 x i8] c"Need 8 arguments: N_X, N_Y, min_x, max_x, min_y, max_y, filename\0A\00"
@DBL_MAX = global double 0.000000e+00
@.str.1 = [18 x i8] c"An error occured\0A\00"
@.str.2 = [5 x i8] c"%f\09\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 8
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
br label %44
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = getelementptr inbounds i8*, i8** %1, i64 2
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call double @atof(i8* %15)
%17 = getelementptr inbounds i8*, i8** %1, i64 4
%18 = load i8*, i8** %17
%19 = tail call double @atof(i8* %18)
%20 = getelementptr inbounds i8*, i8** %1, i64 5
%21 = load i8*, i8** %20
%22 = tail call double @atof(i8* %21)
%23 = getelementptr inbounds i8*, i8** %1, i64 6
%24 = load i8*, i8** %23
%25 = tail call double @atof(i8* %24)
%26 = load double, double* @DBL_MAX
%27 = getelementptr inbounds i8*, i8** %1, i64 7
br label %28
28: ; preds = %7, %37
%29 = phi i32 [ 25, %7 ], [ %40, %37 ]
%30 = phi double [ %26, %7 ], [ %39, %37 ]
%31 = load i8*, i8** %27
%32 = tail call double @run(i32 %10, i32 %13, i32 %29, double %16, double %19, double %22, double %25, i8* %31)
%33 = fcmp oeq double %32, 0.000000e+00
br i1 %33, label %34, label %37
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = tail call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %44
37: ; preds = %28
%38 = fcmp olt double %32, %30
%39 = select i1 %38, double %32, double %30
%40 = add nuw nsw i32 %29, 25
%41 = icmp ult i32 %29, 576
br i1 %41, label %28, label %42
42: ; preds = %37
%43 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %39)
br label %44
44: ; preds = %34, %42, %4
%45 = phi i32 [ 1, %4 ], [ 0, %42 ], [ 1, %34 ]
ret i32 %45
}