#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 */
scalar_t__ check_diagonals(char *);
char *create_board();
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *);
char main() {
  char *board;
  if ((board = create_board()) == NULL)
    printf("invalid\n");
  else {
    printf(check_diagonals(board) ? "valid\n" : "invalid\n");
    free(board);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <create_board@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    116e <main+0x2e>
lea    0xe9c(%rip),%rdi
call   1040 <printf@plt>
jmp    119e <main+0x5e>
mov    -0x8(%rbp),%rdi
call   1050 <check_diagonals@plt>
mov    %rax,%rcx
lea    0xe7f(%rip),%rdi
lea    0xe7a(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
movsbl %al,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1070 <create_board@plt>
test   %rax,%rax
je     118c <main+0x3c>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <check_diagonals@plt>
test   %rax,%rax
lea    0xe8e(%rip),%rax
lea    0xe89(%rip),%rdi
cmove  %rax,%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    1198 <main+0x48>
lea    0xe76(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"invalid\0A\00"
@.str.1 = [7 x i8] c"valid\0A\00"
define signext i8 @main() {
%1 = alloca i8*
%2 = call i8* (...) @create_board()
store i8* %2, i8** %1
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %15
6: ; preds = %0
%7 = load i8*, i8** %1
%8 = call i64 @check_diagonals(i8* %7)
%9 = icmp ne i64 %8, 0
%10 = zext i1 %9 to i64
%11 = select i1 %9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0)
%12 = call i32 @printf(i8* %11)
%13 = load i8*, i8** %1
%14 = call i32 @free(i8* %13)
br label %15
15: ; preds = %6, %4
ret i8 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"invalid\0A\00"
@.str.1 = [7 x i8] c"valid\0A\00"
@str = [8 x i8] c"invalid\00"
define signext i8 @main() {
%1 = tail call i8* (...) @create_board()
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %11
5: ; preds = %0
%6 = tail call i64 @check_diagonals(i8* %1)
%7 = icmp eq i64 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0)
%9 = tail call i32 @printf(i8* dereferenceable(1) %8)
%10 = tail call i32 @free(i8* %1)
br label %11
11: ; preds = %5, %3
ret i8 0
}