#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 /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ test_grid_create();
int /*<<< orphan*/ test_grid_set();
int /*<<< orphan*/ test_grid_shift();
int /*<<< orphan*/ test_grid_write_to_file();
unsigned int test_grid(void) {
  printf("\nTesting grid...\n");
  if (!test_grid_create())
    return 0;
  ;
  if (!test_grid_set())
    return 0;
  ;
  if (!test_grid_shift())
    return 0;
  ;
  if (!test_grid_write_to_file())
    return 0;
  ;
  printf("All grid tests passed!\n");
  return 1;
}


x86 assembly (clang, -O0):
<test_grid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <test_grid_create@plt>
cmp    $0x0,%eax
jne    1180 <test_grid+0x30>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <test_grid+0x97>
mov    $0x0,%al
call   1070 <test_grid_set@plt>
cmp    $0x0,%eax
jne    119c <test_grid+0x4c>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <test_grid+0x97>
mov    $0x0,%al
call   1060 <test_grid_shift@plt>
cmp    $0x0,%eax
jne    11b8 <test_grid+0x68>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <test_grid+0x97>
mov    $0x0,%al
call   1030 <test_grid_write_to_file@plt>
cmp    $0x0,%eax
jne    11d4 <test_grid+0x84>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <test_grid+0x97>
lea    0xe37(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_grid>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <test_grid_create@plt>
test   %eax,%eax
je     11a2 <test_grid+0x52>
xor    %ebx,%ebx
xor    %eax,%eax
call   1070 <test_grid_set@plt>
test   %eax,%eax
je     11a2 <test_grid+0x52>
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <test_grid_shift@plt>
test   %eax,%eax
je     11a2 <test_grid+0x52>
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <test_grid_write_to_file@plt>
test   %eax,%eax
je     11a2 <test_grid+0x52>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\0ATesting grid...\0A\00"
@.str.1 = [24 x i8] c"All grid tests passed!\0A\00"
define i32 @test_grid() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = call i32 (...) @test_grid_create()
%4 = icmp ne i32 %3, 0
br i1 %4, label %6, label %5
5: ; preds = %0
store i32 0, i32* %1
br label %20
6: ; preds = %0
%7 = call i32 (...) @test_grid_set()
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %6
store i32 0, i32* %1
br label %20
10: ; preds = %6
%11 = call i32 (...) @test_grid_shift()
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %10
store i32 0, i32* %1
br label %20
14: ; preds = %10
%15 = call i32 (...) @test_grid_write_to_file()
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %14
store i32 0, i32* %1
br label %20
18: ; preds = %14
%19 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %20
20: ; preds = %18, %17, %13, %9, %5
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@str = [17 x i8] c"\0ATesting grid...\00"
@str.2 = [23 x i8] c"All grid tests passed!\00"
define i32 @test_grid() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @test_grid_create()
%3 = icmp eq i32 %2, 0
br i1 %3, label %15, label %4
4: ; preds = %0
%5 = tail call i32 (...) @test_grid_set()
%6 = icmp eq i32 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %4
%8 = tail call i32 (...) @test_grid_shift()
%9 = icmp eq i32 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = tail call i32 (...) @test_grid_write_to_file()
%12 = icmp eq i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.2, i64 0, i64 0))
br label %15
15: ; preds = %10, %7, %4, %0, %13
%16 = phi i32 [ 1, %13 ], [ 0, %0 ], [ 0, %4 ], [ 0, %7 ], [ 0, %10 ]
ret i32 %16
}