#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 time_t;

/* Variables and functions */
scalar_t__ CLOCKS_PER_SEC;
int clock();
int /*<<< orphan*/ printf(char *, int);
main() {
  int size_mat = 150;
  int Niter = 1024;
  double u[size_mat][size_mat];
  double dx = 0.1, dy = 0.1, dx2, dy2;
  int i, j, k;
  time_t t1 = clock();
  for (i = 0; i < size_mat; i++) {
    u[i][0] = 1.0;
    for (j = 1; j < size_mat; j++)
      u[i][j] = 0.0;
  }
  dx2 = dx * dx;
  dy2 = dy * dy;
  for (i = 0; i < Niter; i++)
    for (j = 1; j < size_mat - 1; j++)
      for (k = 1; k < size_mat - 1; k++)
        u[j][k] = ((u[j + 1][k] + u[j - 1][k]) * dy2 +
                   (u[j][k + 1] + u[j][k - 1]) * dx2) *
                  (1.0 / (2 * (dx2 + dy2)));
  t1 = clock() - t1;
  printf("c_laplace\t%f ms\n", 1000 * t1 / (double)CLOCKS_PER_SEC);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x96,-0x8(%rbp)
movl   $0x400,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,%rax
mov    %rax,-0x68(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rcx,%rdx
imul   %rdx,%rdx
lea    0xf(,%rdx,8),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x60(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x20(%rbp)
mov    %rax,-0x28(%rbp)
movsd  0xe80(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe73(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    $0x0,%al
call   1030 <clock@plt>
mov    %eax,-0x58(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1223 <main+0x103>
mov    -0x60(%rbp),%rax
mov    -0x68(%rbp),%rdx
movslq -0x4c(%rbp),%rcx
imul   %rdx,%rcx
movsd  0xe41(%rip),%xmm0
movsd  %xmm0,(%rax,%rcx,8)
movl   $0x1,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1210 <main+0xf0>
mov    -0x60(%rbp),%rax
mov    -0x68(%rbp),%rdx
movslq -0x4c(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x50(%rbp),%rcx
xorps  %xmm0,%xmm0
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    11d3 <main+0xb3>
jmp    1215 <main+0xf5>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    11a3 <main+0x83>
movsd  -0x30(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1390 <main+0x270>
movl   $0x1,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    137d <main+0x25d>
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    136a <main+0x24a>
mov    -0x60(%rbp),%rax
mov    -0x68(%rbp),%rdx
mov    -0x50(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rsi
imul   %rdx,%rsi
shl    $0x3,%rsi
mov    %rax,%rcx
add    %rsi,%rcx
movslq -0x54(%rbp),%rsi
movsd  (%rcx,%rsi,8),%xmm0
mov    -0x50(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rsi
imul   %rdx,%rsi
shl    $0x3,%rsi
mov    %rax,%rcx
add    %rsi,%rcx
movslq -0x54(%rbp),%rsi
addsd  (%rcx,%rsi,8),%xmm0
movsd  -0x48(%rbp),%xmm2
movslq -0x50(%rbp),%rsi
imul   %rdx,%rsi
shl    $0x3,%rsi
mov    %rax,%rcx
add    %rsi,%rcx
mov    -0x54(%rbp),%esi
add    $0x1,%esi
movslq %esi,%rsi
movsd  (%rcx,%rsi,8),%xmm1
movslq -0x50(%rbp),%rsi
imul   %rdx,%rsi
shl    $0x3,%rsi
mov    %rax,%rcx
add    %rsi,%rcx
mov    -0x54(%rbp),%esi
sub    $0x1,%esi
movslq %esi,%rsi
addsd  (%rcx,%rsi,8),%xmm1
mulsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
addsd  -0x48(%rbp),%xmm1
movsd  0xce0(%rip),%xmm2
mulsd  %xmm1,%xmm2
movsd  0xccc(%rip),%xmm1
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movslq -0x50(%rbp),%rcx
imul   %rdx,%rcx
shl    $0x3,%rcx
add    %rcx,%rax
movslq -0x54(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1273 <main+0x153>
jmp    136f <main+0x24f>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    125b <main+0x13b>
jmp    1382 <main+0x262>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1248 <main+0x128>
mov    $0x0,%al
call   1030 <clock@plt>
sub    -0x58(%rbp),%eax
mov    %eax,-0x58(%rbp)
imul   $0x3e8,-0x58(%rbp),%eax
cvtsi2sd %eax,%xmm0
mov    0x2c39(%rip),%rax
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xc55(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x2bf28,%rsp
xor    %eax,%eax
call   1030 <clock@plt>
mov    %eax,%r14d
mov    $0x968,%ebp
movabs $0x3ff0000000000000,%r15
cs nopw 0x0(%rax,%rax,1)
lea    (%rsp,%rbp,1),%rbx
lea    (%rsp,%rbp,1),%rdi
add    $0xfffffffffffff6a0,%rdi
mov    %r15,-0x968(%rsp,%rbp,1)
ff
mov    $0x4a8,%edx
xor    %esi,%esi
call   1050 <memset@plt>
lea    (%rsp,%rbp,1),%rdi
add    $0xfffffffffffffb50,%rdi
mov    %r15,-0x4b8(%rsp,%rbp,1)
ff
mov    $0x4a8,%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    %r15,-0x8(%rsp,%rbp,1)
mov    $0x4a8,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
add    $0xe10,%rbp
cmp    $0x2c888,%rbp
jne    1160 <main+0x30>
xor    %eax,%eax
lea    0x970(%rsp),%rcx
movsd  0xe28(%rip),%xmm0
movsd  0xe28(%rip),%xmm1
mov    $0x1,%edx
mov    %rcx,%rsi
nopl   0x0(%rax,%rax,1)
imul   $0x4b0,%rdx,%rdi
add    $0x1,%rdx
movsd  (%rsp,%rdi,1),%xmm2
mov    $0xfffffffffffffb60,%rdi
nopw   0x0(%rax,%rax,1)
movsd  0x498(%rsi,%rdi,1),%xmm3
addsd  -0x4c8(%rsi,%rdi,1),%xmm3
ff ff
addsd  -0x10(%rsi,%rdi,1),%xmm2
movsd  0x4a0(%rsi,%rdi,1),%xmm4
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm3
addsd  %xmm2,%xmm3
mulsd  %xmm1,%xmm3
movsd  %xmm3,-0x18(%rsi,%rdi,1)
addsd  -0x4c0(%rsi,%rdi,1),%xmm4
ff ff
addsd  -0x8(%rsi,%rdi,1),%xmm3
mulsd  %xmm0,%xmm3
mulsd  %xmm0,%xmm4
addsd  %xmm3,%xmm4
mulsd  %xmm1,%xmm4
movsd  %xmm4,-0x10(%rsi,%rdi,1)
movapd %xmm4,%xmm2
add    $0x10,%rdi
jne    1210 <main+0xe0>
add    $0x4b0,%rsi
cmp    $0x95,%rdx
jne    11f0 <main+0xc0>
add    $0x1,%eax
cmp    $0x400,%eax
jne    11e0 <main+0xb0>
xor    %eax,%eax
call   1030 <clock@plt>
sub    %r14d,%eax
imul   $0x3e8,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    0x2d32(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2sdq (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xd43(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x2bf28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [17 x i8] c"c_laplace\09%f ms\0A\00"
@CLOCKS_PER_SEC = global i64 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %1
store i32 150, i32* %2
store i32 1024, i32* %3
%15 = load i32, i32* %2
%16 = zext i32 %15 to i64
%17 = load i32, i32* %2
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %4
%20 = mul nuw i64 %16, %18
%21 = alloca double, i64 %20
store i64 %16, i64* %5
store i64 %18, i64* %6
store double 1.000000e-01, double* %7
store double 1.000000e-01, double* %8
%22 = call i32 (...) @clock()
store i32 %22, i32* %14
store i32 0, i32* %11
br label %23
23: ; preds = %49, %0
%24 = load i32, i32* %11
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %52
27: ; preds = %23
%28 = load i32, i32* %11
%29 = sext i32 %28 to i64
%30 = mul nsw i64 %29, %18
%31 = getelementptr inbounds double, double* %21, i64 %30
%32 = getelementptr inbounds double, double* %31, i64 0
store double 1.000000e+00, double* %32
store i32 1, i32* %12
br label %33
33: ; preds = %45, %27
%34 = load i32, i32* %12
%35 = load i32, i32* %2
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %48
37: ; preds = %33
%38 = load i32, i32* %11
%39 = sext i32 %38 to i64
%40 = mul nsw i64 %39, %18
%41 = getelementptr inbounds double, double* %21, i64 %40
%42 = load i32, i32* %12
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
store double 0.000000e+00, double* %44
br label %45
45: ; preds = %37
%46 = load i32, i32* %12
%47 = add nsw i32 %46, 1
store i32 %47, i32* %12
br label %33
48: ; preds = %33
br label %49
49: ; preds = %48
%50 = load i32, i32* %11
%51 = add nsw i32 %50, 1
store i32 %51, i32* %11
br label %23
52: ; preds = %23
%53 = load double, double* %7
%54 = load double, double* %7
%55 = fmul double %53, %54
store double %55, double* %9
%56 = load double, double* %8
%57 = load double, double* %8
%58 = fmul double %56, %57
store double %58, double* %10
store i32 0, i32* %11
br label %59
59: ; preds = %139, %52
%60 = load i32, i32* %11
%61 = load i32, i32* %3
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %142
63: ; preds = %59
store i32 1, i32* %12
br label %64
64: ; preds = %135, %63
%65 = load i32, i32* %12
%66 = load i32, i32* %2
%67 = sub nsw i32 %66, 1
%68 = icmp slt i32 %65, %67
br i1 %68, label %69, label %138
69: ; preds = %64
store i32 1, i32* %13
br label %70
70: ; preds = %131, %69
%71 = load i32, i32* %13
%72 = load i32, i32* %2
%73 = sub nsw i32 %72, 1
%74 = icmp slt i32 %71, %73
br i1 %74, label %75, label %134
75: ; preds = %70
%76 = load i32, i32* %12
%77 = add nsw i32 %76, 1
%78 = sext i32 %77 to i64
%79 = mul nsw i64 %78, %18
%80 = getelementptr inbounds double, double* %21, i64 %79
%81 = load i32, i32* %13
%82 = sext i32 %81 to i64
%83 = getelementptr inbounds double, double* %80, i64 %82
%84 = load double, double* %83
%85 = load i32, i32* %12
%86 = sub nsw i32 %85, 1
%87 = sext i32 %86 to i64
%88 = mul nsw i64 %87, %18
%89 = getelementptr inbounds double, double* %21, i64 %88
%90 = load i32, i32* %13
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds double, double* %89, i64 %91
%93 = load double, double* %92
%94 = fadd double %84, %93
%95 = load double, double* %10
%96 = load i32, i32* %12
%97 = sext i32 %96 to i64
%98 = mul nsw i64 %97, %18
%99 = getelementptr inbounds double, double* %21, i64 %98
%100 = load i32, i32* %13
%101 = add nsw i32 %100, 1
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds double, double* %99, i64 %102
%104 = load double, double* %103
%105 = load i32, i32* %12
%106 = sext i32 %105 to i64
%107 = mul nsw i64 %106, %18
%108 = getelementptr inbounds double, double* %21, i64 %107
%109 = load i32, i32* %13
%110 = sub nsw i32 %109, 1
%111 = sext i32 %110 to i64
%112 = getelementptr inbounds double, double* %108, i64 %111
%113 = load double, double* %112
%114 = fadd double %104, %113
%115 = load double, double* %9
%116 = fmul double %114, %115
%117 = call double @llvm.fmuladd.f64(double %94, double %95, double %116)
%118 = load double, double* %9
%119 = load double, double* %10
%120 = fadd double %118, %119
%121 = fmul double 2.000000e+00, %120
%122 = fdiv double 1.000000e+00, %121
%123 = fmul double %117, %122
%124 = load i32, i32* %12
%125 = sext i32 %124 to i64
%126 = mul nsw i64 %125, %18
%127 = getelementptr inbounds double, double* %21, i64 %126
%128 = load i32, i32* %13
%129 = sext i32 %128 to i64
%130 = getelementptr inbounds double, double* %127, i64 %129
store double %123, double* %130
br label %131
131: ; preds = %75
%132 = load i32, i32* %13
%133 = add nsw i32 %132, 1
store i32 %133, i32* %13
br label %70
134: ; preds = %70
br label %135
135: ; preds = %134
%136 = load i32, i32* %12
%137 = add nsw i32 %136, 1
store i32 %137, i32* %12
br label %64
138: ; preds = %64
br label %139
139: ; preds = %138
%140 = load i32, i32* %11
%141 = add nsw i32 %140, 1
store i32 %141, i32* %11
br label %59
142: ; preds = %59
%143 = call i32 (...) @clock()
%144 = load i32, i32* %14
%145 = sub nsw i32 %143, %144
store i32 %145, i32* %14
%146 = load i32, i32* %14
%147 = mul nsw i32 1000, %146
%148 = sitofp i32 %147 to double
%149 = load i64, i64* @CLOCKS_PER_SEC
%150 = sitofp i64 %149 to double
%151 = fdiv double %148, %150
%152 = fptosi double %151 to i32
%153 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %152)
%154 = load i8*, i8** %4
%155 = load i32, i32* %1
ret i32 %155
}

LLVM IR (-O2):
@.str = [17 x i8] c"c_laplace\09%f ms\0A\00"
@CLOCKS_PER_SEC = global i64 0
define i32 @main() {
%1 = alloca [22500 x double]
%2 = tail call i32 (...) @clock()
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %22, %3 ]
%5 = mul nuw nsw i64 %4, 150
%6 = or i64 %5, 1
%7 = getelementptr [22500 x double], [22500 x double]* %1, i64 0, i64 %6
%8 = bitcast double* %7 to i8*
%9 = getelementptr inbounds [22500 x double], [22500 x double]* %1, i64 0, i64 %5
store double 1.000000e+00, double* %9
%10 = mul i64 %4, 150
%11 = add i64 %10, 150
%12 = or i64 %11, 1
%13 = getelementptr [22500 x double], [22500 x double]* %1, i64 0, i64 %12
%14 = bitcast double* %13 to i8*
%15 = getelementptr inbounds [22500 x double], [22500 x double]* %1, i64 0, i64 %11
store double 1.000000e+00, double* %15
%16 = mul i64 %4, 150
%17 = add i64 %16, 300
%18 = or i64 %17, 1
%19 = getelementptr [22500 x double], [22500 x double]* %1, i64 0, i64 %18
%20 = bitcast double* %19 to i8*
%21 = getelementptr inbounds [22500 x double], [22500 x double]* %1, i64 0, i64 %17
store double 1.000000e+00, double* %21
%22 = add nuw nsw i64 %4, 3
%23 = icmp eq i64 %22, 150
br i1 %23, label %24, label %3
24: ; preds = %3, %69
%25 = phi i32 [ %70, %69 ], [ 0, %3 ]
br label %26
26: ; preds = %24, %67
%27 = phi i64 [ 1, %24 ], [ %28, %67 ]
%28 = add nuw nsw i64 %27, 1
%29 = mul nuw nsw i64 %28, 150
%30 = getelementptr inbounds [22500 x double], [22500 x double]* %1, i64 0, i64 %29
%31 = mul i64 %27, 150
%32 = add i64 %31, -150
%33 = getelementptr inbounds [22500 x double], [22500 x double]* %1, i64 0, i64 %32
%34 = mul nuw nsw i64 %27, 150
%35 = getelementptr inbounds [22500 x double], [22500 x double]* %1, i64 0, i64 %34
%36 = load double, double* %35
br label %37
37: ; preds = %37, %26
%38 = phi double [ %36, %26 ], [ %64, %37 ]
%39 = phi i64 [ 1, %26 ], [ %58, %37 ]
%40 = getelementptr inbounds double, double* %30, i64 %39
%41 = load double, double* %40
%42 = getelementptr inbounds double, double* %33, i64 %39
%43 = load double, double* %42
%44 = fadd double %41, %43
%45 = add nuw nsw i64 %39, 1
%46 = getelementptr inbounds double, double* %35, i64 %45
%47 = load double, double* %46
%48 = fadd double %47, %38
%49 = fmul double %48, 0x3F847AE147AE147C
%50 = tail call double @llvm.fmuladd.f64(double %44, double 0x3F847AE147AE147C, double %49)
%51 = fmul double %50, 0x4038FFFFFFFFFFFF
%52 = getelementptr inbounds double, double* %35, i64 %39
store double %51, double* %52
%53 = getelementptr inbounds double, double* %30, i64 %45
%54 = load double, double* %53
%55 = getelementptr inbounds double, double* %33, i64 %45
%56 = load double, double* %55
%57 = fadd double %54, %56
%58 = add nuw nsw i64 %39, 2
%59 = getelementptr inbounds double, double* %35, i64 %58
%60 = load double, double* %59
%61 = fadd double %60, %51
%62 = fmul double %61, 0x3F847AE147AE147C
%63 = tail call double @llvm.fmuladd.f64(double %57, double 0x3F847AE147AE147C, double %62)
%64 = fmul double %63, 0x4038FFFFFFFFFFFF
%65 = getelementptr inbounds double, double* %35, i64 %45
store double %64, double* %65
%66 = icmp eq i64 %58, 149
br i1 %66, label %67, label %37
67: ; preds = %37
%68 = icmp eq i64 %28, 149
br i1 %68, label %69, label %26
69: ; preds = %67
%70 = add nuw nsw i32 %25, 1
%71 = icmp eq i32 %70, 1024
br i1 %71, label %72, label %24
72: ; preds = %69
%73 = tail call i32 (...) @clock()
%74 = sub nsw i32 %73, %2
%75 = mul nsw i32 %74, 1000
%76 = sitofp i32 %75 to double
%77 = load i64, i64* @CLOCKS_PER_SEC
%78 = sitofp i64 %77 to double
%79 = fdiv double %76, %78
%80 = fptosi double %79 to i32
%81 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %80)
ret i32 0
}