#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 exp(double);
int /*<<< orphan*/ printf(char *, double);
int sqrt(double);
void error_check(int n, double dx, double dy, double *u) {
  int i, j;
  double xx, yy, temp, error;
  double *up = u;
  error = 0.0;
  for (j = 0; j < n; j++) {
    xx = exp(dx * (i - 1));
    for (i = 0; i < n; i++) {
      yy = exp(-2.0 * (dy * (j - 1)));
      temp = *up++ - xx * yy;
      error += temp * temp;
    }
  }
  error = sqrt(error) / (n * n);
  printf("Erro : %g\n", error);
}


x86 assembly (clang, -O0):
<error_check>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rsi,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1243 <error_check+0x113>
movsd  -0x10(%rbp),%xmm0
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1230 <error_check+0x100>
movsd  -0x18(%rbp),%xmm1
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  %xmm0,%xmm1
movsd  0xe49(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <exp@plt>
movsd  %xmm0,-0x38(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x50(%rbp)
movsd  (%rax),%xmm1
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x48(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1190 <error_check+0x60>
jmp    1235 <error_check+0x105>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1160 <error_check+0x30>
movsd  -0x48(%rbp),%xmm0
call   1050 <sqrt@plt>
mov    -0x4(%rbp),%ecx
imul   -0x4(%rbp),%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
lea    0xd9c(%rip),%rdi
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<error_check>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
movsd  %xmm1,0x10(%rsp)
mov    %edi,%r14d
test   %edi,%edi
jle    11f9 <error_check+0xc9>
mov    %rsi,%rbx
lea    -0x1(%r14),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
xor    %r15d,%r15d
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
nop
movsd  0x8(%rsp),%xmm0
call   1040 <exp@plt>
lea    -0x1(%r15),%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0x10(%rsp),%xmm1
mulsd  0xe6c(%rip),%xmm1
movsd  %xmm1,0x18(%rsp)
xorps  0xe6f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
mov    %r14d,%ebp
movsd  (%rsp),%xmm0
xchg   %ax,%ax
movsd  %xmm0,(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <exp@plt>
mulsd  0x20(%rsp),%xmm0
addsd  (%rbx),%xmm0
add    $0x8,%rbx
mulsd  %xmm0,%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0xffffffff,%ebp
jne    11b0 <error_check+0x80>
add    $0x1,%r15d
cmp    %r14d,%r15d
jne    1170 <error_check+0x40>
jmp    1202 <error_check+0xd2>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
call   1050 <sqrt@plt>
imul   %r14d,%r14d
cltd
idiv   %r14d
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
lea    0xdfe(%rip),%rdi
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"Erro : %g\0A\00"
define void @error_check(i32 %0, double %1, double %2, double* %3) {
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double*
store i32 %0, i32* %5
store double %1, double* %6
store double %2, double* %7
store double* %3, double** %8
%16 = load double*, double** %8
store double* %16, double** %15
store double 0.000000e+00, double* %14
store i32 0, i32* %10
br label %17
17: ; preds = %55, %4
%18 = load i32, i32* %10
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %58
21: ; preds = %17
%22 = load double, double* %6
%23 = load i32, i32* %9
%24 = sub nsw i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = fmul double %22, %25
%27 = call double @exp(double %26)
store double %27, double* %11
store i32 0, i32* %9
br label %28
28: ; preds = %51, %21
%29 = load i32, i32* %9
%30 = load i32, i32* %5
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %54
32: ; preds = %28
%33 = load double, double* %7
%34 = load i32, i32* %10
%35 = sub nsw i32 %34, 1
%36 = sitofp i32 %35 to double
%37 = fmul double %33, %36
%38 = fmul double -2.000000e+00, %37
%39 = call double @exp(double %38)
store double %39, double* %12
%40 = load double*, double** %15
%41 = getelementptr inbounds double, double* %40, i32 1
store double* %41, double** %15
%42 = load double, double* %40
%43 = load double, double* %11
%44 = load double, double* %12
%45 = fneg double %43
%46 = call double @llvm.fmuladd.f64(double %45, double %44, double %42)
store double %46, double* %13
%47 = load double, double* %13
%48 = load double, double* %13
%49 = load double, double* %14
%50 = call double @llvm.fmuladd.f64(double %47, double %48, double %49)
store double %50, double* %14
br label %51
51: ; preds = %32
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %28
54: ; preds = %28
br label %55
55: ; preds = %54
%56 = load i32, i32* %10
%57 = add nsw i32 %56, 1
store i32 %57, i32* %10
br label %17
58: ; preds = %17
%59 = load double, double* %14
%60 = call i32 @sqrt(double %59)
%61 = load i32, i32* %5
%62 = load i32, i32* %5
%63 = mul nsw i32 %61, %62
%64 = sdiv i32 %60, %63
%65 = sitofp i32 %64 to double
store double %65, double* %14
%66 = load double, double* %14
%67 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %66)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"Erro : %g\0A\00"
define void @error_check(i32 %0, double %1, double %2, double* nocapture %3) {
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %34
6: ; preds = %4
%7 = add nsw i32 %0, -1
%8 = sitofp i32 %7 to double
%9 = fmul double %8, %1
br label %10
10: ; preds = %31, %6
%11 = phi double* [ %3, %6 ], [ %25, %31 ]
%12 = phi double [ 0.000000e+00, %6 ], [ %28, %31 ]
%13 = phi i32 [ 0, %6 ], [ %32, %31 ]
%14 = tail call double @exp(double %9)
%15 = add nsw i32 %13, -1
%16 = sitofp i32 %15 to double
%17 = fmul double %16, %2
%18 = fmul double %17, -2.000000e+00
%19 = fneg double %14
br label %20
20: ; preds = %10, %20
%21 = phi double* [ %11, %10 ], [ %25, %20 ]
%22 = phi double [ %12, %10 ], [ %28, %20 ]
%23 = phi i32 [ 0, %10 ], [ %29, %20 ]
%24 = tail call double @exp(double %18)
%25 = getelementptr inbounds double, double* %21, i64 1
%26 = load double, double* %21
%27 = tail call double @llvm.fmuladd.f64(double %19, double %24, double %26)
%28 = tail call double @llvm.fmuladd.f64(double %27, double %27, double %22)
%29 = add nuw nsw i32 %23, 1
%30 = icmp eq i32 %29, %0
br i1 %30, label %31, label %20
31: ; preds = %20
%32 = add nuw nsw i32 %13, 1
%33 = icmp eq i32 %32, %0
br i1 %33, label %34, label %10
34: ; preds = %31, %4
%35 = phi double [ 0.000000e+00, %4 ], [ %28, %31 ]
%36 = tail call i32 @sqrt(double %35)
%37 = mul nsw i32 %0, %0
%38 = sdiv i32 %36, %37
%39 = sitofp i32 %38 to double
%40 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), double %39)
ret void
}