#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 node {
  int dummy;
};

/* Variables and functions */
struct node *get_bishop_moves(struct node *, char *, int, struct node *);
struct node *get_king_moves(struct node *, char *, int, struct node *);
struct node *get_knight_moves(int /*<<< orphan*/, char *, int, struct node *);
struct node *get_pawn_moves(struct node *, char *, int, struct node *);
struct node *get_queen_moves(struct node *, char *, int, struct node *);
struct node *get_rook_moves(struct node *, char *, int, struct node *);
struct node *populate_row(char *board, int isWhitesMove,
                          struct node *parentNode) {
  struct node *n1 = get_knight_moves(0, board, isWhitesMove, parentNode);
  struct node *n2 = get_pawn_moves(n1, board, isWhitesMove, parentNode);
  struct node *n3 = get_king_moves(n2, board, isWhitesMove, parentNode);
  struct node *n4 = get_bishop_moves(n3, board, isWhitesMove, parentNode);
  struct node *n5 = get_rook_moves(n4, board, isWhitesMove, parentNode);
  struct node *n6 = get_queen_moves(n5, board, isWhitesMove, parentNode);
  return n6;
}


x86 assembly (clang, -O0):
<populate_row>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
xor    %edi,%edi
call   1060 <get_knight_moves@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1070 <get_pawn_moves@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1080 <get_king_moves@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1040 <get_bishop_moves@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1030 <get_rook_moves@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1050 <get_queen_moves@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<populate_row>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %edi,%edi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1060 <get_knight_moves@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1070 <get_pawn_moves@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1080 <get_king_moves@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1040 <get_bishop_moves@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
call   1030 <get_rook_moves@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
mov    %r14,%rcx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <get_queen_moves@plt>

LLVM IR (-O0):
%struct.node = type { i32 }
define %struct.node* @populate_row(i8* %0, i32 %1, %struct.node* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca %struct.node*
%7 = alloca %struct.node*
%8 = alloca %struct.node*
%9 = alloca %struct.node*
%10 = alloca %struct.node*
%11 = alloca %struct.node*
%12 = alloca %struct.node*
store i8* %0, i8** %4
store i32 %1, i32* %5
store %struct.node* %2, %struct.node** %6
%13 = load i8*, i8** %4
%14 = load i32, i32* %5
%15 = load %struct.node*, %struct.node** %6
%16 = call %struct.node* @get_knight_moves(i32 0, i8* %13, i32 %14, %struct.node* %15)
store %struct.node* %16, %struct.node** %7
%17 = load %struct.node*, %struct.node** %7
%18 = load i8*, i8** %4
%19 = load i32, i32* %5
%20 = load %struct.node*, %struct.node** %6
%21 = call %struct.node* @get_pawn_moves(%struct.node* %17, i8* %18, i32 %19, %struct.node* %20)
store %struct.node* %21, %struct.node** %8
%22 = load %struct.node*, %struct.node** %8
%23 = load i8*, i8** %4
%24 = load i32, i32* %5
%25 = load %struct.node*, %struct.node** %6
%26 = call %struct.node* @get_king_moves(%struct.node* %22, i8* %23, i32 %24, %struct.node* %25)
store %struct.node* %26, %struct.node** %9
%27 = load %struct.node*, %struct.node** %9
%28 = load i8*, i8** %4
%29 = load i32, i32* %5
%30 = load %struct.node*, %struct.node** %6
%31 = call %struct.node* @get_bishop_moves(%struct.node* %27, i8* %28, i32 %29, %struct.node* %30)
store %struct.node* %31, %struct.node** %10
%32 = load %struct.node*, %struct.node** %10
%33 = load i8*, i8** %4
%34 = load i32, i32* %5
%35 = load %struct.node*, %struct.node** %6
%36 = call %struct.node* @get_rook_moves(%struct.node* %32, i8* %33, i32 %34, %struct.node* %35)
store %struct.node* %36, %struct.node** %11
%37 = load %struct.node*, %struct.node** %11
%38 = load i8*, i8** %4
%39 = load i32, i32* %5
%40 = load %struct.node*, %struct.node** %6
%41 = call %struct.node* @get_queen_moves(%struct.node* %37, i8* %38, i32 %39, %struct.node* %40)
store %struct.node* %41, %struct.node** %12
%42 = load %struct.node*, %struct.node** %12
ret %struct.node* %42
}

LLVM IR (-O2):
%struct.node = type { i32 }
define %struct.node* @populate_row(i8* %0, i32 %1, %struct.node* %2) {
%4 = tail call %struct.node* @get_knight_moves(i32 0, i8* %0, i32 %1, %struct.node* %2)
%5 = tail call %struct.node* @get_pawn_moves(%struct.node* %4, i8* %0, i32 %1, %struct.node* %2)
%6 = tail call %struct.node* @get_king_moves(%struct.node* %5, i8* %0, i32 %1, %struct.node* %2)
%7 = tail call %struct.node* @get_bishop_moves(%struct.node* %6, i8* %0, i32 %1, %struct.node* %2)
%8 = tail call %struct.node* @get_rook_moves(%struct.node* %7, i8* %0, i32 %1, %struct.node* %2)
%9 = tail call %struct.node* @get_queen_moves(%struct.node* %8, i8* %0, i32 %1, %struct.node* %2)
ret %struct.node* %9
}