; LLVM IR from ponylang/ponyc :: src/libponyc/ast (parserapi)

; 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.parser_t = type { ptr, ptr, ptr, ptr, ptr, i32, i8, i8, ptr, i8 }
%struct.rule_state_t = type { ptr, ptr, ptr, ptr, ptr, i32, i8, i8, i8, i32, i64, i64 }

@.str.1 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.add_deferrable_ast = external hidden unnamed_addr constant [19 x i8], align 1

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

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

11:                                               ; preds = %4
  %12 = load ptr, ptr %5, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.parser_t, ptr %12, i32 0, i32 2
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  store ptr %14, ptr %8, align 8, !tbaa !5
  br label %15

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

18:                                               ; preds = %15
  br label %20

19:                                               ; preds = %15
  call void @ponyint_assert_fail(ptr noundef @.str.3, ptr noundef @.str.1, i64 noundef 218, ptr noundef @__func__.add_deferrable_ast)
  br label %20

20:                                               ; preds = %19, %18
  %21 = load ptr, ptr %6, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.rule_state_t, ptr %21, i32 0, i32 6
  %23 = load i8, ptr %22, align 4, !tbaa !14, !range !17, !noundef !18
  %24 = trunc i8 %23 to i1
  br i1 %24, label %49, label %25

25:                                               ; preds = %20
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.rule_state_t, ptr %26, i32 0, i32 1
  %28 = load ptr, ptr %27, align 8, !tbaa !19
  %29 = icmp eq ptr %28, null
  br i1 %29, label %30, label %49

30:                                               ; preds = %25
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.rule_state_t, ptr %31, i32 0, i32 8
  %33 = load i8, ptr %32, align 2, !tbaa !20, !range !17, !noundef !18
  %34 = trunc i8 %33 to i1
  br i1 %34, label %49, label %35

35:                                               ; preds = %30
  %36 = load ptr, ptr %6, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.rule_state_t, ptr %36, i32 0, i32 8
  store i8 1, ptr %37, align 2, !tbaa !20
  %38 = load i32, ptr %7, align 4, !tbaa !9
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.rule_state_t, ptr %39, i32 0, i32 9
  store i32 %38, ptr %40, align 8, !tbaa !21
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = call i64 @token_line_number(ptr noundef %41)
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.rule_state_t, ptr %43, i32 0, i32 10
  store i64 %42, ptr %44, align 8, !tbaa !22
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = call i64 @token_line_position(ptr noundef %45)
  %47 = load ptr, ptr %6, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.rule_state_t, ptr %47, i32 0, i32 11
  store i64 %46, ptr %48, align 8, !tbaa !23
  br label %55

49:                                               ; preds = %30, %25, %20
  %50 = load ptr, ptr %5, align 8, !tbaa !5
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = load ptr, ptr %8, align 8, !tbaa !5
  %53 = load i32, ptr %7, align 4, !tbaa !9
  %54 = call ptr @ast_new(ptr noundef %52, i32 noundef %53)
  call void @add_ast(ptr noundef %50, ptr noundef %51, ptr noundef %54, ptr noundef @default_builder)
  br label %55

55:                                               ; preds = %49, %35
  ret void
}

declare i64 @token_line_number(ptr noundef) #0

declare i64 @token_line_position(ptr noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @add_ast(ptr noundef, ptr noundef, ptr noundef, ptr noundef) #1

declare ptr @ast_new(ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
declare hidden void @default_builder(ptr noundef, ptr noundef) #1

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

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"parser_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !13, i64 44, !13, i64 45, !6, i64 48, !13, i64 56}
!13 = !{!"_Bool", !7, i64 0}
!14 = !{!15, !13, i64 44}
!15 = !{!"rule_state_t", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !13, i64 44, !13, i64 45, !13, i64 46, !10, i64 48, !16, i64 56, !16, i64 64}
!16 = !{!"long", !7, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!15, !6, i64 8}
!20 = !{!15, !13, i64 46}
!21 = !{!15, !10, i64 48}
!22 = !{!15, !16, i64 56}
!23 = !{!15, !16, i64 64}


; 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.1 = external hidden unnamed_addr constant [77 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [22 x i8], align 1
@__func__.add_deferrable_ast = external hidden unnamed_addr constant [19 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @add_deferrable_ast(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) local_unnamed_addr #1 {
  %5 = icmp eq ptr %3, null
  br i1 %5, label %6, label %.thread

6:                                                ; preds = %4
  %7 = getelementptr inbounds i8, ptr %0, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %9, label %.thread

9:                                                ; preds = %6
  tail call void @ponyint_assert_fail(ptr noundef nonnull @.str.3, ptr noundef nonnull @.str.1, i64 noundef 218, ptr noundef nonnull @__func__.add_deferrable_ast) #2
  br label %.thread

.thread:                                          ; preds = %4, %6, %9
  %.019 = phi ptr [ %8, %6 ], [ null, %9 ], [ %3, %4 ]
  %10 = getelementptr inbounds i8, ptr %1, i64 44
  %11 = load i8, ptr %10, align 4, !tbaa !12, !range !15, !noundef !16
  %12 = trunc nuw i8 %11 to i1
  br i1 %12, label %27, label %13

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

17:                                               ; preds = %13
  %18 = getelementptr inbounds i8, ptr %1, i64 46
  %19 = load i8, ptr %18, align 2, !tbaa !18, !range !15, !noundef !16
  %20 = trunc nuw i8 %19 to i1
  br i1 %20, label %27, label %21

21:                                               ; preds = %17
  store i8 1, ptr %18, align 2, !tbaa !18
  %22 = getelementptr inbounds i8, ptr %1, i64 48
  store i32 %2, ptr %22, align 8, !tbaa !19
  %23 = tail call i64 @token_line_number(ptr noundef %.019) #2
  %24 = getelementptr inbounds i8, ptr %1, i64 56
  store i64 %23, ptr %24, align 8, !tbaa !20
  %25 = tail call i64 @token_line_position(ptr noundef %.019) #2
  %26 = getelementptr inbounds i8, ptr %1, i64 64
  store i64 %25, ptr %26, align 8, !tbaa !21
  br label %29

27:                                               ; preds = %17, %13, %.thread
  %28 = tail call ptr @ast_new(ptr noundef %.019, i32 noundef %2) #2
  tail call void @add_ast(ptr noundef %0, ptr noundef nonnull %1, ptr noundef %28, ptr noundef nonnull @default_builder)
  br label %29

29:                                               ; preds = %27, %21
  ret void
}

declare i64 @token_line_number(ptr noundef) local_unnamed_addr #0

declare i64 @token_line_position(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @add_ast(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @ast_new(ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @default_builder(ptr noundef, ptr noundef) #1

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

!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 16}
!6 = !{!"parser_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !11, i64 44, !11, i64 45, !7, i64 48, !11, i64 56}
!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 = !{!13, !11, i64 44}
!13 = !{!"rule_state_t", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !11, i64 44, !11, i64 45, !11, i64 46, !10, i64 48, !14, i64 56, !14, i64 64}
!14 = !{!"long", !8, i64 0}
!15 = !{i8 0, i8 2}
!16 = !{}
!17 = !{!13, !7, i64 8}
!18 = !{!13, !11, i64 46}
!19 = !{!13, !10, i64 48}
!20 = !{!13, !14, i64 56}
!21 = !{!13, !14, i64 64}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,JumpThreadingPass,SROAPass,SimplifyCFGPass,TailCallElimPass