#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 */
float **malloc(int);
int /*<<< orphan*/ printf(char *, ...);
main() {
  float fd_sweep();
  float(*grid)[], (*field)[];
  float delta;
  int i, j, k;
  int nx, ny, nz;
  nx = 10;
  ny = 10;
  nz = 10;
  grid = malloc(nx * ny * nz * sizeof(float));
  field = malloc(nx * ny * nz * sizeof(float));
  (*grid)[4 * nx * ny + 3 * nx + 3] = 1.;
  (*grid)[4 * nx * ny + 7 * nx + 7] = -1.;
  for (k = 0; k < nz; k++) {
    delta = fd_sweep(grid, field, nx, ny, nz, 2.0, 2.0, 2.0);
    printf("%f\n", delta);
    for (i = 0; i < nx; i++) {
      for (j = 0; j < ny; j++) {
        printf("%10.5e ", (*field)[4 * nx * ny + j * nx + i]);
      }
      printf("\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x2c(%rbp)
movl   $0xa,-0x30(%rbp)
movl   $0xa,-0x34(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
imul   -0x34(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x2c(%rbp),%eax
imul   -0x30(%rbp),%eax
imul   -0x34(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x2,%ecx
imul   -0x30(%rbp),%ecx
imul   $0x3,-0x2c(%rbp),%edx
add    %edx,%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
movss  0xe56(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x2,%ecx
imul   -0x30(%rbp),%ecx
imul   $0x7,-0x2c(%rbp),%edx
add    %edx,%ecx
add    $0x7,%ecx
movslq %ecx,%rcx
movss  0xe2b(%rip),%xmm0
movss  %xmm0,(%rax,%rcx,4)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    12c7 <main+0x197>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
movsd  0xe01(%rip),%xmm2
movaps %xmm2,%xmm0
movaps %xmm2,%xmm1
mov    $0x3,%al
call   1050 <fd_sweep@plt>
movss  %xmm0,-0x1c(%rbp)
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde7(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12b4 <main+0x184>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1298 <main+0x168>
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
shl    $0x2,%ecx
imul   -0x30(%rbp),%ecx
mov    -0x24(%rbp),%edx
imul   -0x2c(%rbp),%edx
add    %edx,%ecx
add    -0x20(%rbp),%ecx
movslq %ecx,%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd91(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    124a <main+0x11a>
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1237 <main+0x107>
jmp    12b9 <main+0x189>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11e1 <main+0xb1>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0xfa0,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0xfa0,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
movl   $0x3f800000,0x6c4(%r14)
movl   $0xbf800000,0x774(%r14)
xor    %r13d,%r13d
lea    0xe83(%rip),%r15
lea    0xe80(%rip),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0xa,%r8d
movsd  0xe52(%rip),%xmm0
movaps %xmm0,%xmm1
movaps %xmm0,%xmm2
mov    $0x3,%al
call   1060 <fd_sweep@plt>
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xfffffffffffffff6,%rbp
movss  0x668(%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x690(%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x6b8(%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x6e0(%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x708(%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x730(%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x758(%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x780(%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x7a8(%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0x7d0(%rbx,%rbp,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    %r12,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
inc    %rbp
jne    11d0 <main+0x90>
add    $0x1,%r13d
cmp    $0xa,%r13d
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [8 x i8] c"%10.5e \00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [0 x float]*
%3 = alloca [0 x float]*
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %8
store i32 10, i32* %9
store i32 10, i32* %10
%11 = load i32, i32* %8
%12 = load i32, i32* %9
%13 = mul nsw i32 %11, %12
%14 = load i32, i32* %10
%15 = mul nsw i32 %13, %14
%16 = sext i32 %15 to i64
%17 = mul i64 %16, 4
%18 = trunc i64 %17 to i32
%19 = call float** @malloc(i32 %18)
%20 = bitcast float** %19 to [0 x float]*
store [0 x float]* %20, [0 x float]** %2
%21 = load i32, i32* %8
%22 = load i32, i32* %9
%23 = mul nsw i32 %21, %22
%24 = load i32, i32* %10
%25 = mul nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 4
%28 = trunc i64 %27 to i32
%29 = call float** @malloc(i32 %28)
%30 = bitcast float** %29 to [0 x float]*
store [0 x float]* %30, [0 x float]** %3
%31 = load [0 x float]*, [0 x float]** %2
%32 = load i32, i32* %8
%33 = mul nsw i32 4, %32
%34 = load i32, i32* %9
%35 = mul nsw i32 %33, %34
%36 = load i32, i32* %8
%37 = mul nsw i32 3, %36
%38 = add nsw i32 %35, %37
%39 = add nsw i32 %38, 3
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [0 x float], [0 x float]* %31, i64 0, i64 %40
store float 1.000000e+00, float* %41
%42 = load [0 x float]*, [0 x float]** %2
%43 = load i32, i32* %8
%44 = mul nsw i32 4, %43
%45 = load i32, i32* %9
%46 = mul nsw i32 %44, %45
%47 = load i32, i32* %8
%48 = mul nsw i32 7, %47
%49 = add nsw i32 %46, %48
%50 = add nsw i32 %49, 7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [0 x float], [0 x float]* %42, i64 0, i64 %51
store float -1.000000e+00, float* %52
store i32 0, i32* %7
br label %53
53: ; preds = %102, %0
%54 = load i32, i32* %7
%55 = load i32, i32* %10
%56 = icmp slt i32 %54, %55
br i1 %56, label %57, label %105
57: ; preds = %53
%58 = load [0 x float]*, [0 x float]** %2
%59 = load [0 x float]*, [0 x float]** %3
%60 = load i32, i32* %8
%61 = load i32, i32* %9
%62 = load i32, i32* %10
%63 = call float ([0 x float]*, [0 x float]*, i32, i32, i32, double, double, double, ...) bitcast (float (...)* @fd_sweep to float ([0 x float]*, [0 x float]*, i32, i32, i32, double, double, double, ...)*)([0 x float]* %58, [0 x float]* %59, i32 %60, i32 %61, i32 %62, double 2.000000e+00, double 2.000000e+00, double 2.000000e+00)
store float %63, float* %4
%64 = load float, float* %4
%65 = fpext float %64 to double
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %65)
store i32 0, i32* %5
br label %67
67: ; preds = %98, %57
%68 = load i32, i32* %5
%69 = load i32, i32* %8
%70 = icmp slt i32 %68, %69
br i1 %70, label %71, label %101
71: ; preds = %67
store i32 0, i32* %6
br label %72
72: ; preds = %93, %71
%73 = load i32, i32* %6
%74 = load i32, i32* %9
%75 = icmp slt i32 %73, %74
br i1 %75, label %76, label %96
76: ; preds = %72
%77 = load [0 x float]*, [0 x float]** %3
%78 = load i32, i32* %8
%79 = mul nsw i32 4, %78
%80 = load i32, i32* %9
%81 = mul nsw i32 %79, %80
%82 = load i32, i32* %6
%83 = load i32, i32* %8
%84 = mul nsw i32 %82, %83
%85 = add nsw i32 %81, %84
%86 = load i32, i32* %5
%87 = add nsw i32 %85, %86
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [0 x float], [0 x float]* %77, i64 0, i64 %88
%90 = load float, float* %89
%91 = fpext float %90 to double
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %91)
br label %93
93: ; preds = %76
%94 = load i32, i32* %6
%95 = add nsw i32 %94, 1
store i32 %95, i32* %6
br label %72
96: ; preds = %72
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %98
98: ; preds = %96
%99 = load i32, i32* %5
%100 = add nsw i32 %99, 1
store i32 %100, i32* %5
br label %67
101: ; preds = %67
br label %102
102: ; preds = %101
%103 = load i32, i32* %7
%104 = add nsw i32 %103, 1
store i32 %104, i32* %7
br label %53
105: ; preds = %53
%106 = load i32, i32* %1
ret i32 %106
}

LLVM IR (-O2):
@.str = [4 x i8] c"%f\0A\00"
@.str.1 = [8 x i8] c"%10.5e \00"
define i32 @main() {
%1 = tail call float** @malloc(i32 4000)
%2 = bitcast float** %1 to [0 x float]*
%3 = tail call float** @malloc(i32 4000)
%4 = bitcast float** %3 to [0 x float]*
%5 = getelementptr inbounds [0 x float], [0 x float]* %2, i64 0, i64 433
store float 1.000000e+00, float* %5
%6 = getelementptr inbounds [0 x float], [0 x float]* %2, i64 0, i64 477
store float -1.000000e+00, float* %6
br label %7
7: ; preds = %0, %67
%8 = phi i32 [ 0, %0 ], [ %68, %67 ]
%9 = tail call float ([0 x float]*, [0 x float]*, i32, i32, i32, double, double, double, ...) bitcast (float (...)* @fd_sweep to float ([0 x float]*, [0 x float]*, i32, i32, i32, double, double, double, ...)*)([0 x float]* %2, [0 x float]* %4, i32 10, i32 10, i32 10, double 2.000000e+00, double 2.000000e+00, double 2.000000e+00)
%10 = fpext float %9 to double
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %10)
br label %12
12: ; preds = %7, %12
%13 = phi i64 [ 0, %7 ], [ %65, %12 ]
%14 = add nuw nsw i64 %13, 400
%15 = getelementptr inbounds [0 x float], [0 x float]* %4, i64 0, i64 %14
%16 = load float, float* %15
%17 = fpext float %16 to double
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %17)
%19 = add nuw nsw i64 %13, 410
%20 = getelementptr inbounds [0 x float], [0 x float]* %4, i64 0, i64 %19
%21 = load float, float* %20
%22 = fpext float %21 to double
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %22)
%24 = add nuw nsw i64 %13, 420
%25 = getelementptr inbounds [0 x float], [0 x float]* %4, i64 0, i64 %24
%26 = load float, float* %25
%27 = fpext float %26 to double
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %27)
%29 = add nuw nsw i64 %13, 430
%30 = getelementptr inbounds [0 x float], [0 x float]* %4, i64 0, i64 %29
%31 = load float, float* %30
%32 = fpext float %31 to double
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %32)
%34 = add nuw nsw i64 %13, 440
%35 = getelementptr inbounds [0 x float], [0 x float]* %4, i64 0, i64 %34
%36 = load float, float* %35
%37 = fpext float %36 to double
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %37)
%39 = add nuw nsw i64 %13, 450
%40 = getelementptr inbounds [0 x float], [0 x float]* %4, i64 0, i64 %39
%41 = load float, float* %40
%42 = fpext float %41 to double
%43 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %42)
%44 = add nuw nsw i64 %13, 460
%45 = getelementptr inbounds [0 x float], [0 x float]* %4, i64 0, i64 %44
%46 = load float, float* %45
%47 = fpext float %46 to double
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %47)
%49 = add nuw nsw i64 %13, 470
%50 = getelementptr inbounds [0 x float], [0 x float]* %4, i64 0, i64 %49
%51 = load float, float* %50
%52 = fpext float %51 to double
%53 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %52)
%54 = add nuw nsw i64 %13, 480
%55 = getelementptr inbounds [0 x float], [0 x float]* %4, i64 0, i64 %54
%56 = load float, float* %55
%57 = fpext float %56 to double
%58 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %57)
%59 = add nuw nsw i64 %13, 490
%60 = getelementptr inbounds [0 x float], [0 x float]* %4, i64 0, i64 %59
%61 = load float, float* %60
%62 = fpext float %61 to double
%63 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %62)
%64 = tail call i32 @putchar(i32 10)
%65 = add nuw nsw i64 %13, 1
%66 = icmp eq i64 %65, 10
br i1 %66, label %67, label %12
67: ; preds = %12
%68 = add nuw nsw i32 %8, 1
%69 = icmp eq i32 %68, 10
br i1 %69, label %70, label %7
70: ; preds = %67
ret i32 0
}