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

/* Variables and functions */
int /*<<< orphan*/ bam_add_edge(struct bitwise_adj_mat *, int, int);
int /*<<< orphan*/ bam_destroy(struct bitwise_adj_mat *, int);
struct bitwise_adj_mat *bam_new(int);
int /*<<< orphan*/ bam_remove_edge(struct bitwise_adj_mat *, int /*<<< orphan*/,
                                   int);
int bam_size(struct bitwise_adj_mat *);
scalar_t__ bam_test_edge(struct bitwise_adj_mat *, int, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ puts(char *);
int main(void) {
  struct bitwise_adj_mat *bam = bam_new(4);
  int i = 0;
  int j = 0;
  int n = 0;
  bam_add_edge(bam, 0, 1);
  bam_add_edge(bam, 0, 2);
  bam_add_edge(bam, 2, 3);
  if (bam_test_edge(bam, 0, 1)) {
    puts("edge exists from 0 to 1");
  }
  if (!bam_test_edge(bam, 1, 0)) {
    puts("no edge exists from 1 to 0");
  }
  bam_remove_edge(bam, 0, 1);
  if (!bam_test_edge(bam, 0, 1)) {
    puts("removed edge from 0 to 1");
  }
  n = bam_size(bam);
  puts("\nlist of all edges");
  for (i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      if (bam_test_edge(bam, i, j)) {
        printf("%d -> %d\n", i, j);
      }
    }
  }
  bam_destroy(bam, 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1090 <bam_new@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1080 <bam_add_edge@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1080 <bam_add_edge@plt>
mov    -0x10(%rbp),%rdi
mov    $0x2,%esi
mov    $0x3,%edx
call   1080 <bam_add_edge@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <bam_test_edge@plt>
cmp    $0x0,%rax
je     120b <main+0x8b>
lea    0xdfa(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1050 <bam_test_edge@plt>
cmp    $0x0,%rax
jne    1231 <main+0xb1>
lea    0xdec(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1070 <bam_remove_edge@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <bam_test_edge@plt>
cmp    $0x0,%rax
jne    1267 <main+0xe7>
lea    0xdd1(%rip),%rdi
call   1030 <puts@plt>
mov    -0x10(%rbp),%rdi
call   1060 <bam_size@plt>
mov    %eax,-0x1c(%rbp)
lea    0xdd2(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12f6 <main+0x176>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12e3 <main+0x163>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <bam_test_edge@plt>
cmp    $0x0,%rax
je     12d0 <main+0x150>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xd94(%rip),%rdi
call   1040 <printf@plt>
jmp    12d5 <main+0x155>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1299 <main+0x119>
jmp    12e8 <main+0x168>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1286 <main+0x106>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   10a0 <bam_destroy@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    $0x4,%edi
call   1090 <bam_new@plt>
mov    %rax,%r14
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1080 <bam_add_edge@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1080 <bam_add_edge@plt>
mov    %r14,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
call   1080 <bam_add_edge@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <bam_test_edge@plt>
test   %rax,%rax
je     11e5 <main+0x65>
lea    0xe20(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
mov    $0x1,%esi
xor    %edx,%edx
call   1050 <bam_test_edge@plt>
test   %rax,%rax
jne    1205 <main+0x85>
lea    0xe18(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1070 <bam_remove_edge@plt>
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <bam_test_edge@plt>
test   %rax,%rax
jne    1234 <main+0xb4>
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1060 <bam_size@plt>
mov    %eax,%r12d
lea    0xe06(%rip),%rdi
call   1030 <puts@plt>
test   %r12d,%r12d
jle    1297 <main+0x117>
xor    %ebx,%ebx
lea    0xe06(%rip),%r15
jmp    1268 <main+0xe8>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebx
cmp    %r12d,%ebx
je     1297 <main+0x117>
xor    %ebp,%ebp
jmp    1278 <main+0xf8>
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    %ebp,%r12d
je     1260 <main+0xe0>
mov    %r14,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1050 <bam_test_edge@plt>
test   %rax,%rax
je     1270 <main+0xf0>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
call   1040 <printf@plt>
jmp    1270 <main+0xf0>
mov    %r14,%rdi
mov    $0x1,%esi
call   10a0 <bam_destroy@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.bitwise_adj_mat = type { i32 }
@.str = [24 x i8] c"edge exists from 0 to 1\00"
@.str.1 = [27 x i8] c"no edge exists from 1 to 0\00"
@.str.2 = [25 x i8] c"removed edge from 0 to 1\00"
@.str.3 = [19 x i8] c"\0Alist of all edges\00"
@.str.4 = [10 x i8] c"%d -> %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.bitwise_adj_mat*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call %struct.bitwise_adj_mat* @bam_new(i32 4)
store %struct.bitwise_adj_mat* %6, %struct.bitwise_adj_mat** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%7 = load %struct.bitwise_adj_mat*, %struct.bitwise_adj_mat** %2
%8 = call i32 @bam_add_edge(%struct.bitwise_adj_mat* %7, i32 0, i32 1)
%9 = load %struct.bitwise_adj_mat*, %struct.bitwise_adj_mat** %2
%10 = call i32 @bam_add_edge(%struct.bitwise_adj_mat* %9, i32 0, i32 2)
%11 = load %struct.bitwise_adj_mat*, %struct.bitwise_adj_mat** %2
%12 = call i32 @bam_add_edge(%struct.bitwise_adj_mat* %11, i32 2, i32 3)
%13 = load %struct.bitwise_adj_mat*, %struct.bitwise_adj_mat** %2
%14 = call i64 @bam_test_edge(%struct.bitwise_adj_mat* %13, i32 0, i32 1)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %0
%17 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %0
%19 = load %struct.bitwise_adj_mat*, %struct.bitwise_adj_mat** %2
%20 = call i64 @bam_test_edge(%struct.bitwise_adj_mat* %19, i32 1, i32 0)
%21 = icmp ne i64 %20, 0
br i1 %21, label %24, label %22
22: ; preds = %18
%23 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %18
%25 = load %struct.bitwise_adj_mat*, %struct.bitwise_adj_mat** %2
%26 = call i32 @bam_remove_edge(%struct.bitwise_adj_mat* %25, i32 0, i32 1)
%27 = load %struct.bitwise_adj_mat*, %struct.bitwise_adj_mat** %2
%28 = call i64 @bam_test_edge(%struct.bitwise_adj_mat* %27, i32 0, i32 1)
%29 = icmp ne i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %24
%31 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %32
32: ; preds = %30, %24
%33 = load %struct.bitwise_adj_mat*, %struct.bitwise_adj_mat** %2
%34 = call i32 @bam_size(%struct.bitwise_adj_mat* %33)
store i32 %34, i32* %5
%35 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %36
36: ; preds = %60, %32
%37 = load i32, i32* %3
%38 = load i32, i32* %5
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %63
40: ; preds = %36
store i32 0, i32* %4
br label %41
41: ; preds = %56, %40
%42 = load i32, i32* %4
%43 = load i32, i32* %5
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %59
45: ; preds = %41
%46 = load %struct.bitwise_adj_mat*, %struct.bitwise_adj_mat** %2
%47 = load i32, i32* %3
%48 = load i32, i32* %4
%49 = call i64 @bam_test_edge(%struct.bitwise_adj_mat* %46, i32 %47, i32 %48)
%50 = icmp ne i64 %49, 0
br i1 %50, label %51, label %55
51: ; preds = %45
%52 = load i32, i32* %3
%53 = load i32, i32* %4
%54 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %52, i32 %53)
br label %55
55: ; preds = %51, %45
br label %56
56: ; preds = %55
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
br label %41
59: ; preds = %41
br label %60
60: ; preds = %59
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 1
store i32 %62, i32* %3
br label %36
63: ; preds = %36
%64 = load %struct.bitwise_adj_mat*, %struct.bitwise_adj_mat** %2
%65 = call i32 @bam_destroy(%struct.bitwise_adj_mat* %64, i32 1)
ret i32 0
}

LLVM IR (-O2):
%struct.bitwise_adj_mat = type { i32 }
@.str = [24 x i8] c"edge exists from 0 to 1\00"
@.str.1 = [27 x i8] c"no edge exists from 1 to 0\00"
@.str.2 = [25 x i8] c"removed edge from 0 to 1\00"
@.str.3 = [19 x i8] c"\0Alist of all edges\00"
@.str.4 = [10 x i8] c"%d -> %d\0A\00"
define i32 @main() {
%1 = tail call %struct.bitwise_adj_mat* @bam_new(i32 4)
%2 = tail call i32 @bam_add_edge(%struct.bitwise_adj_mat* %1, i32 0, i32 1)
%3 = tail call i32 @bam_add_edge(%struct.bitwise_adj_mat* %1, i32 0, i32 2)
%4 = tail call i32 @bam_add_edge(%struct.bitwise_adj_mat* %1, i32 2, i32 3)
%5 = tail call i64 @bam_test_edge(%struct.bitwise_adj_mat* %1, i32 0, i32 1)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
%10 = tail call i64 @bam_test_edge(%struct.bitwise_adj_mat* %1, i32 1, i32 0)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = tail call i32 @bam_remove_edge(%struct.bitwise_adj_mat* %1, i32 0, i32 1)
%16 = tail call i64 @bam_test_edge(%struct.bitwise_adj_mat* %1, i32 0, i32 1)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %20
20: ; preds = %18, %14
%21 = tail call i32 @bam_size(%struct.bitwise_adj_mat* %1)
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp sgt i32 %21, 0
br i1 %23, label %24, label %38
24: ; preds = %20, %35
%25 = phi i32 [ %36, %35 ], [ 0, %20 ]
br label %26
26: ; preds = %24, %32
%27 = phi i32 [ %33, %32 ], [ 0, %24 ]
%28 = tail call i64 @bam_test_edge(%struct.bitwise_adj_mat* %1, i32 %25, i32 %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i32 %25, i32 %27)
br label %32
32: ; preds = %26, %30
%33 = add nuw nsw i32 %27, 1
%34 = icmp eq i32 %33, %21
br i1 %34, label %35, label %26
35: ; preds = %32
%36 = add nuw nsw i32 %25, 1
%37 = icmp eq i32 %36, %21
br i1 %37, label %38, label %24
38: ; preds = %35, %20
%39 = tail call i32 @bam_destroy(%struct.bitwise_adj_mat* %1, i32 1)
ret i32 0
}