; 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_class_decl_t = type { %struct.gnode_t, i8, i8, ptr, i32, i32, ptr, ptr, i8, ptr, ptr, ptr, ptr, i32, i32 }
%struct.gravity_class_s = type { ptr, %struct.gravity_gc_s, ptr, ptr, i8, i8, i8, i8, ptr, ptr, ptr, ptr, i32, ptr }
%struct.gravity_gc_s = type { i8, i8, ptr, ptr, ptr, ptr }
%struct.gnode_var_t = type { %struct.gnode_t, ptr, ptr, ptr, ptr, i32, i16, i8, i8, ptr }
%struct.gnode_variable_decl_t = type { %struct.gnode_t, i32, i32, i32, ptr }

@gravity_class_class = external global ptr, align 8

; 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 uwtable
define dso_local ptr @gnode2class(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %15

13:                                               ; preds = %2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  store i8 0, ptr %14, align 1, !tbaa !9
  br label %15

15:                                               ; preds = %13, %2
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %37

18:                                               ; preds = %15
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.gnode_keyword_expr_t, ptr %19, i32 0, i32 0
  %21 = getelementptr inbounds %struct.gnode_t, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 8, !tbaa !11
  %23 = icmp eq i32 %22, 10
  br i1 %23, label %24, label %37

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %25, ptr %6, align 8, !tbaa !5
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %35

28:                                               ; preds = %24
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.gnode_class_decl_t, ptr %29, i32 0, i32 5
  %31 = load i32, ptr %30, align 4, !tbaa !16
  %32 = icmp eq i32 %31, 31
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = zext i1 %32 to i8
  store i8 %34, ptr %33, align 1, !tbaa !9
  br label %35

35:                                               ; preds = %28, %24
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %36, ptr %3, align 8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  br label %103

37:                                               ; preds = %18, %15
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = icmp ne ptr %38, null
  br i1 %39, label %40, label %101

40:                                               ; preds = %37
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.gnode_keyword_expr_t, ptr %41, i32 0, i32 0
  %43 = getelementptr inbounds %struct.gnode_t, ptr %42, i32 0, i32 0
  %44 = load i32, ptr %43, align 8, !tbaa !11
  %45 = icmp eq i32 %44, 12
  br i1 %45, label %46, label %101

46:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %47, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %48 = load ptr, ptr @gravity_class_class, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.gravity_class_s, ptr %48, i32 0, i32 3
  %50 = load ptr, ptr %49, align 8, !tbaa !18
  store ptr %50, ptr %8, align 8, !tbaa !5
  %51 = load ptr, ptr %7, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.gnode_var_t, ptr %51, i32 0, i32 3
  %53 = load ptr, ptr %52, align 8, !tbaa !21
  %54 = icmp ne ptr %53, null
  br i1 %54, label %55, label %79

55:                                               ; preds = %46
  %56 = load ptr, ptr %7, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.gnode_var_t, ptr %56, i32 0, i32 3
  %58 = load ptr, ptr %57, align 8, !tbaa !21
  %59 = load ptr, ptr %8, align 8, !tbaa !5
  %60 = call i32 @string_cmp(ptr noundef %58, ptr noundef %59)
  %61 = icmp eq i32 %60, 0
  br i1 %61, label %62, label %79

62:                                               ; preds = %55
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.gnode_var_t, ptr %63, i32 0, i32 4
  %65 = load ptr, ptr %64, align 8, !tbaa !24
  %66 = icmp ne ptr %65, null
  br i1 %66, label %67, label %79

67:                                               ; preds = %62
  %68 = load ptr, ptr %7, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.gnode_var_t, ptr %68, i32 0, i32 4
  %70 = load ptr, ptr %69, align 8, !tbaa !24
  %71 = getelementptr inbounds %struct.gnode_keyword_expr_t, ptr %70, i32 0, i32 0
  %72 = getelementptr inbounds %struct.gnode_t, ptr %71, i32 0, i32 0
  %73 = load i32, ptr %72, align 8, !tbaa !11
  %74 = icmp eq i32 %73, 10
  br i1 %74, label %75, label %79

75:                                               ; preds = %67
  %76 = load ptr, ptr %7, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.gnode_var_t, ptr %76, i32 0, i32 4
  %78 = load ptr, ptr %77, align 8, !tbaa !24
  store ptr %78, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %98

79:                                               ; preds = %67, %62, %55, %46
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.gnode_var_t, ptr %80, i32 0, i32 9
  %82 = load ptr, ptr %81, align 8, !tbaa !25
  store ptr %82, ptr %10, align 8, !tbaa !5
  %83 = load ptr, ptr %10, align 8, !tbaa !5
  %84 = icmp ne ptr %83, null
  br i1 %84, label %85, label %96

85:                                               ; preds = %79
  %86 = load ptr, ptr %5, align 8, !tbaa !5
  %87 = icmp ne ptr %86, null
  br i1 %87, label %88, label %96

88:                                               ; preds = %85
  %89 = load ptr, ptr %10, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.gnode_variable_decl_t, ptr %89, i32 0, i32 3
  %91 = load i32, ptr %90, align 8, !tbaa !26
  %92 = icmp eq i32 %91, 31
  br i1 %92, label %93, label %96

93:                                               ; preds = %88
  %94 = load ptr, ptr %5, align 8, !tbaa !5
  store i8 1, ptr %94, align 1, !tbaa !9
  %95 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %95, ptr %3, align 8
  store i32 1, ptr %9, align 4
  br label %97

96:                                               ; preds = %88, %85, %79
  store i32 0, ptr %9, align 4
  br label %97

97:                                               ; preds = %96, %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %98

98:                                               ; preds = %97, %75
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  %99 = load i32, ptr %9, align 4
  switch i32 %99, label %105 [
    i32 0, label %100
    i32 1, label %103
  ]

100:                                              ; preds = %98
  br label %101

101:                                              ; preds = %100, %40, %37
  br label %102

102:                                              ; preds = %101
  store ptr null, ptr %3, align 8
  br label %103

103:                                              ; preds = %102, %98, %35
  %104 = load ptr, ptr %3, align 8
  ret ptr %104

105:                                              ; preds = %98
  unreachable
}

declare i32 @string_cmp(ptr noundef, ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }

!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, !10, i64 0}
!10 = !{!"_Bool", !7, i64 0}
!11 = !{!12, !14, i64 0}
!12 = !{!"", !13, i64 0}
!13 = !{!"", !14, i64 0, !14, i64 4, !14, i64 8, !15, i64 16, !10, i64 56, !6, i64 64}
!14 = !{!"int", !7, i64 0}
!15 = !{!"gtoken_s", !14, i64 0, !14, i64 4, !14, i64 8, !14, i64 12, !14, i64 16, !14, i64 20, !14, i64 24, !14, i64 28, !6, i64 32}
!16 = !{!17, !14, i64 92}
!17 = !{!"", !13, i64 0, !10, i64 72, !10, i64 73, !6, i64 80, !14, i64 88, !14, i64 92, !6, i64 96, !6, i64 104, !10, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !14, i64 152, !14, i64 156}
!18 = !{!19, !6, i64 56}
!19 = !{!"gravity_class_s", !6, i64 0, !20, i64 8, !6, i64 48, !6, i64 56, !10, i64 64, !10, i64 65, !10, i64 66, !10, i64 67, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !14, i64 104, !6, i64 112}
!20 = !{!"gravity_gc_s", !10, i64 0, !10, i64 1, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32}
!21 = !{!22, !6, i64 88}
!22 = !{!"", !13, i64 0, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !14, i64 104, !23, i64 108, !10, i64 110, !10, i64 111, !6, i64 112}
!23 = !{!"short", !7, i64 0}
!24 = !{!22, !6, i64 96}
!25 = !{!22, !6, i64 112}
!26 = !{!27, !14, i64 80}
!27 = !{!"", !13, i64 0, !14, i64 72, !14, i64 76, !14, i64 80, !6, i64 88}


; 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"

@gravity_class_class = external local_unnamed_addr global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local ptr @gnode2class(ptr noundef readonly %0, ptr noundef writeonly %1) local_unnamed_addr #0 {
  %3 = icmp ne ptr %1, null
  br i1 %3, label %4, label %5

4:                                                ; preds = %2
  store i8 0, ptr %1, align 1, !tbaa !5
  br label %5

5:                                                ; preds = %4, %2
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %.critedge, label %6

6:                                                ; preds = %5
  %7 = load i32, ptr %0, align 8, !tbaa !9
  switch i32 %7, label %.critedge [
    i32 10, label %8
    i32 12, label %14
  ]

8:                                                ; preds = %6
  br i1 %3, label %9, label %.critedge

9:                                                ; preds = %8
  %10 = getelementptr inbounds i8, ptr %0, i64 92
  %11 = load i32, ptr %10, align 4, !tbaa !15
  %12 = icmp eq i32 %11, 31
  %13 = zext i1 %12 to i8
  br label %.critedge.sink.split

14:                                               ; preds = %6
  %15 = getelementptr inbounds i8, ptr %0, i64 88
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  %.not35 = icmp eq ptr %16, null
  br i1 %.not35, label %29, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr @gravity_class_class, align 8, !tbaa !20
  %19 = getelementptr inbounds i8, ptr %18, i64 56
  %20 = load ptr, ptr %19, align 8, !tbaa !21
  %21 = tail call i32 @string_cmp(ptr noundef nonnull %16, ptr noundef %20) #2
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %29

23:                                               ; preds = %17
  %24 = getelementptr inbounds i8, ptr %0, i64 96
  %25 = load ptr, ptr %24, align 8, !tbaa !24
  %.not36 = icmp eq ptr %25, null
  br i1 %.not36, label %29, label %26

26:                                               ; preds = %23
  %27 = load i32, ptr %25, align 8, !tbaa !9
  %28 = icmp eq i32 %27, 10
  br i1 %28, label %.critedge, label %29

29:                                               ; preds = %26, %23, %17, %14
  %30 = getelementptr inbounds i8, ptr %0, i64 112
  %31 = load ptr, ptr %30, align 8, !tbaa !25
  %32 = icmp ne ptr %31, null
  %or.cond = and i1 %3, %32
  br i1 %or.cond, label %33, label %.critedge

33:                                               ; preds = %29
  %34 = getelementptr inbounds i8, ptr %31, i64 80
  %35 = load i32, ptr %34, align 8, !tbaa !26
  %36 = icmp eq i32 %35, 31
  br i1 %36, label %.critedge.sink.split, label %.critedge

.critedge.sink.split:                             ; preds = %33, %9
  %.sink = phi i8 [ %13, %9 ], [ 1, %33 ]
  store i8 %.sink, ptr %1, align 1, !tbaa !5
  br label %.critedge

.critedge:                                        ; preds = %.critedge.sink.split, %6, %29, %33, %5, %26, %8
  %.2 = phi ptr [ %0, %8 ], [ %25, %26 ], [ null, %5 ], [ null, %33 ], [ null, %29 ], [ null, %6 ], [ %0, %.critedge.sink.split ]
  ret ptr %.2
}

declare i32 @string_cmp(ptr noundef, ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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 }

!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 = !{!"_Bool", !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, !6, i64 56, !14, 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, !14, i64 32}
!14 = !{!"any pointer", !7, i64 0}
!15 = !{!16, !12, i64 92}
!16 = !{!"", !11, i64 0, !6, i64 72, !6, i64 73, !14, i64 80, !12, i64 88, !12, i64 92, !14, i64 96, !14, i64 104, !6, i64 112, !14, i64 120, !14, i64 128, !14, i64 136, !14, i64 144, !12, i64 152, !12, i64 156}
!17 = !{!18, !14, i64 88}
!18 = !{!"", !11, i64 0, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !12, i64 104, !19, i64 108, !6, i64 110, !6, i64 111, !14, i64 112}
!19 = !{!"short", !7, i64 0}
!20 = !{!14, !14, i64 0}
!21 = !{!22, !14, i64 56}
!22 = !{!"gravity_class_s", !14, i64 0, !23, i64 8, !14, i64 48, !14, i64 56, !6, i64 64, !6, i64 65, !6, i64 66, !6, i64 67, !14, i64 72, !14, i64 80, !14, i64 88, !14, i64 96, !12, i64 104, !14, i64 112}
!23 = !{!"gravity_gc_s", !6, i64 0, !6, i64 1, !14, i64 8, !14, i64 16, !14, i64 24, !14, i64 32}
!24 = !{!18, !14, i64 96}
!25 = !{!18, !14, i64 112}
!26 = !{!27, !12, i64 80}
!27 = !{!"", !11, i64 0, !12, i64 72, !12, i64 76, !12, i64 80, !14, i64 88}


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