#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 */
int /*<<< orphan*/ computeDensity(double *, double *);
int /*<<< orphan*/ computeFeq(double *, double *, double *);
int /*<<< orphan*/
computePostCollisionDistributions(double *, double const *const, double *);
int /*<<< orphan*/ computeVelocity(double *, double *, double *);
double *getEl(double *, int, int, int, int /*<<< orphan*/, int);
void doCollision(double *collideField, int *flagField, const double *const tau,
                 int xlength) {
  double density;
  double velocity[3];
  double feq[19];
  double *currentCell;
  int x, y, z;
  int n = xlength + 2;
  for (z = 1; z <= xlength; z++) {
    for (y = 1; y <= xlength; y++) {
      for (x = 1; x <= xlength; x++) {
        currentCell = getEl(collideField, x, y, z, 0, n);
        computeDensity(currentCell, &density);
        computeVelocity(currentCell, &density, velocity);
        computeFeq(&density, velocity, feq);
        computePostCollisionDistributions(currentCell, tau, feq);
      }
    }
  }
}


x86 assembly (clang, -O0):
<doCollision>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xf8(%rbp)
movl   $0x1,-0xf4(%rbp)
mov    -0xf4(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1282 <doCollision+0x132>
movl   $0x1,-0xf0(%rbp)
mov    -0xf0(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1269 <doCollision+0x119>
movl   $0x1,-0xec(%rbp)
mov    -0xec(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     1250 <doCollision+0x100>
mov    -0x8(%rbp),%rdi
mov    -0xec(%rbp),%esi
mov    -0xf0(%rbp),%edx
mov    -0xf4(%rbp),%ecx
mov    -0xf8(%rbp),%r9d
xor    %r8d,%r8d
call   1060 <getEl@plt>
mov    %rax,-0xe8(%rbp)
mov    -0xe8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <computeDensity@plt>
mov    -0xe8(%rbp),%rdi
lea    -0x40(%rbp),%rdx
lea    -0x28(%rbp),%rsi
call   1030 <computeVelocity@plt>
lea    -0x40(%rbp),%rsi
lea    -0xe0(%rbp),%rdx
lea    -0x28(%rbp),%rdi
call   1070 <computeFeq@plt>
mov    -0xe8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0xe0(%rbp),%rdx
call   1050 <computePostCollisionDistributions@plt>
mov    -0xec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xec(%rbp)
jmp    11b2 <doCollision+0x62>
jmp    1255 <doCollision+0x105>
mov    -0xf0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf0(%rbp)
jmp    1199 <doCollision+0x49>
jmp    126e <doCollision+0x11e>
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    1180 <doCollision+0x30>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<doCollision>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xf8,%rsp
mov    %rcx,0x8(%rsp)
test   %ecx,%ecx
jle    125e <doCollision+0x10e>
mov    %rdx,%r14
mov    0x8(%rsp),%rax
lea    0x2(%rax),%r12d
mov    %eax,%esi
neg    %esi
mov    $0x1,%ecx
lea    0x60(%rsp),%rbp
mov    %rsi,0x28(%rsp)
mov    %rdi,0x20(%rsp)
mov    %rdx,0x18(%rsp)
nopw   0x0(%rax,%rax,1)
mov    $0x1,%edx
mov    %rcx,0x10(%rsp)
nopw   0x0(%rax,%rax,1)
mov    $0x1,%r13d
mov    %rdx,0x30(%rsp)
nopl   0x0(%rax,%rax,1)
mov    0x20(%rsp),%rdi
mov    %r13d,%esi
mov    0x10(%rsp),%rcx
xor    %r8d,%r8d
mov    %r12d,%r9d
call   1060 <getEl@plt>
mov    %rax,%rbx
mov    %rax,%rdi
lea    0x38(%rsp),%r15
mov    %r15,%rsi
call   1040 <computeDensity@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
lea    0x40(%rsp),%r14
mov    %r14,%rdx
call   1030 <computeVelocity@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1070 <computeFeq@plt>
mov    %rbx,%rdi
mov    0x18(%rsp),%rsi
mov    %rbp,%rdx
call   1050 <computePostCollisionDistributions@plt>
mov    0x30(%rsp),%rdx
mov    0x28(%rsp),%rsi
lea    (%rsi,%r13,1),%eax
add    $0x1,%eax
mov    %r13d,%ecx
add    $0x1,%ecx
mov    %ecx,%r13d
mov    0x10(%rsp),%rcx
cmp    $0x1,%eax
jne    11c0 <doCollision+0x70>
lea    0x1(%rdx),%eax
cmp    0x8(%rsp),%edx
mov    %eax,%edx
jne    11b0 <doCollision+0x60>
lea    0x1(%rcx),%eax
cmp    0x8(%rsp),%ecx
mov    %eax,%ecx
jne    11a0 <doCollision+0x50>
add    $0xf8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @doCollision(double* %0, i32* %1, double* %2, i32 %3) {
%5 = alloca double*
%6 = alloca i32*
%7 = alloca double*
%8 = alloca i32
%9 = alloca double
%10 = alloca [3 x double]
%11 = alloca [19 x double]
%12 = alloca double*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store double* %0, double** %5
store i32* %1, i32** %6
store double* %2, double** %7
store i32 %3, i32* %8
%17 = load i32, i32* %8
%18 = add nsw i32 %17, 2
store i32 %18, i32* %16
store i32 1, i32* %15
br label %19
19: ; preds = %60, %4
%20 = load i32, i32* %15
%21 = load i32, i32* %8
%22 = icmp sle i32 %20, %21
br i1 %22, label %23, label %63
23: ; preds = %19
store i32 1, i32* %14
br label %24
24: ; preds = %56, %23
%25 = load i32, i32* %14
%26 = load i32, i32* %8
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %59
28: ; preds = %24
store i32 1, i32* %13
br label %29
29: ; preds = %52, %28
%30 = load i32, i32* %13
%31 = load i32, i32* %8
%32 = icmp sle i32 %30, %31
br i1 %32, label %33, label %55
33: ; preds = %29
%34 = load double*, double** %5
%35 = load i32, i32* %13
%36 = load i32, i32* %14
%37 = load i32, i32* %15
%38 = load i32, i32* %16
%39 = call double* @getEl(double* %34, i32 %35, i32 %36, i32 %37, i32 0, i32 %38)
store double* %39, double** %12
%40 = load double*, double** %12
%41 = call i32 @computeDensity(double* %40, double* %9)
%42 = load double*, double** %12
%43 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%44 = call i32 @computeVelocity(double* %42, double* %9, double* %43)
%45 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%46 = getelementptr inbounds [19 x double], [19 x double]* %11, i64 0, i64 0
%47 = call i32 @computeFeq(double* %9, double* %45, double* %46)
%48 = load double*, double** %12
%49 = load double*, double** %7
%50 = getelementptr inbounds [19 x double], [19 x double]* %11, i64 0, i64 0
%51 = call i32 @computePostCollisionDistributions(double* %48, double* %49, double* %50)
br label %52
52: ; preds = %33
%53 = load i32, i32* %13
%54 = add nsw i32 %53, 1
store i32 %54, i32* %13
br label %29
55: ; preds = %29
br label %56
56: ; preds = %55
%57 = load i32, i32* %14
%58 = add nsw i32 %57, 1
store i32 %58, i32* %14
br label %24
59: ; preds = %24
br label %60
60: ; preds = %59
%61 = load i32, i32* %15
%62 = add nsw i32 %61, 1
store i32 %62, i32* %15
br label %19
63: ; preds = %19
ret void
}

LLVM IR (-O2):
define void @doCollision(double* %0, i32* nocapture readnone %1, double* %2, i32 %3) {
%5 = alloca double
%6 = alloca [3 x double]
%7 = alloca [19 x double]
%8 = bitcast double* %5 to i8*
%9 = bitcast [3 x double]* %6 to i8*
%10 = bitcast [19 x double]* %7 to i8*
%11 = add nsw i32 %3, 2
%12 = icmp slt i32 %3, 1
br i1 %12, label %35, label %13
13: ; preds = %4
%14 = getelementptr inbounds [3 x double], [3 x double]* %6, i64 0, i64 0
%15 = getelementptr inbounds [19 x double], [19 x double]* %7, i64 0, i64 0
br label %16
16: ; preds = %32, %13
%17 = phi i32 [ 1, %13 ], [ %33, %32 ]
br label %18
18: ; preds = %29, %16
%19 = phi i32 [ %30, %29 ], [ 1, %16 ]
br label %20
20: ; preds = %18, %20
%21 = phi i32 [ %27, %20 ], [ 1, %18 ]
%22 = call double* @getEl(double* %0, i32 %21, i32 %19, i32 %17, i32 0, i32 %11)
%23 = call i32 @computeDensity(double* %22, double* %5)
%24 = call i32 @computeVelocity(double* %22, double* %5, double* %14)
%25 = call i32 @computeFeq(double* %5, double* %14, double* %15)
%26 = call i32 @computePostCollisionDistributions(double* %22, double* %2, double* %15)
%27 = add nuw i32 %21, 1
%28 = icmp eq i32 %21, %3
br i1 %28, label %29, label %20
29: ; preds = %20
%30 = add nuw i32 %19, 1
%31 = icmp eq i32 %19, %3
br i1 %31, label %32, label %18
32: ; preds = %29
%33 = add nuw i32 %17, 1
%34 = icmp eq i32 %17, %3
br i1 %34, label %35, label %16
35: ; preds = %32, %4
ret void
}