#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 */
typedef scalar_t__ ssize_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
scalar_t__ struct_calcsize(char *);
void test_struct_calcsize_errors(void) {
  ssize_t res1, res2, res3;
  res1 = struct_calcsize(NULL);
  res2 = struct_calcsize("abc");
  res3 = struct_calcsize("1");
  printf("Struct calcsize errors test: ");
  if (res1 < 0 && res2 < 0 && res3 < 0)
    printf("PASS\n");
  else
    printf("FAIL\n");
}


x86 assembly (clang, -O0):
<test_struct_calcsize_errors>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1030 <struct_calcsize@plt>
mov    %rax,-0x8(%rbp)
lea    0xec4(%rip),%rdi
call   1030 <struct_calcsize@plt>
mov    %rax,-0x10(%rbp)
lea    0xeb8(%rip),%rdi
call   1030 <struct_calcsize@plt>
mov    %rax,-0x18(%rbp)
lea    0xeaa(%rip),%rdi
call   1040 <printf@plt>
cmpq   $0x0,-0x8(%rbp)
jge    1193 <test_struct_calcsize_errors+0x73>
cmpq   $0x0,-0x10(%rbp)
jge    1193 <test_struct_calcsize_errors+0x73>
cmpq   $0x0,-0x18(%rbp)
jge    1193 <test_struct_calcsize_errors+0x73>
lea    0xe9b(%rip),%rdi
call   1040 <printf@plt>
jmp    119f <test_struct_calcsize_errors+0x7f>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_struct_calcsize_errors>:
push   %r15
push   %r14
push   %rbx
xor    %edi,%edi
call   1030 <struct_calcsize@plt>
mov    %rax,%r14
lea    0xeba(%rip),%rdi
call   1030 <struct_calcsize@plt>
mov    %rax,%rbx
lea    0xeaf(%rip),%rdi
call   1030 <struct_calcsize@plt>
mov    %rax,%r15
lea    0xea2(%rip),%rdi
call   1050 <printf@plt>
and    %r14,%rbx
lea    0xeb6(%rip),%rax
lea    0xeaa(%rip),%rdi
test   %r15,%rbx
cmovs  %rax,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"abc\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [30 x i8] c"Struct calcsize errors test: \00"
@.str.3 = [6 x i8] c"PASS\0A\00"
@.str.4 = [6 x i8] c"FAIL\0A\00"
define void @test_struct_calcsize_errors() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i64
%4 = call i64 @struct_calcsize(i8* null)
store i64 %4, i64* %1
%5 = call i64 @struct_calcsize(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i64 %5, i64* %2
%6 = call i64 @struct_calcsize(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i64 %6, i64* %3
%7 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%8 = load i64, i64* %1
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %18
10: ; preds = %0
%11 = load i64, i64* %2
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i64, i64* %3
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %20
18: ; preds = %13, %10, %0
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0))
br label %20
20: ; preds = %18, %16
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"abc\00"
@.str.1 = [2 x i8] c"1\00"
@.str.2 = [30 x i8] c"Struct calcsize errors test: \00"
@str = [5 x i8] c"FAIL\00"
@str.5 = [5 x i8] c"PASS\00"
define void @test_struct_calcsize_errors() {
%1 = tail call i64 @struct_calcsize(i8* null)
%2 = tail call i64 @struct_calcsize(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%3 = tail call i64 @struct_calcsize(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%5 = icmp slt i64 %1, 0
%6 = icmp slt i64 %2, 0
%7 = select i1 %5, i1 %6, i1 false
%8 = icmp slt i64 %3, 0
%9 = select i1 %7, i1 %8, i1 false
%10 = select i1 %9, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str.5, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret void
}