#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*/ add_source(int, float *, float *, float);
int /*<<< orphan*/ advect(int, int /*<<< orphan*/, float *, float *, float *,
                          float *, float *, float);
int /*<<< orphan*/ diffuse(int, int /*<<< orphan*/, float *, float *, float,
                           float);
void get_density(int N, float *density, float *density_prev, float *velocity_u,
                 float *velocity_v, float *velocity_w, float diff, float dt) {
  add_source(N, density, density_prev, dt);
  {
    float *tmp = density_prev;
    density_prev = density;
    density = tmp;
  };
  diffuse(N, 0, density, density_prev, diff, dt);
  {
    float *tmp = density_prev;
    density_prev = density;
    density = tmp;
  };
  advect(N, 0, density, density_prev, velocity_u, velocity_v, velocity_w, dt);
}


x86 assembly (clang, -O0):
<get_density>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movss  %xmm0,-0x34(%rbp)
movss  %xmm1,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
movss  -0x38(%rbp),%xmm0
call   1030 <add_source@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
movss  -0x34(%rbp),%xmm0
movss  -0x38(%rbp),%xmm1
xor    %esi,%esi
call   1050 <diffuse@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%rax
movss  -0x38(%rbp),%xmm0
xor    %esi,%esi
mov    %rax,(%rsp)
call   1040 <advect@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_density>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movss  %xmm1,0x10(%rsp)
movss  %xmm0,0x14(%rsp)
mov    %r9,%r12
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %edi,%ebp
movaps %xmm1,%xmm0
call   1030 <add_source@plt>
mov    %ebp,%edi
xor    %esi,%esi
mov    %r13,%rdx
mov    %rbx,%rcx
movss  0x14(%rsp),%xmm0
movss  0x10(%rsp),%xmm1
call   1050 <diffuse@plt>
mov    %r12,(%rsp)
mov    %ebp,%edi
xor    %esi,%esi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r15,%r8
mov    %r14,%r9
movss  0x10(%rsp),%xmm0
call   1040 <advect@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @get_density(i32 %0, float* %1, float* %2, float* %3, float* %4, float* %5, float %6, float %7) {
%9 = alloca i32
%10 = alloca float*
%11 = alloca float*
%12 = alloca float*
%13 = alloca float*
%14 = alloca float*
%15 = alloca float
%16 = alloca float
%17 = alloca float*
%18 = alloca float*
store i32 %0, i32* %9
store float* %1, float** %10
store float* %2, float** %11
store float* %3, float** %12
store float* %4, float** %13
store float* %5, float** %14
store float %6, float* %15
store float %7, float* %16
%19 = load i32, i32* %9
%20 = load float*, float** %10
%21 = load float*, float** %11
%22 = load float, float* %16
%23 = call i32 @add_source(i32 %19, float* %20, float* %21, float %22)
%24 = load float*, float** %11
store float* %24, float** %17
%25 = load float*, float** %10
store float* %25, float** %11
%26 = load float*, float** %17
store float* %26, float** %10
%27 = load i32, i32* %9
%28 = load float*, float** %10
%29 = load float*, float** %11
%30 = load float, float* %15
%31 = load float, float* %16
%32 = call i32 @diffuse(i32 %27, i32 0, float* %28, float* %29, float %30, float %31)
%33 = load float*, float** %11
store float* %33, float** %18
%34 = load float*, float** %10
store float* %34, float** %11
%35 = load float*, float** %18
store float* %35, float** %10
%36 = load i32, i32* %9
%37 = load float*, float** %10
%38 = load float*, float** %11
%39 = load float*, float** %12
%40 = load float*, float** %13
%41 = load float*, float** %14
%42 = load float, float* %16
%43 = call i32 @advect(i32 %36, i32 0, float* %37, float* %38, float* %39, float* %40, float* %41, float %42)
ret void
}

LLVM IR (-O2):
define void @get_density(i32 %0, float* %1, float* %2, float* %3, float* %4, float* %5, float %6, float %7) {
%9 = tail call i32 @add_source(i32 %0, float* %1, float* %2, float %7)
%10 = tail call i32 @diffuse(i32 %0, i32 0, float* %2, float* %1, float %6, float %7)
%11 = tail call i32 @advect(i32 %0, i32 0, float* %1, float* %2, float* %3, float* %4, float* %5, float %7)
ret void
}