#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*/ assert(int);
int print_int_array(int *, int);
int /*<<< orphan*/ printf(char *);
int main(void) {
  int ret;
  int crap_ints[] = {9, 8, 7, 6, 5, 4, 3, 2, 1};
  printf("Test NULL array: ");
  ret = print_int_array(NULL, 10);
  assert(ret != 0);
  printf(" OK\n");
  printf("Test valid array: ");
  ret = print_int_array(crap_ints, 9);
  assert(ret == 0);
  printf("OK\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x24,%edx
call   1050 <memcpy@plt>
lea    0xeb9(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0xa,%esi
call   1060 <print_int_array@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe9d(%rip),%rdi
call   1030 <printf@plt>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0x9,%esi
call   1060 <print_int_array@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
mov    0xed6(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xebb(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe9f(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0xeb8(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
mov    $0xa,%esi
call   1060 <print_int_array@plt>
xor    %edi,%edi
test   %eax,%eax
setne  %dil
call   1050 <assert@plt>
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
lea    0xe99(%rip),%rdi
call   1040 <printf@plt>
mov    %rsp,%rdi
mov    $0x9,%esi
call   1060 <print_int_array@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1050 <assert@plt>
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.main.crap_ints = [9 x i32] [i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1]
@.str = [18 x i8] c"Test NULL array: \00"
@.str.1 = [5 x i8] c" OK\0A\00"
@.str.2 = [19 x i8] c"Test valid array: \00"
@.str.3 = [4 x i8] c"OK\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [9 x i32]
store i32 0, i32* %1
%4 = bitcast [9 x i32]* %3 to i8*
%5 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @print_int_array(i32* null, i32 10)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp ne i32 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%13 = getelementptr inbounds [9 x i32], [9 x i32]* %3, i64 0, i64 0
%14 = call i32 @print_int_array(i32* %13, i32 9)
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.crap_ints = [9 x i32] [i32 9, i32 8, i32 7, i32 6, i32 5, i32 4, i32 3, i32 2, i32 1]
@.str = [18 x i8] c"Test NULL array: \00"
@.str.2 = [19 x i8] c"Test valid array: \00"
@str = [4 x i8] c" OK\00"
@str.4 = [3 x i8] c"OK\00"
define i32 @main() {
%1 = alloca [9 x i32]
%2 = bitcast [9 x i32]* %1 to i8*
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 @print_int_array(i32* null, i32 10)
%5 = icmp ne i32 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
%9 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%10 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
%11 = call i32 @print_int_array(i32* %10, i32 9)
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.4, i64 0, i64 0))
ret i32 0
}