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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
scalar_t__ nam_add_edge(struct naive_adj_mat *, int, int);
int nam_destroy(struct naive_adj_mat *, int);
struct naive_adj_mat *nam_new(int);
scalar_t__ nam_remove_edge(struct naive_adj_mat *, int, int);
scalar_t__ nam_resize(struct naive_adj_mat *, int /*<<< orphan*/);
scalar_t__ nam_test_edge(struct naive_adj_mat *, int, int);
int /*<<< orphan*/ puts(char *);
void invalid(void) {
  struct naive_adj_mat *nam = 0;
  puts("\ntesting calling functions with invalid arguments (warnings will be "
       "printed)");
  nam = nam_new(2);
  assert(nam);
  assert(0 == nam_resize(nam, 0));
  assert(0 == nam_add_edge(nam, 2, 0));
  assert(0 == nam_add_edge(nam, 0, 2));
  assert(0 == nam_remove_edge(nam, 2, 0));
  assert(0 == nam_remove_edge(nam, 0, 2));
  assert(0 == nam_test_edge(nam, 2, 0));
  assert(0 == nam_test_edge(nam, 0, 2));
  assert(nam_destroy(nam, 1));
  puts("success!");
}


x86 assembly (clang, -O0):
<invalid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movq   $0x0,-0x8(%rbp)
lea    0xe69(%rip),%rdi
call   1050 <puts@plt>
mov    $0x2,%edi
call   1080 <nam_new@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,%edi
call   1090 <assert@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1040 <nam_resize@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1070 <nam_add_edge@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1070 <nam_add_edge@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   10a0 <nam_remove_edge@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   10a0 <nam_remove_edge@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1030 <nam_test_edge@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <nam_test_edge@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1060 <nam_destroy@plt>
mov    %eax,%edi
call   1090 <assert@plt>
lea    0xd7e(%rip),%rdi
call   1050 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<invalid>:
push   %rbx
lea    0xe78(%rip),%rdi
call   1050 <puts@plt>
mov    $0x2,%edi
call   1080 <nam_new@plt>
mov    %rax,%rbx
mov    %ebx,%edi
call   1090 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nam_resize@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1070 <nam_add_edge@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1070 <nam_add_edge@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   10a0 <nam_remove_edge@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   10a0 <nam_remove_edge@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
xor    %edx,%edx
call   1030 <nam_test_edge@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1030 <nam_test_edge@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1090 <assert@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <nam_destroy@plt>
mov    %eax,%edi
call   1090 <assert@plt>
lea    0xdcb(%rip),%rdi
pop    %rbx
jmp    1050 <puts@plt>

LLVM IR (-O0):
%struct.naive_adj_mat = type { i32 }
@.str = [77 x i8] c"\0Atesting calling functions with invalid arguments (warnings will be printed)\00"
@.str.1 = [9 x i8] c"success!\00"
define void @invalid() {
%1 = alloca %struct.naive_adj_mat*
store %struct.naive_adj_mat* null, %struct.naive_adj_mat** %1
%2 = call i32 @puts(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
%3 = call %struct.naive_adj_mat* @nam_new(i32 2)
store %struct.naive_adj_mat* %3, %struct.naive_adj_mat** %1
%4 = load %struct.naive_adj_mat*, %struct.naive_adj_mat** %1
%5 = ptrtoint %struct.naive_adj_mat* %4 to i32
%6 = call i32 @assert(i32 %5)
%7 = load %struct.naive_adj_mat*, %struct.naive_adj_mat** %1
%8 = call i64 @nam_resize(%struct.naive_adj_mat* %7, i32 0)
%9 = icmp eq i64 0, %8
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = load %struct.naive_adj_mat*, %struct.naive_adj_mat** %1
%13 = call i64 @nam_add_edge(%struct.naive_adj_mat* %12, i32 2, i32 0)
%14 = icmp eq i64 0, %13
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = load %struct.naive_adj_mat*, %struct.naive_adj_mat** %1
%18 = call i64 @nam_add_edge(%struct.naive_adj_mat* %17, i32 0, i32 2)
%19 = icmp eq i64 0, %18
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load %struct.naive_adj_mat*, %struct.naive_adj_mat** %1
%23 = call i64 @nam_remove_edge(%struct.naive_adj_mat* %22, i32 2, i32 0)
%24 = icmp eq i64 0, %23
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load %struct.naive_adj_mat*, %struct.naive_adj_mat** %1
%28 = call i64 @nam_remove_edge(%struct.naive_adj_mat* %27, i32 0, i32 2)
%29 = icmp eq i64 0, %28
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
%32 = load %struct.naive_adj_mat*, %struct.naive_adj_mat** %1
%33 = call i64 @nam_test_edge(%struct.naive_adj_mat* %32, i32 2, i32 0)
%34 = icmp eq i64 0, %33
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load %struct.naive_adj_mat*, %struct.naive_adj_mat** %1
%38 = call i64 @nam_test_edge(%struct.naive_adj_mat* %37, i32 0, i32 2)
%39 = icmp eq i64 0, %38
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = load %struct.naive_adj_mat*, %struct.naive_adj_mat** %1
%43 = call i32 @nam_destroy(%struct.naive_adj_mat* %42, i32 1)
%44 = call i32 @assert(i32 %43)
%45 = call i32 @puts(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.naive_adj_mat = type { i32 }
@.str = [77 x i8] c"\0Atesting calling functions with invalid arguments (warnings will be printed)\00"
@.str.1 = [9 x i8] c"success!\00"
define void @invalid() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0))
%2 = tail call %struct.naive_adj_mat* @nam_new(i32 2)
%3 = ptrtoint %struct.naive_adj_mat* %2 to i64
%4 = trunc i64 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i64 @nam_resize(%struct.naive_adj_mat* %2, i32 0)
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i64 @nam_add_edge(%struct.naive_adj_mat* %2, i32 2, i32 0)
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @assert(i32 %12)
%14 = tail call i64 @nam_add_edge(%struct.naive_adj_mat* %2, i32 0, i32 2)
%15 = icmp eq i64 %14, 0
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = tail call i64 @nam_remove_edge(%struct.naive_adj_mat* %2, i32 2, i32 0)
%19 = icmp eq i64 %18, 0
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i64 @nam_remove_edge(%struct.naive_adj_mat* %2, i32 0, i32 2)
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i64 @nam_test_edge(%struct.naive_adj_mat* %2, i32 2, i32 0)
%27 = icmp eq i64 %26, 0
%28 = zext i1 %27 to i32
%29 = tail call i32 @assert(i32 %28)
%30 = tail call i64 @nam_test_edge(%struct.naive_adj_mat* %2, i32 0, i32 2)
%31 = icmp eq i64 %30, 0
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = tail call i32 @nam_destroy(%struct.naive_adj_mat* %2, i32 1)
%35 = tail call i32 @assert(i32 %34)
%36 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
ret void
}