#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] = 0.1;
  (*grid)[4 * nx * ny + 7 * nx + 7] = -0.1;
  for (k = 0; k < 80; k++) {
    delta = fd_sweep(grid, field, nx, ny, nz, 1.0, 1.0, 1.0);
    if (k == 79) {
      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)
cmpl   $0x50,-0x28(%rbp)
jge    12d4 <main+0x1a4>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x2c(%rbp),%edx
mov    -0x30(%rbp),%ecx
mov    -0x34(%rbp),%r8d
movsd  0xe03(%rip),%xmm2
movaps %xmm2,%xmm0
movaps %xmm2,%xmm1
mov    $0x3,%al
call   1050 <fd_sweep@plt>
movss  %xmm0,-0x1c(%rbp)
cmpl   $0x4f,-0x28(%rbp)
jne    12c1 <main+0x191>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xddf(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    12bc <main+0x18c>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    12a0 <main+0x170>
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    0xd89(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1252 <main+0x122>
lea    0xd6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    123f <main+0x10f>
jmp    12c1 <main+0x191>
jmp    12c6 <main+0x196>
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   $0x3dcccccd,0x6c4(%r14)
cd cc cc 3d
movl   $0xbdcccccd,0x774(%r14)
cd cc cc bd
xor    %r13d,%r13d
lea    0xe83(%rip),%r15
lea    0xe80(%rip),%r12
jmp    119e <main+0x5e>
xchg   %ax,%ax
add    $0x1,%r13d
cmp    $0x50,%r13d
je     12ee <main+0x1ae>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0xa,%r8d
movsd  0xe44(%rip),%xmm0
movaps %xmm0,%xmm1
movaps %xmm0,%xmm2
mov    $0x3,%al
call   1060 <fd_sweep@plt>
cmp    $0x4f,%r13d
jne    1190 <main+0x50>
cvtss2sd %xmm0,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    $0xfffffffffffffff6,%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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    11f0 <main+0xb0>
jmp    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 0x3FB99999A0000000, 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 0xBFB99999A0000000, float* %52
store i32 0, i32* %7
br label %53
53: ; preds = %105, %0
%54 = load i32, i32* %7
%55 = icmp slt i32 %54, 80
br i1 %55, label %56, label %108
56: ; preds = %53
%57 = load [0 x float]*, [0 x float]** %2
%58 = load [0 x float]*, [0 x float]** %3
%59 = load i32, i32* %8
%60 = load i32, i32* %9
%61 = load i32, i32* %10
%62 = 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]* %57, [0 x float]* %58, i32 %59, i32 %60, i32 %61, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00)
store float %62, float* %4
%63 = load i32, i32* %7
%64 = icmp eq i32 %63, 79
br i1 %64, label %65, label %104
65: ; preds = %56
%66 = load float, float* %4
%67 = fpext float %66 to double
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %67)
store i32 0, i32* %5
br label %69
69: ; preds = %100, %65
%70 = load i32, i32* %5
%71 = load i32, i32* %8
%72 = icmp slt i32 %70, %71
br i1 %72, label %73, label %103
73: ; preds = %69
store i32 0, i32* %6
br label %74
74: ; preds = %95, %73
%75 = load i32, i32* %6
%76 = load i32, i32* %9
%77 = icmp slt i32 %75, %76
br i1 %77, label %78, label %98
78: ; preds = %74
%79 = load [0 x float]*, [0 x float]** %3
%80 = load i32, i32* %8
%81 = mul nsw i32 4, %80
%82 = load i32, i32* %9
%83 = mul nsw i32 %81, %82
%84 = load i32, i32* %6
%85 = load i32, i32* %8
%86 = mul nsw i32 %84, %85
%87 = add nsw i32 %83, %86
%88 = load i32, i32* %5
%89 = add nsw i32 %87, %88
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds [0 x float], [0 x float]* %79, i64 0, i64 %90
%92 = load float, float* %91
%93 = fpext float %92 to double
%94 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %93)
br label %95
95: ; preds = %78
%96 = load i32, i32* %6
%97 = add nsw i32 %96, 1
store i32 %97, i32* %6
br label %74
98: ; preds = %74
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %100
100: ; preds = %98
%101 = load i32, i32* %5
%102 = add nsw i32 %101, 1
store i32 %102, i32* %5
br label %69
103: ; preds = %69
br label %104
104: ; preds = %103, %56
br label %105
105: ; preds = %104
%106 = load i32, i32* %7
%107 = add nsw i32 %106, 1
store i32 %107, i32* %7
br label %53
108: ; preds = %53
%109 = load i32, i32* %1
ret i32 %109
}

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