#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 count_neighbors(int **, int, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ system_clear();
void show_cell_info(int board[20][40], int x, int y) {
  int internal_x = (20 - y), internal_y = (x - 1);
  system_clear();
  printf("-- Cell information --\n");
  printf("User coordinates:     %d,%d\n", x, y);
  printf("Internal coordinates: %d,%d\n", internal_x, internal_y);
  printf("State (1 is active):  %d\n", board[internal_x][internal_y]);
  printf("Active neighbors:     %d\n",
         count_neighbors(board, internal_x, internal_y));
  getchar();
}


x86 assembly (clang, -O0):
<show_cell_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    $0x14,%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    $0x0,%al
call   1060 <system_clear@plt>
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xe90(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
imul   $0xa0,%rcx,%rcx
add    %rcx,%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1040 <count_neighbors@plt>
mov    %eax,%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_cell_info>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r12d
mov    %esi,%ebx
mov    %rdi,%r14
mov    $0x14,%ebp
sub    %edx,%ebp
lea    -0x1(%rbx),%r15d
xor    %eax,%eax
call   1070 <system_clear@plt>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7b(%rip),%rdi
mov    %ebx,%esi
mov    %r12d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
mov    %ebp,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1040 <printf@plt>
movslq %ebp,%rbp
movslq %ebx,%rax
lea    0x0(,%rbp,4),%rcx
add    %rbp,%rcx
shl    $0x5,%rcx
add    %r14,%rcx
mov    -0x4(%rcx,%rax,4),%esi
lea    0xe73(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
call   1050 <count_neighbors@plt>
lea    0xe72(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <getchar@plt>

LLVM IR (-O0):
@.str = [24 x i8] c"-- Cell information --\0A\00"
@.str.1 = [29 x i8] c"User coordinates: %d,%d\0A\00"
@.str.2 = [29 x i8] c"Internal coordinates: %d,%d\0A\00"
@.str.3 = [26 x i8] c"State (1 is active): %d\0A\00"
@.str.4 = [26 x i8] c"Active neighbors: %d\0A\00"
define void @show_cell_info([40 x i32]* %0, i32 %1, i32 %2) {
%4 = alloca [40 x i32]*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store [40 x i32]* %0, [40 x i32]** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %6
%10 = sub nsw i32 20, %9
store i32 %10, i32* %7
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 1
store i32 %12, i32* %8
%13 = call i32 (...) @system_clear()
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %15, i32 %16)
%18 = load i32, i32* %7
%19 = load i32, i32* %8
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
%21 = load [40 x i32]*, [40 x i32]** %4
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [40 x i32], [40 x i32]* %21, i64 %23
%25 = load i32, i32* %8
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [40 x i32], [40 x i32]* %24, i64 0, i64 %26
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %28)
%30 = load [40 x i32]*, [40 x i32]** %4
%31 = bitcast [40 x i32]* %30 to i32**
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = call i32 @count_neighbors(i32** %31, i32 %32, i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%36 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str.1 = [29 x i8] c"User coordinates: %d,%d\0A\00"
@.str.2 = [29 x i8] c"Internal coordinates: %d,%d\0A\00"
@.str.3 = [26 x i8] c"State (1 is active): %d\0A\00"
@.str.4 = [26 x i8] c"Active neighbors: %d\0A\00"
@str = [23 x i8] c"-- Cell information --\00"
define void @show_cell_info([40 x i32]* %0, i32 %1, i32 %2) {
%4 = sub nsw i32 20, %2
%5 = add nsw i32 %1, -1
%6 = tail call i32 (...) @system_clear()
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %2)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %5)
%10 = sext i32 %4 to i64
%11 = sext i32 %5 to i64
%12 = getelementptr inbounds [40 x i32], [40 x i32]* %0, i64 %10, i64 %11
%13 = load i32, i32* %12
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = bitcast [40 x i32]* %0 to i32**
%16 = tail call i32 @count_neighbors(i32** %15, i32 %4, i32 %5)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %16)
%18 = tail call i32 (...) @getchar()
ret void
}