#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*/ copy(float **, float **, int, int);
int /*<<< orphan*/ iteration(float **, float **, float **, float **, int, int,
                             float, float, float, float);
int /*<<< orphan*/ liberar(float **, int);
int /*<<< orphan*/ print_matriz(float **, int, int);
float **reserva(int, int);
int /*<<< orphan*/ set_initial(float **, int, int, float, float);
int main() {
  int xpoints = 41;
  int ypoints = 41;
  int ntime = 500;
  float c = 1.0;
  float dx = 2.0 / (xpoints - 1);
  float dy = 2.0 / (ypoints - 1);
  float sigma = 0.0009;
  float nu = 0.01;
  float dt = sigma * dx * dy / nu;
  int i;
  int j;
  float **u;
  float **v;
  float **u_past;
  float **v_past;
  u = reserva(xpoints, ypoints);
  v = reserva(xpoints, ypoints);
  u_past = reserva(xpoints, ypoints);
  v_past = reserva(xpoints, ypoints);
  set_initial(u, xpoints, ypoints, dx, dy);
  set_initial(v, xpoints, ypoints, dx, dy);
  int t;
  for (t = 0; t < ntime; t++) {
    print_matriz(u, xpoints, ypoints);
    print_matriz(v, xpoints, ypoints);
    copy(u, u_past, xpoints, ypoints);
    copy(v, v_past, xpoints, ypoints);
    iteration(u, v, u_past, v_past, xpoints, ypoints, dx, dy, dt, nu);
  }
  liberar(u, xpoints);
  liberar(v, xpoints);
  liberar(u_past, xpoints);
  liberar(v_past, xpoints);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x29,-0x8(%rbp)
movl   $0x29,-0xc(%rbp)
movl   $0x1f4,-0x10(%rbp)
movss  0xe7c(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe6d(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe4e(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xe2d(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xe1c(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
movss  -0x20(%rbp),%xmm0
mulss  -0x18(%rbp),%xmm0
mulss  -0x1c(%rbp),%xmm0
divss  -0x24(%rbp),%xmm0
movss  %xmm0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <reserva@plt>
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <reserva@plt>
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <reserva@plt>
mov    %rax,-0x48(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1080 <reserva@plt>
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
call   1050 <set_initial@plt>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
call   1050 <set_initial@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1306 <main+0x1a6>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1070 <print_matriz@plt>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1070 <print_matriz@plt>
mov    -0x38(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1040 <copy@plt>
mov    -0x40(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
call   1040 <copy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x50(%rbp),%rcx
mov    -0x8(%rbp),%r8d
mov    -0xc(%rbp),%r9d
movss  -0x18(%rbp),%xmm0
movss  -0x1c(%rbp),%xmm1
movss  -0x28(%rbp),%xmm2
movss  -0x24(%rbp),%xmm3
call   1030 <iteration@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1277 <main+0x117>
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <liberar@plt>
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <liberar@plt>
mov    -0x48(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <liberar@plt>
mov    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1060 <liberar@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x29,%edi
mov    $0x29,%esi
call   1080 <reserva@plt>
mov    %rax,%r14
mov    $0x29,%edi
mov    $0x29,%esi
call   1080 <reserva@plt>
mov    %rax,%rbx
mov    $0x29,%edi
mov    $0x29,%esi
call   1080 <reserva@plt>
mov    %rax,%r15
mov    $0x29,%edi
mov    $0x29,%esi
call   1080 <reserva@plt>
mov    %rax,%r12
movss  0xe48(%rip),%xmm0
mov    %r14,%rdi
mov    $0x29,%esi
mov    $0x29,%edx
movaps %xmm0,%xmm1
call   1050 <set_initial@plt>
mov    %rbx,%rdi
mov    $0x29,%esi
mov    $0x29,%edx
movss  0xe1e(%rip),%xmm0
movaps %xmm0,%xmm1
call   1050 <set_initial@plt>
mov    $0x1f4,%ebp
nop
mov    %r14,%rdi
mov    $0x29,%esi
mov    $0x29,%edx
call   1070 <print_matriz@plt>
mov    %rbx,%rdi
mov    $0x29,%esi
mov    $0x29,%edx
call   1070 <print_matriz@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x29,%edx
mov    $0x29,%ecx
call   1040 <copy@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x29,%edx
mov    $0x29,%ecx
call   1040 <copy@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    $0x29,%r8d
mov    $0x29,%r9d
movss  0xda2(%rip),%xmm0
movaps %xmm0,%xmm1
movss  0xd9b(%rip),%xmm2
movss  0xd97(%rip),%xmm3
call   1030 <iteration@plt>
add    $0xffffffff,%ebp
jne    11f0 <main+0x90>
mov    %r14,%rdi
mov    $0x29,%esi
call   1060 <liberar@plt>
mov    %rbx,%rdi
mov    $0x29,%esi
call   1060 <liberar@plt>
mov    %r15,%rdi
mov    $0x29,%esi
call   1060 <liberar@plt>
mov    %r12,%rdi
mov    $0x29,%esi
call   1060 <liberar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca i32
%12 = alloca i32
%13 = alloca float**
%14 = alloca float**
%15 = alloca float**
%16 = alloca float**
%17 = alloca i32
store i32 0, i32* %1
store i32 41, i32* %2
store i32 41, i32* %3
store i32 500, i32* %4
store float 1.000000e+00, float* %5
%18 = load i32, i32* %2
%19 = sub nsw i32 %18, 1
%20 = sitofp i32 %19 to double
%21 = fdiv double 2.000000e+00, %20
%22 = fptrunc double %21 to float
store float %22, float* %6
%23 = load i32, i32* %3
%24 = sub nsw i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = fdiv double 2.000000e+00, %25
%27 = fptrunc double %26 to float
store float %27, float* %7
store float 0x3F4D7DBF40000000, float* %8
store float 0x3F847AE140000000, float* %9
%28 = load float, float* %8
%29 = load float, float* %6
%30 = fmul float %28, %29
%31 = load float, float* %7
%32 = fmul float %30, %31
%33 = load float, float* %9
%34 = fdiv float %32, %33
store float %34, float* %10
%35 = load i32, i32* %2
%36 = load i32, i32* %3
%37 = call float** @reserva(i32 %35, i32 %36)
store float** %37, float*** %13
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = call float** @reserva(i32 %38, i32 %39)
store float** %40, float*** %14
%41 = load i32, i32* %2
%42 = load i32, i32* %3
%43 = call float** @reserva(i32 %41, i32 %42)
store float** %43, float*** %15
%44 = load i32, i32* %2
%45 = load i32, i32* %3
%46 = call float** @reserva(i32 %44, i32 %45)
store float** %46, float*** %16
%47 = load float**, float*** %13
%48 = load i32, i32* %2
%49 = load i32, i32* %3
%50 = load float, float* %6
%51 = load float, float* %7
%52 = call i32 @set_initial(float** %47, i32 %48, i32 %49, float %50, float %51)
%53 = load float**, float*** %14
%54 = load i32, i32* %2
%55 = load i32, i32* %3
%56 = load float, float* %6
%57 = load float, float* %7
%58 = call i32 @set_initial(float** %53, i32 %54, i32 %55, float %56, float %57)
store i32 0, i32* %17
br label %59
59: ; preds = %93, %0
%60 = load i32, i32* %17
%61 = load i32, i32* %4
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %96
63: ; preds = %59
%64 = load float**, float*** %13
%65 = load i32, i32* %2
%66 = load i32, i32* %3
%67 = call i32 @print_matriz(float** %64, i32 %65, i32 %66)
%68 = load float**, float*** %14
%69 = load i32, i32* %2
%70 = load i32, i32* %3
%71 = call i32 @print_matriz(float** %68, i32 %69, i32 %70)
%72 = load float**, float*** %13
%73 = load float**, float*** %15
%74 = load i32, i32* %2
%75 = load i32, i32* %3
%76 = call i32 @copy(float** %72, float** %73, i32 %74, i32 %75)
%77 = load float**, float*** %14
%78 = load float**, float*** %16
%79 = load i32, i32* %2
%80 = load i32, i32* %3
%81 = call i32 @copy(float** %77, float** %78, i32 %79, i32 %80)
%82 = load float**, float*** %13
%83 = load float**, float*** %14
%84 = load float**, float*** %15
%85 = load float**, float*** %16
%86 = load i32, i32* %2
%87 = load i32, i32* %3
%88 = load float, float* %6
%89 = load float, float* %7
%90 = load float, float* %10
%91 = load float, float* %9
%92 = call i32 @iteration(float** %82, float** %83, float** %84, float** %85, i32 %86, i32 %87, float %88, float %89, float %90, float %91)
br label %93
93: ; preds = %63
%94 = load i32, i32* %17
%95 = add nsw i32 %94, 1
store i32 %95, i32* %17
br label %59
96: ; preds = %59
%97 = load float**, float*** %13
%98 = load i32, i32* %2
%99 = call i32 @liberar(float** %97, i32 %98)
%100 = load float**, float*** %14
%101 = load i32, i32* %2
%102 = call i32 @liberar(float** %100, i32 %101)
%103 = load float**, float*** %15
%104 = load i32, i32* %2
%105 = call i32 @liberar(float** %103, i32 %104)
%106 = load float**, float*** %16
%107 = load i32, i32* %2
%108 = call i32 @liberar(float** %106, i32 %107)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call float** @reserva(i32 41, i32 41)
%2 = tail call float** @reserva(i32 41, i32 41)
%3 = tail call float** @reserva(i32 41, i32 41)
%4 = tail call float** @reserva(i32 41, i32 41)
%5 = tail call i32 @set_initial(float** %1, i32 41, i32 41, float 0x3FA99999A0000000, float 0x3FA99999A0000000)
%6 = tail call i32 @set_initial(float** %2, i32 41, i32 41, float 0x3FA99999A0000000, float 0x3FA99999A0000000)
br label %7
7: ; preds = %0, %7
%8 = phi i32 [ 0, %0 ], [ %14, %7 ]
%9 = tail call i32 @print_matriz(float** %1, i32 41, i32 41)
%10 = tail call i32 @print_matriz(float** %2, i32 41, i32 41)
%11 = tail call i32 @copy(float** %1, float** %3, i32 41, i32 41)
%12 = tail call i32 @copy(float** %2, float** %4, i32 41, i32 41)
%13 = tail call i32 @iteration(float** %1, float** %2, float** %3, float** %4, i32 41, i32 41, float 0x3FA99999A0000000, float 0x3FA99999A0000000, float 0x3F2D7DBF60000000, float 0x3F847AE140000000)
%14 = add nuw nsw i32 %8, 1
%15 = icmp eq i32 %14, 500
br i1 %15, label %16, label %7
16: ; preds = %7
%17 = tail call i32 @liberar(float** %1, i32 41)
%18 = tail call i32 @liberar(float** %2, i32 41)
%19 = tail call i32 @liberar(float** %3, i32 41)
%20 = tail call i32 @liberar(float** %4, i32 41)
ret i32 0
}