#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_board(int **, int **);
int /*<<< orphan*/ init_board(int **);
int /*<<< orphan*/ iter_cell(int **, int **, int, int);
void next_iteration(int board[20][40]) {
  int i, j;
  int next[20][40];
  init_board(next);
  for (i = 0; i < 20; i++)
    for (j = 0; j < 40; j++)
      iter_cell(board, next, i, j);
  copy_board(next, board);
}


x86 assembly (clang, -O0):
<next_iteration>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc90,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0xc90(%rbp),%rdi
call   1040 <init_board@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x14,-0xc(%rbp)
jge    11a4 <next_iteration+0x74>
movl   $0x0,-0x10(%rbp)
cmpl   $0x28,-0x10(%rbp)
jge    1191 <next_iteration+0x61>
mov    -0x8(%rbp),%rdi
lea    -0xc90(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%ecx
call   1030 <iter_cell@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1163 <next_iteration+0x33>
jmp    1196 <next_iteration+0x66>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1152 <next_iteration+0x22>
lea    -0xc90(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1050 <copy_board@plt>
add    $0xc90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<next_iteration>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xc88,%rsp
mov    %rdi,%r15
mov    %rsp,%r14
mov    %r14,%rdi
call   1040 <init_board@plt>
xor    %ebp,%ebp
nopl   (%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebx,%ecx
call   1030 <iter_cell@plt>
add    $0x1,%ebx
cmp    $0x28,%ebx
jne    1160 <next_iteration+0x30>
add    $0x1,%ebp
cmp    $0x14,%ebp
jne    1150 <next_iteration+0x20>
mov    %rsp,%rdi
mov    %r15,%rsi
call   1050 <copy_board@plt>
add    $0xc88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @next_iteration([40 x i32]* %0) {
%2 = alloca [40 x i32]*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [20 x [40 x i32]]
store [40 x i32]* %0, [40 x i32]** %2
%6 = getelementptr inbounds [20 x [40 x i32]], [20 x [40 x i32]]* %5, i64 0, i64 0
%7 = bitcast [40 x i32]* %6 to i32**
%8 = call i32 @init_board(i32** %7)
store i32 0, i32* %3
br label %9
9: ; preds = %28, %1
%10 = load i32, i32* %3
%11 = icmp slt i32 %10, 20
br i1 %11, label %12, label %31
12: ; preds = %9
store i32 0, i32* %4
br label %13
13: ; preds = %24, %12
%14 = load i32, i32* %4
%15 = icmp slt i32 %14, 40
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = load [40 x i32]*, [40 x i32]** %2
%18 = bitcast [40 x i32]* %17 to i32**
%19 = getelementptr inbounds [20 x [40 x i32]], [20 x [40 x i32]]* %5, i64 0, i64 0
%20 = bitcast [40 x i32]* %19 to i32**
%21 = load i32, i32* %3
%22 = load i32, i32* %4
%23 = call i32 @iter_cell(i32** %18, i32** %20, i32 %21, i32 %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
br label %13
27: ; preds = %13
br label %28
28: ; preds = %27
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %9
31: ; preds = %9
%32 = getelementptr inbounds [20 x [40 x i32]], [20 x [40 x i32]]* %5, i64 0, i64 0
%33 = bitcast [40 x i32]* %32 to i32**
%34 = load [40 x i32]*, [40 x i32]** %2
%35 = bitcast [40 x i32]* %34 to i32**
%36 = call i32 @copy_board(i32** %33, i32** %35)
ret void
}

LLVM IR (-O2):
define void @next_iteration([40 x i32]* %0) {
%2 = alloca [20 x [40 x i32]]
%3 = bitcast [20 x [40 x i32]]* %2 to i8*
%4 = bitcast [20 x [40 x i32]]* %2 to i32**
%5 = call i32 @init_board(i32** %4)
%6 = bitcast [40 x i32]* %0 to i32**
br label %7
7: ; preds = %1, %14
%8 = phi i32 [ 0, %1 ], [ %15, %14 ]
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ 0, %7 ], [ %12, %9 ]
%11 = call i32 @iter_cell(i32** %6, i32** %4, i32 %8, i32 %10)
%12 = add nuw nsw i32 %10, 1
%13 = icmp eq i32 %12, 40
br i1 %13, label %14, label %9
14: ; preds = %9
%15 = add nuw nsw i32 %8, 1
%16 = icmp eq i32 %15, 20
br i1 %16, label %17, label %7
17: ; preds = %14
%18 = call i32 @copy_board(i32** %4, i32** %6)
ret void
}