#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 priority_queue {
  int dummy;
};
struct board_state {
  int dummy;
};

/* Variables and functions */
int generate_bishop_moves_white(struct board_state *, struct priority_queue *);
int generate_castle_white(struct board_state *, struct priority_queue *);
int generate_king_moves_white(struct board_state *, struct priority_queue *);
int generate_knight_moves_white(struct board_state *, struct priority_queue *);
int generate_pawn_moves_white(struct board_state *, struct priority_queue *);
int generate_queen_moves_white(struct board_state *, struct priority_queue *);
int generate_rook_moves_white(struct board_state *, struct priority_queue *);
int generate_moves_white(struct board_state *board,
                         struct priority_queue *moves) {
  return generate_king_moves_white(board, moves) +
         generate_queen_moves_white(board, moves) +
         generate_bishop_moves_white(board, moves) +
         generate_knight_moves_white(board, moves) +
         generate_rook_moves_white(board, moves) +
         generate_pawn_moves_white(board, moves) +
         generate_castle_white(board, moves);
}


x86 assembly (clang, -O0):
<generate_moves_white>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <generate_king_moves_white@plt>
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <generate_queen_moves_white@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <generate_bishop_moves_white@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <generate_knight_moves_white@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <generate_rook_moves_white@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <generate_pawn_moves_white@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <generate_castle_white@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
add    %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<generate_moves_white>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1050 <generate_king_moves_white@plt>
mov    %eax,%r15d
mov    %r12,%rdi
mov    %r14,%rsi
call   1090 <generate_queen_moves_white@plt>
mov    %eax,%ebp
add    %r15d,%ebp
mov    %r12,%rdi
mov    %r14,%rsi
call   1080 <generate_bishop_moves_white@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <generate_knight_moves_white@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r12,%rdi
mov    %r14,%rsi
call   1060 <generate_rook_moves_white@plt>
mov    %eax,%ebx
add    %ebp,%ebx
mov    %r12,%rdi
mov    %r14,%rsi
call   1070 <generate_pawn_moves_white@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r12,%rdi
mov    %r14,%rsi
call   1040 <generate_castle_white@plt>
add    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.board_state = type { i32 }
%struct.priority_queue = type { i32 }
define i32 @generate_moves_white(%struct.board_state* %0, %struct.priority_queue* %1) {
%3 = alloca %struct.board_state*
%4 = alloca %struct.priority_queue*
store %struct.board_state* %0, %struct.board_state** %3
store %struct.priority_queue* %1, %struct.priority_queue** %4
%5 = load %struct.board_state*, %struct.board_state** %3
%6 = load %struct.priority_queue*, %struct.priority_queue** %4
%7 = call i32 @generate_king_moves_white(%struct.board_state* %5, %struct.priority_queue* %6)
%8 = load %struct.board_state*, %struct.board_state** %3
%9 = load %struct.priority_queue*, %struct.priority_queue** %4
%10 = call i32 @generate_queen_moves_white(%struct.board_state* %8, %struct.priority_queue* %9)
%11 = add nsw i32 %7, %10
%12 = load %struct.board_state*, %struct.board_state** %3
%13 = load %struct.priority_queue*, %struct.priority_queue** %4
%14 = call i32 @generate_bishop_moves_white(%struct.board_state* %12, %struct.priority_queue* %13)
%15 = add nsw i32 %11, %14
%16 = load %struct.board_state*, %struct.board_state** %3
%17 = load %struct.priority_queue*, %struct.priority_queue** %4
%18 = call i32 @generate_knight_moves_white(%struct.board_state* %16, %struct.priority_queue* %17)
%19 = add nsw i32 %15, %18
%20 = load %struct.board_state*, %struct.board_state** %3
%21 = load %struct.priority_queue*, %struct.priority_queue** %4
%22 = call i32 @generate_rook_moves_white(%struct.board_state* %20, %struct.priority_queue* %21)
%23 = add nsw i32 %19, %22
%24 = load %struct.board_state*, %struct.board_state** %3
%25 = load %struct.priority_queue*, %struct.priority_queue** %4
%26 = call i32 @generate_pawn_moves_white(%struct.board_state* %24, %struct.priority_queue* %25)
%27 = add nsw i32 %23, %26
%28 = load %struct.board_state*, %struct.board_state** %3
%29 = load %struct.priority_queue*, %struct.priority_queue** %4
%30 = call i32 @generate_castle_white(%struct.board_state* %28, %struct.priority_queue* %29)
%31 = add nsw i32 %27, %30
ret i32 %31
}

LLVM IR (-O2):
%struct.board_state = type { i32 }
%struct.priority_queue = type { i32 }
define i32 @generate_moves_white(%struct.board_state* %0, %struct.priority_queue* %1) {
%3 = tail call i32 @generate_king_moves_white(%struct.board_state* %0, %struct.priority_queue* %1)
%4 = tail call i32 @generate_queen_moves_white(%struct.board_state* %0, %struct.priority_queue* %1)
%5 = add nsw i32 %4, %3
%6 = tail call i32 @generate_bishop_moves_white(%struct.board_state* %0, %struct.priority_queue* %1)
%7 = add nsw i32 %5, %6
%8 = tail call i32 @generate_knight_moves_white(%struct.board_state* %0, %struct.priority_queue* %1)
%9 = add nsw i32 %7, %8
%10 = tail call i32 @generate_rook_moves_white(%struct.board_state* %0, %struct.priority_queue* %1)
%11 = add nsw i32 %9, %10
%12 = tail call i32 @generate_pawn_moves_white(%struct.board_state* %0, %struct.priority_queue* %1)
%13 = add nsw i32 %11, %12
%14 = tail call i32 @generate_castle_white(%struct.board_state* %0, %struct.priority_queue* %1)
%15 = add nsw i32 %13, %14
ret i32 %15
}