; LLVM IR from ponylang/ponyc :: src/libponyc/ast (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.ast_t = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i8 }
%struct.symbol_t = type { ptr, ptr, i32, i64 }

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [15 x i8], align 1
@__func__.ast_consolidate_branches = external hidden unnamed_addr constant [25 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [27 x i8], align 1

; 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

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @ast_get(ptr noundef, ptr noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @ast_consolidate_branches(ptr noundef %0, i64 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp ne ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %2
  br label %12

11:                                               ; preds = %2
  call void @ponyint_assert_fail(ptr noundef @.str, ptr noundef @.str.1, i64 noundef 1243, ptr noundef @__func__.ast_consolidate_branches)
  br label %12

12:                                               ; preds = %11, %10
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call zeroext i1 @hasparent(ptr noundef %13)
  br i1 %14, label %15, label %16

15:                                               ; preds = %12
  br label %17

16:                                               ; preds = %12
  call void @ponyint_assert_fail(ptr noundef @.str.12, ptr noundef @.str.1, i64 noundef 1244, ptr noundef @__func__.ast_consolidate_branches)
  br label %17

17:                                               ; preds = %16, %15
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.ast_t, ptr %18, i32 0, i32 1
  %20 = load ptr, ptr %19, align 8, !tbaa !11
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %23

22:                                               ; preds = %17
  br label %24

23:                                               ; preds = %17
  call void @ponyint_assert_fail(ptr noundef @.str.18, ptr noundef @.str.1, i64 noundef 1245, ptr noundef @__func__.ast_consolidate_branches)
  br label %24

24:                                               ; preds = %23, %22
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.ast_t, ptr %25, i32 0, i32 8
  %27 = load i8, ptr %26, align 4, !tbaa !15, !range !16, !noundef !17
  %28 = trunc i8 %27 to i1
  br i1 %28, label %30, label %29

29:                                               ; preds = %24
  br label %31

30:                                               ; preds = %24
  call void @ponyint_assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 1247, ptr noundef @__func__.ast_consolidate_branches)
  br label %31

31:                                               ; preds = %30, %29
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  store i64 -1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  br label %32

32:                                               ; preds = %74, %31
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ast_t, ptr %33, i32 0, i32 1
  %35 = load ptr, ptr %34, align 8, !tbaa !11
  %36 = call ptr @symtab_next(ptr noundef %35, ptr noundef %5)
  store ptr %36, ptr %6, align 8, !tbaa !5
  %37 = icmp ne ptr %36, null
  br i1 %37, label %38, label %75

38:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %39 = load ptr, ptr %3, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ast_t, ptr %39, i32 0, i32 3
  %41 = load ptr, ptr %40, align 8, !tbaa !18
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.symbol_t, ptr %42, i32 0, i32 0
  %44 = load ptr, ptr %43, align 8, !tbaa !19
  %45 = call ptr @ast_get(ptr noundef %41, ptr noundef %44, ptr noundef %7)
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.symbol_t, ptr %46, i32 0, i32 2
  %48 = load i32, ptr %47, align 8, !tbaa !21
  %49 = icmp eq i32 %48, 3
  br i1 %49, label %50, label %74

50:                                               ; preds = %38
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.symbol_t, ptr %51, i32 0, i32 3
  %53 = load i64, ptr %52, align 8, !tbaa !22
  %54 = load i64, ptr %4, align 8, !tbaa !9
  %55 = icmp ule i64 %53, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %50
  br label %58

57:                                               ; preds = %50
  call void @ponyint_assert_fail(ptr noundef @.str.19, ptr noundef @.str.1, i64 noundef 1260, ptr noundef @__func__.ast_consolidate_branches)
  br label %58

58:                                               ; preds = %57, %56
  %59 = load i32, ptr %7, align 4, !tbaa !23
  %60 = icmp eq i32 %59, 2
  br i1 %60, label %67, label %61

61:                                               ; preds = %58
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.symbol_t, ptr %62, i32 0, i32 3
  %64 = load i64, ptr %63, align 8, !tbaa !22
  %65 = load i64, ptr %4, align 8, !tbaa !9
  %66 = icmp eq i64 %64, %65
  br i1 %66, label %67, label %70

67:                                               ; preds = %61, %58
  %68 = load ptr, ptr %6, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.symbol_t, ptr %68, i32 0, i32 2
  store i32 2, ptr %69, align 8, !tbaa !21
  br label %73

70:                                               ; preds = %61
  %71 = load ptr, ptr %6, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.symbol_t, ptr %71, i32 0, i32 3
  store i64 0, ptr %72, align 8, !tbaa !22
  br label %73

73:                                               ; preds = %70, %67
  br label %74

74:                                               ; preds = %73, %38
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  br label %32, !llvm.loop !24

75:                                               ; preds = %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

declare ptr @symtab_next(ptr noundef, ptr noundef) #1

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

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 8}
!12 = !{!"ast_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !13, i64 56, !14, i64 60}
!13 = !{!"int", !7, i64 0}
!14 = !{!"_Bool", !7, i64 0}
!15 = !{!12, !14, i64 60}
!16 = !{i8 0, i8 2}
!17 = !{}
!18 = !{!12, !6, i64 24}
!19 = !{!20, !6, i64 0}
!20 = !{!"symbol_t", !6, i64 0, !6, i64 8, !13, i64 16, !10, i64 24}
!21 = !{!20, !13, i64 16}
!22 = !{!20, !10, i64 24}
!23 = !{!13, !13, i64 0}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


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

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [71 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [15 x i8], align 1
@__func__.ast_consolidate_branches = external hidden unnamed_addr constant [25 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [27 x i8], align 1

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

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

declare void @ponyint_assert_fail(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden zeroext i1 @hasparent(ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare dso_local ptr @ast_get(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @ast_consolidate_branches(ptr noundef %0, i64 noundef %1) local_unnamed_addr #2 {
  %3 = alloca i64, align 8
  %4 = alloca i32, align 4
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %2
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i64 noundef 1243, ptr noundef nonnull @__func__.ast_consolidate_branches) #3
  br label %6

6:                                                ; preds = %2, %5
  %7 = tail call zeroext i1 @hasparent(ptr noundef %0)
  br i1 %7, label %9, label %8

8:                                                ; preds = %6
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.12, ptr noundef nonnull @.str.1, i64 noundef 1244, ptr noundef nonnull @__func__.ast_consolidate_branches) #3
  br label %9

9:                                                ; preds = %6, %8
  %10 = getelementptr inbounds i8, ptr %0, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %.not13 = icmp eq ptr %11, null
  br i1 %.not13, label %12, label %13

12:                                               ; preds = %9
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.18, ptr noundef nonnull @.str.1, i64 noundef 1245, ptr noundef nonnull @__func__.ast_consolidate_branches) #3
  br label %13

13:                                               ; preds = %9, %12
  %14 = getelementptr inbounds i8, ptr %0, i64 60
  %15 = load i8, ptr %14, align 4, !tbaa !12, !range !13, !noundef !14
  %16 = trunc nuw i8 %15 to i1
  br i1 %16, label %17, label %18

17:                                               ; preds = %13
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i64 noundef 1247, ptr noundef nonnull @__func__.ast_consolidate_branches) #3
  br label %18

18:                                               ; preds = %13, %17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  store i64 -1, ptr %3, align 8, !tbaa !15
  %19 = load ptr, ptr %10, align 8, !tbaa !5
  %20 = call ptr @symtab_next(ptr noundef %19, ptr noundef nonnull %3) #3
  %.not1416 = icmp eq ptr %20, null
  br i1 %.not1416, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %18
  %21 = getelementptr inbounds i8, ptr %0, i64 24
  br label %22

22:                                               ; preds = %.lr.ph, %42
  %23 = phi ptr [ %20, %.lr.ph ], [ %44, %42 ]
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #3
  %24 = load ptr, ptr %21, align 8, !tbaa !17
  %25 = load ptr, ptr %23, align 8, !tbaa !18
  %26 = call ptr @ast_get(ptr noundef %24, ptr noundef %25, ptr noundef nonnull %4)
  %27 = getelementptr inbounds i8, ptr %23, i64 16
  %28 = load i32, ptr %27, align 8, !tbaa !20
  %29 = icmp eq i32 %28, 3
  br i1 %29, label %30, label %42

30:                                               ; preds = %22
  %31 = getelementptr inbounds i8, ptr %23, i64 24
  %32 = load i64, ptr %31, align 8, !tbaa !21
  %.not15 = icmp ugt i64 %32, %1
  br i1 %.not15, label %33, label %34

33:                                               ; preds = %30
  call void @ponyint_assert_fail(ptr noundef nonnull @.str.19, ptr noundef nonnull @.str.1, i64 noundef 1260, ptr noundef nonnull @__func__.ast_consolidate_branches) #3
  br label %34

34:                                               ; preds = %30, %33
  %35 = load i32, ptr %4, align 4, !tbaa !22
  %36 = icmp eq i32 %35, 2
  br i1 %36, label %40, label %37

37:                                               ; preds = %34
  %38 = load i64, ptr %31, align 8, !tbaa !21
  %39 = icmp eq i64 %38, %1
  br i1 %39, label %40, label %41

40:                                               ; preds = %37, %34
  store i32 2, ptr %27, align 8, !tbaa !20
  br label %42

41:                                               ; preds = %37
  store i64 0, ptr %31, align 8, !tbaa !21
  br label %42

42:                                               ; preds = %40, %41, %22
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #3
  %43 = load ptr, ptr %10, align 8, !tbaa !5
  %44 = call ptr @symtab_next(ptr noundef %43, ptr noundef nonnull %3) #3
  %.not14 = icmp eq ptr %44, null
  br i1 %.not14, label %._crit_edge, label %22, !llvm.loop !23

._crit_edge:                                      ; preds = %42, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  ret void
}

declare ptr @symtab_next(ptr noundef, ptr noundef) local_unnamed_addr #1

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

!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, !7, i64 8}
!6 = !{!"ast_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !10, i64 56, !11, i64 60}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!6, !11, i64 60}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{!6, !7, i64 24}
!18 = !{!19, !7, i64 0}
!19 = !{!"symbol_t", !7, i64 0, !7, i64 8, !10, i64 16, !16, i64 24}
!20 = !{!19, !10, i64 16}
!21 = !{!19, !16, i64 24}
!22 = !{!10, !10, i64 0}
!23 = distinct !{!23, !24}
!24 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass