#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 */
double transition(int *, double *, int, int, int);
void evolve(int *B, double *Tin, double *Tout, int nx, int ny) {
  int i = 0;
  for (i = 0; i < nx * ny; ++i)
    Tout[i] = transition(B, Tin, nx, ny, i);
}


x86 assembly (clang, -O0):
<evolve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
cmp    %ecx,%eax
jge    117d <evolve+0x6d>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%r8d
call   1030 <transition@plt>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1139 <evolve+0x29>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<evolve>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%eax
imul   %ecx,%eax
test   %eax,%eax
jle    1163 <evolve+0x53>
mov    %r8d,%r12d
mov    %ecx,%ebx
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r14
mov    %eax,%eax
mov    %rax,(%rsp)
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
mov    %r12d,%ecx
mov    %ebp,%r8d
call   1030 <transition@plt>
movsd  %xmm0,(%r15,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,(%rsp)
jne    1140 <evolve+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @evolve(i32* %0, double* %1, double* %2, i32 %3, i32 %4) {
%6 = alloca i32*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %6
store double* %1, double** %7
store double* %2, double** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
store i32 0, i32* %11
store i32 0, i32* %11
br label %12
12: ; preds = %29, %5
%13 = load i32, i32* %11
%14 = load i32, i32* %9
%15 = load i32, i32* %10
%16 = mul nsw i32 %14, %15
%17 = icmp slt i32 %13, %16
br i1 %17, label %18, label %32
18: ; preds = %12
%19 = load i32*, i32** %6
%20 = load double*, double** %7
%21 = load i32, i32* %9
%22 = load i32, i32* %10
%23 = load i32, i32* %11
%24 = call double @transition(i32* %19, double* %20, i32 %21, i32 %22, i32 %23)
%25 = load double*, double** %8
%26 = load i32, i32* %11
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds double, double* %25, i64 %27
store double %24, double* %28
br label %29
29: ; preds = %18
%30 = load i32, i32* %11
%31 = add nsw i32 %30, 1
store i32 %31, i32* %11
br label %12
32: ; preds = %12
ret void
}

LLVM IR (-O2):
define void @evolve(i32* %0, double* %1, double* nocapture writeonly %2, i32 %3, i32 %4) {
%6 = mul i32 %4, %3
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = zext i32 %6 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %15, %10 ]
%12 = trunc i64 %11 to i32
%13 = tail call double @transition(i32* %0, double* %1, i32 %3, i32 %4, i32 %12)
%14 = getelementptr inbounds double, double* %2, i64 %11
store double %13, double* %14
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, %9
br i1 %16, label %17, label %10
17: ; preds = %10, %5
ret void
}