; LLVM IR from marcobambini/gravity :: src/compiler (gravity_ast)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%struct.gnode_keyword_expr_t = type { %struct.gnode_t }
%struct.gnode_t = type { i32, i32, i32, %struct.gtoken_s, i8, ptr }
%struct.gtoken_s = type { i32, i32, i32, i32, i32, i32, i32, i32, ptr }
%struct.gnode_literal_expr_t = type { %struct.gnode_t, i32, i32, %union.anon }
%union.anon = type { ptr }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @gnode_is_equal(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i1, align 1
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %11, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %12, ptr %7, align 8, !tbaa !5
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.gnode_keyword_expr_t, ptr %13, i32 0, i32 0
  %15 = getelementptr inbounds %struct.gnode_t, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = load ptr, ptr %7, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.gnode_keyword_expr_t, ptr %17, i32 0, i32 0
  %19 = getelementptr inbounds %struct.gnode_t, ptr %18, i32 0, i32 0
  %20 = load i32, ptr %19, align 8, !tbaa !9
  %21 = icmp ne i32 %16, %20
  br i1 %21, label %22, label %23

22:                                               ; preds = %2
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %95

23:                                               ; preds = %2
  %24 = load ptr, ptr %4, align 8, !tbaa !5
  %25 = call zeroext i1 @gnode_is_literal(ptr noundef %24)
  br i1 %25, label %26, label %94

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #3
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %27, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %28 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %28, ptr %10, align 8, !tbaa !5
  %29 = load ptr, ptr %9, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %29, i32 0, i32 1
  %31 = load i32, ptr %30, align 8, !tbaa !15
  %32 = load ptr, ptr %10, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %32, i32 0, i32 1
  %34 = load i32, ptr %33, align 8, !tbaa !15
  %35 = icmp ne i32 %31, %34
  br i1 %35, label %36, label %37

36:                                               ; preds = %26
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %91

37:                                               ; preds = %26
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %38, i32 0, i32 1
  %40 = load i32, ptr %39, align 8, !tbaa !15
  %41 = icmp eq i32 %40, 3
  br i1 %41, label %42, label %50

42:                                               ; preds = %37
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %43, i32 0, i32 3
  %45 = load i64, ptr %44, align 8, !tbaa !17
  %46 = load ptr, ptr %10, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %46, i32 0, i32 3
  %48 = load i64, ptr %47, align 8, !tbaa !17
  %49 = icmp eq i64 %45, %48
  store i1 %49, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %91

50:                                               ; preds = %37
  %51 = load ptr, ptr %9, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %51, i32 0, i32 1
  %53 = load i32, ptr %52, align 8, !tbaa !15
  %54 = icmp eq i32 %53, 2
  br i1 %54, label %55, label %63

55:                                               ; preds = %50
  %56 = load ptr, ptr %9, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %56, i32 0, i32 3
  %58 = load i64, ptr %57, align 8, !tbaa !17
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %59, i32 0, i32 3
  %61 = load i64, ptr %60, align 8, !tbaa !17
  %62 = icmp eq i64 %58, %61
  store i1 %62, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %91

63:                                               ; preds = %50
  %64 = load ptr, ptr %9, align 8, !tbaa !5
  %65 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %64, i32 0, i32 1
  %66 = load i32, ptr %65, align 8, !tbaa !15
  %67 = icmp eq i32 %66, 1
  br i1 %67, label %68, label %76

68:                                               ; preds = %63
  %69 = load ptr, ptr %9, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %69, i32 0, i32 3
  %71 = load double, ptr %70, align 8, !tbaa !17
  %72 = load ptr, ptr %10, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %72, i32 0, i32 3
  %74 = load double, ptr %73, align 8, !tbaa !17
  %75 = fcmp oeq double %71, %74
  store i1 %75, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %91

76:                                               ; preds = %63
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %77, i32 0, i32 1
  %79 = load i32, ptr %78, align 8, !tbaa !15
  %80 = icmp eq i32 %79, 0
  br i1 %80, label %81, label %90

81:                                               ; preds = %76
  %82 = load ptr, ptr %9, align 8, !tbaa !5
  %83 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %82, i32 0, i32 3
  %84 = load ptr, ptr %83, align 8, !tbaa !17
  %85 = load ptr, ptr %10, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.gnode_literal_expr_t, ptr %85, i32 0, i32 3
  %87 = load ptr, ptr %86, align 8, !tbaa !17
  %88 = call i32 @strcmp(ptr noundef %84, ptr noundef %87) #4
  %89 = icmp eq i32 %88, 0
  store i1 %89, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %91

90:                                               ; preds = %76
  store i32 0, ptr %8, align 4
  br label %91

91:                                               ; preds = %90, %81, %68, %55, %42, %36
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #3
  %92 = load i32, ptr %8, align 4
  switch i32 %92, label %95 [
    i32 0, label %93
  ]

93:                                               ; preds = %91
  br label %94

94:                                               ; preds = %93, %23
  store i1 false, ptr %3, align 1
  store i32 1, ptr %8, align 4
  br label %95

95:                                               ; preds = %94, %91, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %96 = load i1, ptr %3, align 1
  ret i1 %96
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @gnode_is_literal(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind willreturn memory(read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }
attributes #4 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !12, i64 0}
!10 = !{!"", !11, i64 0}
!11 = !{!"", !12, i64 0, !12, i64 4, !12, i64 8, !13, i64 16, !14, i64 56, !6, i64 64}
!12 = !{!"int", !7, i64 0}
!13 = !{!"gtoken_s", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12, !12, i64 16, !12, i64 20, !12, i64 24, !12, i64 28, !6, i64 32}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!16, !12, i64 72}
!16 = !{!"", !11, i64 0, !12, i64 72, !12, i64 76, !7, i64 80}
!17 = !{!7, !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local zeroext i1 @gnode_is_equal(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #1 {
  %3 = load i32, ptr %0, align 8, !tbaa !5
  %4 = load i32, ptr %1, align 8, !tbaa !5
  %.not = icmp eq i32 %3, %4
  br i1 %.not, label %5, label %.thread

5:                                                ; preds = %2
  %6 = tail call zeroext i1 @gnode_is_literal(ptr noundef nonnull %0)
  br i1 %6, label %7, label %.thread

7:                                                ; preds = %5
  %8 = getelementptr inbounds i8, ptr %0, i64 72
  %9 = load i32, ptr %8, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %1, i64 72
  %11 = load i32, ptr %10, align 8, !tbaa !14
  %.not24 = icmp eq i32 %9, %11
  br i1 %.not24, label %12, label %.thread

12:                                               ; preds = %7
  switch i32 %9, label %.thread [
    i32 3, label %13
    i32 2, label %19
    i32 1, label %25
    i32 0, label %31
  ]

13:                                               ; preds = %12
  %14 = getelementptr inbounds i8, ptr %0, i64 80
  %15 = load i64, ptr %14, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %1, i64 80
  %17 = load i64, ptr %16, align 8, !tbaa !16
  %18 = icmp eq i64 %15, %17
  br label %.thread

19:                                               ; preds = %12
  %20 = getelementptr inbounds i8, ptr %0, i64 80
  %21 = load i64, ptr %20, align 8, !tbaa !16
  %22 = getelementptr inbounds i8, ptr %1, i64 80
  %23 = load i64, ptr %22, align 8, !tbaa !16
  %24 = icmp eq i64 %21, %23
  br label %.thread

25:                                               ; preds = %12
  %26 = getelementptr inbounds i8, ptr %0, i64 80
  %27 = load double, ptr %26, align 8, !tbaa !16
  %28 = getelementptr inbounds i8, ptr %1, i64 80
  %29 = load double, ptr %28, align 8, !tbaa !16
  %30 = fcmp oeq double %27, %29
  br label %.thread

31:                                               ; preds = %12
  %32 = getelementptr inbounds i8, ptr %0, i64 80
  %33 = load ptr, ptr %32, align 8, !tbaa !16
  %34 = getelementptr inbounds i8, ptr %1, i64 80
  %35 = load ptr, ptr %34, align 8, !tbaa !16
  %36 = tail call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %33, ptr noundef nonnull dereferenceable(1) %35) #2
  %37 = icmp eq i32 %36, 0
  br label %.thread

.thread:                                          ; preds = %7, %31, %25, %19, %13, %5, %12, %2
  %.1 = phi i1 [ false, %2 ], [ false, %12 ], [ false, %5 ], [ false, %7 ], [ %37, %31 ], [ %30, %25 ], [ %24, %19 ], [ %18, %13 ]
  ret i1 %.1
}

; Function Attrs: nounwind uwtable
declare dso_local zeroext i1 @gnode_is_literal(ptr noundef) local_unnamed_addr #1

attributes #0 = { mustprogress nofree nounwind willreturn memory(argmem: read) "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { nounwind willreturn memory(read) }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !8, i64 0}
!6 = !{!"", !7, i64 0}
!7 = !{!"", !8, i64 0, !8, i64 4, !8, i64 8, !11, i64 16, !13, i64 56, !12, i64 64}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C/C++ TBAA"}
!11 = !{!"gtoken_s", !8, i64 0, !8, i64 4, !8, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28, !12, i64 32}
!12 = !{!"any pointer", !9, i64 0}
!13 = !{!"_Bool", !9, i64 0}
!14 = !{!15, !8, i64 72}
!15 = !{!"", !7, i64 0, !8, i64 72, !8, i64 76, !9, i64 80}
!16 = !{!9, !9, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass