#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*/ aan_ecuacion_calor_metodo_explicito_canal(float *, float *,
                                                             int, int, float);
int /*<<< orphan*/ free(float *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(float *, float *, int);
void aan_ecuacion_calor_metodo_explicito(float *red_input, float *green_input,
                                         float *blue_input, float *red_output,
                                         float *green_output,
                                         float *blue_output, int width,
                                         int height, float dt, int Niter) {
  int i;
  float *red_tmp = (float *)malloc(sizeof(float) * width * height);
  float *green_tmp = (float *)malloc(sizeof(float) * width * height);
  float *blue_tmp = (float *)malloc(sizeof(float) * width * height);
  memcpy(red_tmp, red_input, sizeof(float) * width * height);
  memcpy(green_tmp, green_input, sizeof(float) * width * height);
  memcpy(blue_tmp, blue_input, sizeof(float) * width * height);
  for (i = 0; i < Niter; i++) {
    aan_ecuacion_calor_metodo_explicito_canal(red_input, red_output, width,
                                              height, dt);
    aan_ecuacion_calor_metodo_explicito_canal(green_input, green_output, width,
                                              height, dt);
    aan_ecuacion_calor_metodo_explicito_canal(blue_input, blue_output, width,
                                              height, dt);
    memcpy(red_tmp, red_output, sizeof(float) * width * height);
    memcpy(green_tmp, green_output, sizeof(float) * width * height);
    memcpy(blue_tmp, blue_output, sizeof(float) * width * height);
  }
  free(red_tmp);
  free(green_tmp);
  free(blue_tmp);
}


x86 assembly (clang, -O0):
<aan_ecuacion_calor_metodo_explicito>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%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)
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
movslq 0x18(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x40(%rbp)
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
movslq 0x18(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x48(%rbp)
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
movslq 0x18(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
movslq 0x18(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
movslq 0x18(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x50(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
movslq 0x18(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
cmp    0x20(%rbp),%eax
jge    12e2 <aan_ecuacion_calor_metodo_explicito+0x1a2>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%ecx
movss  -0x34(%rbp),%xmm0
call   1060 <aan_ecuacion_calor_metodo_explicito_canal@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%ecx
movss  -0x34(%rbp),%xmm0
call   1060 <aan_ecuacion_calor_metodo_explicito_canal@plt>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%ecx
movss  -0x34(%rbp),%xmm0
call   1060 <aan_ecuacion_calor_metodo_explicito_canal@plt>
mov    -0x40(%rbp),%rdi
mov    -0x20(%rbp),%rsi
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
movslq 0x18(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x48(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
movslq 0x18(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x50(%rbp),%rdi
mov    -0x30(%rbp),%rsi
movslq 0x10(%rbp),%rax
shl    $0x2,%rax
movslq 0x18(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%edx
call   1040 <memcpy@plt>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1223 <aan_ecuacion_calor_metodo_explicito+0xe3>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<aan_ecuacion_calor_metodo_explicito>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movss  %xmm0,0x4(%rsp)
mov    %r9,0x50(%rsp)
mov    %r8,0x48(%rsp)
mov    %rcx,%r14
mov    %rdx,0x30(%rsp)
mov    %rsi,0x38(%rsp)
mov    %rdi,%r13
mov    0xa0(%rsp),%ebp
mov    0x98(%rsp),%eax
mov    0x90(%rsp),%r12d
mov    %r12d,0x14(%rsp)
mov    %eax,0x18(%rsp)
imul   %eax,%r12d
shl    $0x2,%r12d
mov    %r12d,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %r12d,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    %r12d,%edi
call   1050 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    %rbx,0x28(%rsp)
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
call   1040 <memcpy@plt>
mov    %r15,0x20(%rsp)
mov    %r15,%rdi
mov    0x38(%rsp),%rsi
mov    %rsi,%rbx
mov    %r12d,%edx
call   1040 <memcpy@plt>
mov    0x8(%rsp),%rdi
mov    0x30(%rsp),%rsi
mov    %rsi,%r15
mov    %r12d,%edx
call   1040 <memcpy@plt>
test   %ebp,%ebp
jle    12bd <aan_ecuacion_calor_metodo_explicito+0x17d>
mov    %r13,0x40(%rsp)
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,0x1c(%rsp)
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r12d,%ebp
mov    0x14(%rsp),%r12d
mov    %r12d,%edx
mov    0x18(%rsp),%r13d
mov    %r13d,%ecx
movss  0x4(%rsp),%xmm0
call   1060 <aan_ecuacion_calor_metodo_explicito_canal@plt>
mov    %rbx,%rdi
mov    0x48(%rsp),%rbx
mov    %rbx,%rsi
mov    %r12d,%edx
mov    %r13d,%ecx
movss  0x4(%rsp),%xmm0
call   1060 <aan_ecuacion_calor_metodo_explicito_canal@plt>
mov    %r15,%rdi
mov    0x50(%rsp),%r15
mov    %r15,%rsi
mov    %r12d,%edx
mov    %ebp,%r12d
mov    %r13d,%ecx
movss  0x4(%rsp),%xmm0
call   1060 <aan_ecuacion_calor_metodo_explicito_canal@plt>
mov    0x28(%rsp),%rdi
mov    %r14,%rsi
mov    %ebp,%edx
call   1040 <memcpy@plt>
mov    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <memcpy@plt>
mov    0x8(%rsp),%rdi
mov    %r15,%rsi
mov    0x30(%rsp),%r15
mov    0x38(%rsp),%rbx
mov    0x40(%rsp),%r13
mov    0x1c(%rsp),%ebp
mov    %r12d,%edx
call   1040 <memcpy@plt>
add    $0xffffffff,%ebp
jne    1210 <aan_ecuacion_calor_metodo_explicito+0xd0>
mov    0x28(%rsp),%rdi
call   1030 <free@plt>
mov    0x20(%rsp),%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @aan_ecuacion_calor_metodo_explicito(float* %0, float* %1, float* %2, float* %3, float* %4, float* %5, i32 %6, i32 %7, float %8, i32 %9) {
%11 = alloca float*
%12 = alloca float*
%13 = alloca float*
%14 = alloca float*
%15 = alloca float*
%16 = alloca float*
%17 = alloca i32
%18 = alloca i32
%19 = alloca float
%20 = alloca i32
%21 = alloca i32
%22 = alloca float*
%23 = alloca float*
%24 = alloca float*
store float* %0, float** %11
store float* %1, float** %12
store float* %2, float** %13
store float* %3, float** %14
store float* %4, float** %15
store float* %5, float** %16
store i32 %6, i32* %17
store i32 %7, i32* %18
store float %8, float* %19
store i32 %9, i32* %20
%25 = load i32, i32* %17
%26 = sext i32 %25 to i64
%27 = mul i64 4, %26
%28 = load i32, i32* %18
%29 = sext i32 %28 to i64
%30 = mul i64 %27, %29
%31 = trunc i64 %30 to i32
%32 = call i64 @malloc(i32 %31)
%33 = inttoptr i64 %32 to float*
store float* %33, float** %22
%34 = load i32, i32* %17
%35 = sext i32 %34 to i64
%36 = mul i64 4, %35
%37 = load i32, i32* %18
%38 = sext i32 %37 to i64
%39 = mul i64 %36, %38
%40 = trunc i64 %39 to i32
%41 = call i64 @malloc(i32 %40)
%42 = inttoptr i64 %41 to float*
store float* %42, float** %23
%43 = load i32, i32* %17
%44 = sext i32 %43 to i64
%45 = mul i64 4, %44
%46 = load i32, i32* %18
%47 = sext i32 %46 to i64
%48 = mul i64 %45, %47
%49 = trunc i64 %48 to i32
%50 = call i64 @malloc(i32 %49)
%51 = inttoptr i64 %50 to float*
store float* %51, float** %24
%52 = load float*, float** %22
%53 = load float*, float** %11
%54 = load i32, i32* %17
%55 = sext i32 %54 to i64
%56 = mul i64 4, %55
%57 = load i32, i32* %18
%58 = sext i32 %57 to i64
%59 = mul i64 %56, %58
%60 = trunc i64 %59 to i32
%61 = call i32 @memcpy(float* %52, float* %53, i32 %60)
%62 = load float*, float** %23
%63 = load float*, float** %12
%64 = load i32, i32* %17
%65 = sext i32 %64 to i64
%66 = mul i64 4, %65
%67 = load i32, i32* %18
%68 = sext i32 %67 to i64
%69 = mul i64 %66, %68
%70 = trunc i64 %69 to i32
%71 = call i32 @memcpy(float* %62, float* %63, i32 %70)
%72 = load float*, float** %24
%73 = load float*, float** %13
%74 = load i32, i32* %17
%75 = sext i32 %74 to i64
%76 = mul i64 4, %75
%77 = load i32, i32* %18
%78 = sext i32 %77 to i64
%79 = mul i64 %76, %78
%80 = trunc i64 %79 to i32
%81 = call i32 @memcpy(float* %72, float* %73, i32 %80)
store i32 0, i32* %21
br label %82
82: ; preds = %135, %10
%83 = load i32, i32* %21
%84 = load i32, i32* %20
%85 = icmp slt i32 %83, %84
br i1 %85, label %86, label %138
86: ; preds = %82
%87 = load float*, float** %11
%88 = load float*, float** %14
%89 = load i32, i32* %17
%90 = load i32, i32* %18
%91 = load float, float* %19
%92 = call i32 @aan_ecuacion_calor_metodo_explicito_canal(float* %87, float* %88, i32 %89, i32 %90, float %91)
%93 = load float*, float** %12
%94 = load float*, float** %15
%95 = load i32, i32* %17
%96 = load i32, i32* %18
%97 = load float, float* %19
%98 = call i32 @aan_ecuacion_calor_metodo_explicito_canal(float* %93, float* %94, i32 %95, i32 %96, float %97)
%99 = load float*, float** %13
%100 = load float*, float** %16
%101 = load i32, i32* %17
%102 = load i32, i32* %18
%103 = load float, float* %19
%104 = call i32 @aan_ecuacion_calor_metodo_explicito_canal(float* %99, float* %100, i32 %101, i32 %102, float %103)
%105 = load float*, float** %22
%106 = load float*, float** %14
%107 = load i32, i32* %17
%108 = sext i32 %107 to i64
%109 = mul i64 4, %108
%110 = load i32, i32* %18
%111 = sext i32 %110 to i64
%112 = mul i64 %109, %111
%113 = trunc i64 %112 to i32
%114 = call i32 @memcpy(float* %105, float* %106, i32 %113)
%115 = load float*, float** %23
%116 = load float*, float** %15
%117 = load i32, i32* %17
%118 = sext i32 %117 to i64
%119 = mul i64 4, %118
%120 = load i32, i32* %18
%121 = sext i32 %120 to i64
%122 = mul i64 %119, %121
%123 = trunc i64 %122 to i32
%124 = call i32 @memcpy(float* %115, float* %116, i32 %123)
%125 = load float*, float** %24
%126 = load float*, float** %16
%127 = load i32, i32* %17
%128 = sext i32 %127 to i64
%129 = mul i64 4, %128
%130 = load i32, i32* %18
%131 = sext i32 %130 to i64
%132 = mul i64 %129, %131
%133 = trunc i64 %132 to i32
%134 = call i32 @memcpy(float* %125, float* %126, i32 %133)
br label %135
135: ; preds = %86
%136 = load i32, i32* %21
%137 = add nsw i32 %136, 1
store i32 %137, i32* %21
br label %82
138: ; preds = %82
%139 = load float*, float** %22
%140 = call i32 @free(float* %139)
%141 = load float*, float** %23
%142 = call i32 @free(float* %141)
%143 = load float*, float** %24
%144 = call i32 @free(float* %143)
ret void
}

LLVM IR (-O2):
define void @aan_ecuacion_calor_metodo_explicito(float* %0, float* %1, float* %2, float* %3, float* %4, float* %5, i32 %6, i32 %7, float %8, i32 %9) {
%11 = shl i32 %6, 2
%12 = mul i32 %11, %7
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to float*
%15 = tail call i64 @malloc(i32 %12)
%16 = inttoptr i64 %15 to float*
%17 = tail call i64 @malloc(i32 %12)
%18 = inttoptr i64 %17 to float*
%19 = tail call i32 @memcpy(float* %14, float* %0, i32 %12)
%20 = tail call i32 @memcpy(float* %16, float* %1, i32 %12)
%21 = tail call i32 @memcpy(float* %18, float* %2, i32 %12)
%22 = icmp sgt i32 %9, 0
br i1 %22, label %23, label %33
23: ; preds = %10, %23
%24 = phi i32 [ %31, %23 ], [ 0, %10 ]
%25 = tail call i32 @aan_ecuacion_calor_metodo_explicito_canal(float* %0, float* %3, i32 %6, i32 %7, float %8)
%26 = tail call i32 @aan_ecuacion_calor_metodo_explicito_canal(float* %1, float* %4, i32 %6, i32 %7, float %8)
%27 = tail call i32 @aan_ecuacion_calor_metodo_explicito_canal(float* %2, float* %5, i32 %6, i32 %7, float %8)
%28 = tail call i32 @memcpy(float* %14, float* %3, i32 %12)
%29 = tail call i32 @memcpy(float* %16, float* %4, i32 %12)
%30 = tail call i32 @memcpy(float* %18, float* %5, i32 %12)
%31 = add nuw nsw i32 %24, 1
%32 = icmp eq i32 %31, %9
br i1 %32, label %33, label %23
33: ; preds = %23, %10
%34 = tail call i32 @free(float* %14)
%35 = tail call i32 @free(float* %16)
%36 = tail call i32 @free(float* %18)
ret void
}