#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(int);
scalar_t__ fabs(double);
double fmax(double, scalar_t__);
int /*<<< orphan*/ printf(char *, double const);
double sqrt(double const);
void CalcError(double *u, const double t, const double dx, const double dy,
               unsigned int nx, unsigned int ny) {
  unsigned int i, j, o, xy;
  double err = 0., l1_norm = 0., l2_norm = 0., linf_norm = 0.;
  for (j = 0; j < ny; j++) {
    for (i = 0; i < nx; i++) {
      err = ((0.1 / t) * exp(-((-5 + i * dx) * (-5 + i * dx) +
                               (-5 + j * dy) * (-5 + j * dy)) /
                             (4 * 1.0 * t))) -
            u[i];
      l1_norm += fabs(err);
      l2_norm += err * err;
      linf_norm = fmax(linf_norm, fabs(err));
    }
  }
  printf("L1 norm                                       :  %e\n",
         dx * dy * l1_norm);
  printf("L2 norm                                       :  %e\n",
         sqrt(dx * dy * l2_norm));
  printf("Linf norm                                     :  %e\n", linf_norm);
}


x86 assembly (clang, -O0):
<CalcError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %esi,-0x24(%rbp)
mov    %edx,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
jae    130b <CalcError+0x1bb>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jae    12f8 <CalcError+0x1a8>
movsd  -0x10(%rbp),%xmm1
movsd  0xe4c(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
mov    -0x2c(%rbp),%eax
cvtsi2sd %rax,%xmm2
movsd  -0x18(%rbp),%xmm0
mulsd  %xmm0,%xmm2
movsd  0xe22(%rip),%xmm4
addsd  %xmm4,%xmm2
movaps %xmm2,%xmm0
mov    -0x30(%rbp),%eax
cvtsi2sd %rax,%xmm3
movsd  -0x20(%rbp),%xmm5
movaps %xmm3,%xmm1
mulsd  %xmm5,%xmm1
addsd  %xmm4,%xmm1
movsd  -0x20(%rbp),%xmm4
mulsd  %xmm4,%xmm3
movsd  0xdf2(%rip),%xmm4
addsd  %xmm4,%xmm3
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xdbb(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <exp@plt>
movaps %xmm0,%xmm2
movsd  -0x68(%rbp),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x2c(%rbp),%ecx
movsd  (%rax,%rcx,8),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <fabs@plt>
cvtsi2sd %rax,%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x40(%rbp),%xmm0
call   1040 <fabs@plt>
movsd  -0x60(%rbp),%xmm0
mov    %rax,%rdi
call   1060 <fmax@plt>
movsd  %xmm0,-0x58(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ab <CalcError+0x5b>
jmp    12fd <CalcError+0x1ad>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1198 <CalcError+0x48>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
lea    0xcf7(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
call   1070 <sqrt@plt>
lea    0xd0c(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x58(%rbp),%xmm0
lea    0xd30(%rip),%rdi
call   1030 <printf@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CalcError>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movsd  %xmm2,0x28(%rsp)
movapd %xmm0,%xmm2
xorpd  %xmm4,%xmm4
xorps  %xmm8,%xmm8
xorpd  %xmm0,%xmm0
test   %edx,%edx
je     1302 <CalcError+0x1b2>
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%r13
movsd  0xe73(%rip),%xmm5
divsd  %xmm2,%xmm5
mulsd  0xe6f(%rip),%xmm2
mov    %esi,%ebx
xor    %r12d,%r12d
xorpd  %xmm0,%xmm0
movsd  0xe66(%rip),%xmm6
movapd 0xe7e(%rip),%xmm7
xorps  %xmm8,%xmm8
xorpd  %xmm4,%xmm4
xorpd  %xmm3,%xmm3
movsd  %xmm1,0x10(%rsp)
movsd  %xmm2,0x40(%rsp)
movsd  %xmm5,0x38(%rsp)
jmp    1208 <CalcError+0xb8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  0x30(%rsp),%xmm3
addsd  0xe2a(%rip),%xmm3
add    $0x1,%r12d
cmp    %r15d,%r12d
movsd  0x8(%rsp),%xmm8
movsd  0x20(%rsp),%xmm4
je     1302 <CalcError+0x1b2>
test   %r14d,%r14d
movsd  %xmm3,0x30(%rsp)
movsd  %xmm8,0x8(%rsp)
movsd  %xmm4,0x20(%rsp)
je     11e0 <CalcError+0x90>
mulsd  0x28(%rsp),%xmm3
addsd  %xmm6,%xmm3
mulsd  %xmm3,%xmm3
movsd  %xmm3,0x48(%rsp)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm0,0x18(%rsp)
mov    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
mulsd  %xmm1,%xmm0
addsd  %xmm6,%xmm0
mulsd  %xmm0,%xmm0
addsd  0x48(%rsp),%xmm0
xorpd  %xmm7,%xmm0
divsd  %xmm2,%xmm0
cvttsd2si %xmm0,%edi
call   1050 <exp@plt>
mulsd  0x38(%rsp),%xmm0
subsd  0x0(%r13,%rbp,8),%xmm0
movsd  %xmm0,0x50(%rsp)
call   1040 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
movsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x50(%rsp),%xmm0
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
addsd  %xmm2,%xmm1
movsd  %xmm1,0x8(%rsp)
call   1040 <fabs@plt>
movsd  0x18(%rsp),%xmm0
mov    %rax,%rdi
call   1060 <fmax@plt>
movapd 0xd54(%rip),%xmm7
movsd  0xd2c(%rip),%xmm6
movsd  0x40(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1240 <CalcError+0xf0>
jmp    11e0 <CalcError+0x90>
movsd  %xmm8,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
mulsd  0x28(%rsp),%xmm1
movsd  %xmm1,0x10(%rsp)
mulsd  %xmm1,%xmm4
lea    0xd1a(%rip),%rdi
movapd %xmm4,%xmm0
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
ucomisd 0xcdd(%rip),%xmm0
jb     134b <CalcError+0x1fb>
sqrtsd %xmm0,%xmm0
jmp    1350 <CalcError+0x200>
call   1070 <sqrt@plt>
lea    0xd1e(%rip),%rdi
call   1030 <printf@plt>
lea    0xd47(%rip),%rdi
movsd  0x18(%rsp),%xmm0
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [53 x i8] c"L1 norm : %e\0A\00"
@.str.1 = [53 x i8] c"L2 norm : %e\0A\00"
@.str.2 = [53 x i8] c"Linf norm : %e\0A\00"
define void @CalcError(double* %0, double %1, double %2, double %3, i32 %4, i32 %5) {
%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 i32
%17 = alloca double
%18 = alloca double
%19 = alloca double
%20 = alloca double
store double* %0, double** %7
store double %1, double* %8
store double %2, double* %9
store double %3, double* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
store double 0.000000e+00, double* %17
store double 0.000000e+00, double* %18
store double 0.000000e+00, double* %19
store double 0.000000e+00, double* %20
store i32 0, i32* %14
br label %21
21: ; preds = %81, %6
%22 = load i32, i32* %14
%23 = load i32, i32* %12
%24 = icmp ult i32 %22, %23
br i1 %24, label %25, label %84
25: ; preds = %21
store i32 0, i32* %13
br label %26
26: ; preds = %77, %25
%27 = load i32, i32* %13
%28 = load i32, i32* %11
%29 = icmp ult i32 %27, %28
br i1 %29, label %30, label %80
30: ; preds = %26
%31 = load double, double* %8
%32 = fdiv double 1.000000e-01, %31
%33 = load i32, i32* %13
%34 = uitofp i32 %33 to double
%35 = load double, double* %9
%36 = call double @llvm.fmuladd.f64(double %34, double %35, double -5.000000e+00)
%37 = load i32, i32* %13
%38 = uitofp i32 %37 to double
%39 = load double, double* %9
%40 = call double @llvm.fmuladd.f64(double %38, double %39, double -5.000000e+00)
%41 = load i32, i32* %14
%42 = uitofp i32 %41 to double
%43 = load double, double* %10
%44 = call double @llvm.fmuladd.f64(double %42, double %43, double -5.000000e+00)
%45 = load i32, i32* %14
%46 = uitofp i32 %45 to double
%47 = load double, double* %10
%48 = call double @llvm.fmuladd.f64(double %46, double %47, double -5.000000e+00)
%49 = fmul double %44, %48
%50 = call double @llvm.fmuladd.f64(double %36, double %40, double %49)
%51 = fneg double %50
%52 = load double, double* %8
%53 = fmul double 4.000000e+00, %52
%54 = fdiv double %51, %53
%55 = fptosi double %54 to i32
%56 = call double @exp(i32 %55)
%57 = load double*, double** %7
%58 = load i32, i32* %13
%59 = zext i32 %58 to i64
%60 = getelementptr inbounds double, double* %57, i64 %59
%61 = load double, double* %60
%62 = fneg double %61
%63 = call double @llvm.fmuladd.f64(double %32, double %56, double %62)
store double %63, double* %17
%64 = load double, double* %17
%65 = call i64 @fabs(double %64)
%66 = sitofp i64 %65 to double
%67 = load double, double* %18
%68 = fadd double %67, %66
store double %68, double* %18
%69 = load double, double* %17
%70 = load double, double* %17
%71 = load double, double* %19
%72 = call double @llvm.fmuladd.f64(double %69, double %70, double %71)
store double %72, double* %19
%73 = load double, double* %20
%74 = load double, double* %17
%75 = call i64 @fabs(double %74)
%76 = call double @fmax(double %73, i64 %75)
store double %76, double* %20
br label %77
77: ; preds = %30
%78 = load i32, i32* %13
%79 = add i32 %78, 1
store i32 %79, i32* %13
br label %26
80: ; preds = %26
br label %81
81: ; preds = %80
%82 = load i32, i32* %14
%83 = add i32 %82, 1
store i32 %83, i32* %14
br label %21
84: ; preds = %21
%85 = load double, double* %9
%86 = load double, double* %10
%87 = fmul double %85, %86
%88 = load double, double* %18
%89 = fmul double %87, %88
%90 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), double %89)
%91 = load double, double* %9
%92 = load double, double* %10
%93 = fmul double %91, %92
%94 = load double, double* %19
%95 = fmul double %93, %94
%96 = call double @sqrt(double %95)
%97 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), double %96)
%98 = load double, double* %20
%99 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), double %98)
ret void
}

LLVM IR (-O2):
@.str = [53 x i8] c"L1 norm : %e\0A\00"
@.str.1 = [53 x i8] c"L2 norm : %e\0A\00"
@.str.2 = [53 x i8] c"Linf norm : %e\0A\00"
define void @CalcError(double* nocapture %0, double %1, double %2, double %3, i32 %4, i32 %5) {
%7 = icmp eq i32 %5, 0
br i1 %7, label %53, label %8
8: ; preds = %6
%9 = icmp eq i32 %4, 0
%10 = fdiv double 1.000000e-01, %1
%11 = fmul double %1, 4.000000e+00
%12 = zext i32 %4 to i64
br label %13
13: ; preds = %8, %47
%14 = phi double [ 0.000000e+00, %8 ], [ %50, %47 ]
%15 = phi double [ 0.000000e+00, %8 ], [ %49, %47 ]
%16 = phi double [ 0.000000e+00, %8 ], [ %48, %47 ]
%17 = phi i32 [ 0, %8 ], [ %51, %47 ]
br i1 %9, label %47, label %18
18: ; preds = %13
%19 = uitofp i32 %17 to double
%20 = tail call double @llvm.fmuladd.f64(double %19, double %3, double -5.000000e+00)
%21 = fmul double %20, %20
br label %22
22: ; preds = %18, %22
%23 = phi i64 [ 0, %18 ], [ %45, %22 ]
%24 = phi double [ %14, %18 ], [ %44, %22 ]
%25 = phi double [ %15, %18 ], [ %42, %22 ]
%26 = phi double [ %16, %18 ], [ %41, %22 ]
%27 = trunc i64 %23 to i32
%28 = uitofp i32 %27 to double
%29 = tail call double @llvm.fmuladd.f64(double %28, double %2, double -5.000000e+00)
%30 = tail call double @llvm.fmuladd.f64(double %29, double %29, double %21)
%31 = fneg double %30
%32 = fdiv double %31, %11
%33 = fptosi double %32 to i32
%34 = tail call double @exp(i32 %33)
%35 = getelementptr inbounds double, double* %0, i64 %23
%36 = load double, double* %35
%37 = fneg double %36
%38 = tail call double @llvm.fmuladd.f64(double %10, double %34, double %37)
%39 = tail call i64 @fabs(double %38)
%40 = sitofp i64 %39 to double
%41 = fadd double %26, %40
%42 = tail call double @llvm.fmuladd.f64(double %38, double %38, double %25)
%43 = tail call i64 @fabs(double %38)
%44 = tail call double @fmax(double %24, i64 %43)
%45 = add nuw nsw i64 %23, 1
%46 = icmp eq i64 %45, %12
br i1 %46, label %47, label %22
47: ; preds = %22, %13
%48 = phi double [ %16, %13 ], [ %41, %22 ]
%49 = phi double [ %15, %13 ], [ %42, %22 ]
%50 = phi double [ %14, %13 ], [ %44, %22 ]
%51 = add nuw i32 %17, 1
%52 = icmp eq i32 %51, %5
br i1 %52, label %53, label %13
53: ; preds = %47, %6
%54 = phi double [ 0.000000e+00, %6 ], [ %48, %47 ]
%55 = phi double [ 0.000000e+00, %6 ], [ %49, %47 ]
%56 = phi double [ 0.000000e+00, %6 ], [ %50, %47 ]
%57 = fmul double %2, %3
%58 = fmul double %57, %54
%59 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0), double %58)
%60 = fmul double %57, %55
%61 = tail call double @sqrt(double %60)
%62 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), double %61)
%63 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.2, i64 0, i64 0), double %56)
ret void
}