#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 */
struct position {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bishop_control(struct position *, int, char *);
char *calloc(int, int);
int /*<<< orphan*/ king_control(struct position *, int, char *);
int /*<<< orphan*/ knight_control(struct position *, int, char *);
int /*<<< orphan*/ pawn_control(struct position *, int, char *);
int /*<<< orphan*/ rook_control(struct position *, int, char *);
char *net_attacks(struct position *pos) {
  char *squares = calloc(64, 1);
  rook_control(pos, 2, squares);
  bishop_control(pos, 2, squares);
  bishop_control(pos, 6, squares);
  knight_control(pos, 8, squares);
  rook_control(pos, 4, squares);
  pawn_control(pos, 10, squares);
  king_control(pos, 0, squares);
  rook_control(pos, 3, squares);
  bishop_control(pos, 3, squares);
  bishop_control(pos, 7, squares);
  knight_control(pos, 9, squares);
  rook_control(pos, 5, squares);
  pawn_control(pos, 11, squares);
  king_control(pos, 1, squares);
  return (squares);
}


x86 assembly (clang, -O0):
<net_attacks>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x40,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2,%esi
call   1060 <rook_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x2,%esi
call   1040 <bishop_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x6,%esi
call   1040 <bishop_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x8,%esi
call   1070 <knight_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x4,%esi
call   1060 <rook_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xa,%esi
call   1080 <pawn_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
xor    %esi,%esi
call   1030 <king_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3,%esi
call   1060 <rook_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x3,%esi
call   1040 <bishop_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x7,%esi
call   1040 <bishop_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x9,%esi
call   1070 <knight_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x5,%esi
call   1060 <rook_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xb,%esi
call   1080 <pawn_control@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x1,%esi
call   1030 <king_control@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<net_attacks>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x40,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x2,%esi
mov    %rax,%rdx
call   1060 <rook_control@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    %rbx,%rdx
call   1040 <bishop_control@plt>
mov    %r14,%rdi
mov    $0x6,%esi
mov    %rbx,%rdx
call   1040 <bishop_control@plt>
mov    %r14,%rdi
mov    $0x8,%esi
mov    %rbx,%rdx
call   1070 <knight_control@plt>
mov    %r14,%rdi
mov    $0x4,%esi
mov    %rbx,%rdx
call   1060 <rook_control@plt>
mov    %r14,%rdi
mov    $0xa,%esi
mov    %rbx,%rdx
call   1080 <pawn_control@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    %rbx,%rdx
call   1030 <king_control@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1060 <rook_control@plt>
mov    %r14,%rdi
mov    $0x3,%esi
mov    %rbx,%rdx
call   1040 <bishop_control@plt>
mov    %r14,%rdi
mov    $0x7,%esi
mov    %rbx,%rdx
call   1040 <bishop_control@plt>
mov    %r14,%rdi
mov    $0x9,%esi
mov    %rbx,%rdx
call   1070 <knight_control@plt>
mov    %r14,%rdi
mov    $0x5,%esi
mov    %rbx,%rdx
call   1060 <rook_control@plt>
mov    %r14,%rdi
mov    $0xb,%esi
mov    %rbx,%rdx
call   1080 <pawn_control@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %rbx,%rdx
call   1030 <king_control@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.position = type { i32 }
define i8* @net_attacks(%struct.position* %0) {
%2 = alloca %struct.position*
%3 = alloca i8*
store %struct.position* %0, %struct.position** %2
%4 = call i8* @calloc(i32 64, i32 1)
store i8* %4, i8** %3
%5 = load %struct.position*, %struct.position** %2
%6 = load i8*, i8** %3
%7 = call i32 @rook_control(%struct.position* %5, i32 2, i8* %6)
%8 = load %struct.position*, %struct.position** %2
%9 = load i8*, i8** %3
%10 = call i32 @bishop_control(%struct.position* %8, i32 2, i8* %9)
%11 = load %struct.position*, %struct.position** %2
%12 = load i8*, i8** %3
%13 = call i32 @bishop_control(%struct.position* %11, i32 6, i8* %12)
%14 = load %struct.position*, %struct.position** %2
%15 = load i8*, i8** %3
%16 = call i32 @knight_control(%struct.position* %14, i32 8, i8* %15)
%17 = load %struct.position*, %struct.position** %2
%18 = load i8*, i8** %3
%19 = call i32 @rook_control(%struct.position* %17, i32 4, i8* %18)
%20 = load %struct.position*, %struct.position** %2
%21 = load i8*, i8** %3
%22 = call i32 @pawn_control(%struct.position* %20, i32 10, i8* %21)
%23 = load %struct.position*, %struct.position** %2
%24 = load i8*, i8** %3
%25 = call i32 @king_control(%struct.position* %23, i32 0, i8* %24)
%26 = load %struct.position*, %struct.position** %2
%27 = load i8*, i8** %3
%28 = call i32 @rook_control(%struct.position* %26, i32 3, i8* %27)
%29 = load %struct.position*, %struct.position** %2
%30 = load i8*, i8** %3
%31 = call i32 @bishop_control(%struct.position* %29, i32 3, i8* %30)
%32 = load %struct.position*, %struct.position** %2
%33 = load i8*, i8** %3
%34 = call i32 @bishop_control(%struct.position* %32, i32 7, i8* %33)
%35 = load %struct.position*, %struct.position** %2
%36 = load i8*, i8** %3
%37 = call i32 @knight_control(%struct.position* %35, i32 9, i8* %36)
%38 = load %struct.position*, %struct.position** %2
%39 = load i8*, i8** %3
%40 = call i32 @rook_control(%struct.position* %38, i32 5, i8* %39)
%41 = load %struct.position*, %struct.position** %2
%42 = load i8*, i8** %3
%43 = call i32 @pawn_control(%struct.position* %41, i32 11, i8* %42)
%44 = load %struct.position*, %struct.position** %2
%45 = load i8*, i8** %3
%46 = call i32 @king_control(%struct.position* %44, i32 1, i8* %45)
%47 = load i8*, i8** %3
ret i8* %47
}

LLVM IR (-O2):
%struct.position = type { i32 }
define i8* @net_attacks(%struct.position* %0) {
%2 = tail call dereferenceable_or_null(64) i8* @calloc(i32 64, i32 1)
%3 = tail call i32 @rook_control(%struct.position* %0, i32 2, i8* %2)
%4 = tail call i32 @bishop_control(%struct.position* %0, i32 2, i8* %2)
%5 = tail call i32 @bishop_control(%struct.position* %0, i32 6, i8* %2)
%6 = tail call i32 @knight_control(%struct.position* %0, i32 8, i8* %2)
%7 = tail call i32 @rook_control(%struct.position* %0, i32 4, i8* %2)
%8 = tail call i32 @pawn_control(%struct.position* %0, i32 10, i8* %2)
%9 = tail call i32 @king_control(%struct.position* %0, i32 0, i8* %2)
%10 = tail call i32 @rook_control(%struct.position* %0, i32 3, i8* %2)
%11 = tail call i32 @bishop_control(%struct.position* %0, i32 3, i8* %2)
%12 = tail call i32 @bishop_control(%struct.position* %0, i32 7, i8* %2)
%13 = tail call i32 @knight_control(%struct.position* %0, i32 9, i8* %2)
%14 = tail call i32 @rook_control(%struct.position* %0, i32 5, i8* %2)
%15 = tail call i32 @pawn_control(%struct.position* %0, i32 11, i8* %2)
%16 = tail call i32 @king_control(%struct.position* %0, i32 1, i8* %2)
ret i8* %2
}