; LLVM IR from freddiev4/dailyprogrammerchallenges :: Intermediate Challenges/Challenge 0004 Intermediate/solutions (solution)

; 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.Token = type { i8, ptr }

@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [21 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: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @parse(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca %struct.Token, align 8
  %7 = alloca %struct.Token, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i8, align 1
  %10 = alloca %struct.Token, align 8
  %11 = alloca i32, align 4
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #5
  %15 = call ptr @Explist_new()
  store ptr %15, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #5
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr null, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #5
  store i8 0, ptr %9, align 1, !tbaa !9
  br label %16

16:                                               ; preds = %135, %133, %29, %1
  %17 = load i8, ptr %9, align 1, !tbaa !9, !range !11, !noundef !12
  %18 = trunc i8 %17 to i1
  %19 = xor i1 %18, true
  br i1 %19, label %20, label %136

20:                                               ; preds = %16
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #5
  %21 = call { i8, ptr } @next_token(ptr noundef %3)
  %22 = getelementptr inbounds { i8, ptr }, ptr %10, i32 0, i32 0
  %23 = extractvalue { i8, ptr } %21, 0
  store i8 %23, ptr %22, align 8
  %24 = getelementptr inbounds { i8, ptr }, ptr %10, i32 0, i32 1
  %25 = extractvalue { i8, ptr } %21, 1
  store ptr %25, ptr %24, align 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %6, ptr align 8 %10, i64 16, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #5
  %26 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !15
  %28 = icmp eq ptr %27, null
  br i1 %28, label %29, label %30

29:                                               ; preds = %20
  store i8 1, ptr %9, align 1, !tbaa !9
  br label %16, !llvm.loop !17

30:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #5
  %31 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !15
  %33 = call i32 @AST_gettype(ptr noundef %32)
  store i32 %33, ptr %11, align 4, !tbaa !19
  %34 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 0
  %35 = load i8, ptr %34, align 8, !tbaa !21
  %36 = sext i8 %35 to i32
  %37 = icmp eq i32 %36, 41
  br i1 %37, label %38, label %52

38:                                               ; preds = %30
  %39 = load i32, ptr %11, align 4, !tbaa !19
  %40 = icmp eq i32 %39, 0
  br i1 %40, label %46, label %41

41:                                               ; preds = %38
  %42 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 0
  %43 = load i8, ptr %42, align 8, !tbaa !21
  %44 = sext i8 %43 to i32
  %45 = icmp eq i32 %44, 40
  br i1 %45, label %46, label %52

46:                                               ; preds = %41, %38
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %47 = call ptr @AST_new()
  %48 = call ptr @AST_settype(ptr noundef %47, i32 noundef 6)
  store ptr %48, ptr %12, align 8, !tbaa !5
  %49 = load ptr, ptr %12, align 8, !tbaa !5
  %50 = load ptr, ptr %4, align 8, !tbaa !5
  %51 = call ptr @Explist_add(ptr noundef %49, ptr noundef %50)
  store ptr %51, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %73

52:                                               ; preds = %41, %30
  %53 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 1
  %54 = load ptr, ptr %53, align 8, !tbaa !15
  %55 = icmp ne ptr %54, null
  br i1 %55, label %56, label %72

56:                                               ; preds = %52
  %57 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 1
  %58 = load ptr, ptr %57, align 8, !tbaa !15
  %59 = call i32 @AST_gettype(ptr noundef %58)
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %72

61:                                               ; preds = %56
  %62 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 0
  %63 = load i8, ptr %62, align 8, !tbaa !21
  %64 = sext i8 %63 to i32
  %65 = icmp eq i32 %64, 40
  br i1 %65, label %66, label %72

66:                                               ; preds = %61
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #5
  %67 = call ptr @AST_new()
  %68 = call ptr @AST_settype(ptr noundef %67, i32 noundef 6)
  store ptr %68, ptr %13, align 8, !tbaa !5
  %69 = load ptr, ptr %13, align 8, !tbaa !5
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = call ptr @Explist_add(ptr noundef %69, ptr noundef %70)
  store ptr %71, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #5
  br label %72

72:                                               ; preds = %66, %61, %56, %52
  br label %73

73:                                               ; preds = %72, %46
  %74 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 0
  %75 = load i8, ptr %74, align 8, !tbaa !21
  %76 = sext i8 %75 to i32
  %77 = icmp eq i32 %76, 40
  br i1 %77, label %78, label %94

78:                                               ; preds = %73
  %79 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 1
  %80 = load ptr, ptr %79, align 8, !tbaa !15
  %81 = load ptr, ptr %4, align 8, !tbaa !5
  %82 = call ptr @Explist_add(ptr noundef %80, ptr noundef %81)
  store ptr %82, ptr %4, align 8, !tbaa !5
  %83 = call ptr @Explist_new()
  %84 = load ptr, ptr %4, align 8, !tbaa !5
  %85 = call ptr @Explist_prepend(ptr noundef %83, ptr noundef %84)
  store ptr %85, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 1
  call void @AST_free(ptr noundef %86)
  %87 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 0
  %88 = load i8, ptr %87, align 8, !tbaa !21
  %89 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 0
  store i8 %88, ptr %89, align 8, !tbaa !21
  %90 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 1
  %91 = load ptr, ptr %90, align 8, !tbaa !15
  %92 = call ptr @AST_copy(ptr noundef %91)
  %93 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 1
  store ptr %92, ptr %93, align 8, !tbaa !15
  store i32 2, ptr %14, align 4
  br label %133, !llvm.loop !17

94:                                               ; preds = %73
  %95 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 0
  %96 = load i8, ptr %95, align 8, !tbaa !21
  %97 = sext i8 %96 to i32
  %98 = icmp eq i32 %97, 41
  br i1 %98, label %99, label %120

99:                                               ; preds = %94
  %100 = load ptr, ptr %4, align 8, !tbaa !5
  %101 = call ptr @Explist_collapse(ptr noundef %100)
  store ptr %101, ptr %5, align 8, !tbaa !5
  %102 = load ptr, ptr %4, align 8, !tbaa !5
  %103 = load ptr, ptr %5, align 8, !tbaa !5
  %104 = icmp eq ptr %102, %103
  br i1 %104, label %105, label %109

105:                                              ; preds = %99
  %106 = load ptr, ptr @stderr, align 8, !tbaa !5
  %107 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %106, ptr noundef @.str.4, ptr noundef @.str.37) #5
  call void @Explist_free(ptr noundef %5)
  %108 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 1
  call void @AST_free(ptr noundef %108)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %133

109:                                              ; preds = %99
  %110 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %110, ptr %4, align 8, !tbaa !5
  %111 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 1
  call void @AST_free(ptr noundef %111)
  %112 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 1
  call void @AST_free(ptr noundef %112)
  %113 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 0
  %114 = load i8, ptr %113, align 8, !tbaa !21
  %115 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 0
  store i8 %114, ptr %115, align 8, !tbaa !21
  %116 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 1
  %117 = load ptr, ptr %116, align 8, !tbaa !15
  %118 = call ptr @AST_copy(ptr noundef %117)
  %119 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 1
  store ptr %118, ptr %119, align 8, !tbaa !15
  store i32 2, ptr %14, align 4
  br label %133, !llvm.loop !17

120:                                              ; preds = %94
  %121 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 1
  %122 = load ptr, ptr %121, align 8, !tbaa !15
  %123 = load ptr, ptr %4, align 8, !tbaa !5
  %124 = call ptr @Explist_add(ptr noundef %122, ptr noundef %123)
  store ptr %124, ptr %4, align 8, !tbaa !5
  %125 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 1
  call void @AST_free(ptr noundef %125)
  %126 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 0
  %127 = load i8, ptr %126, align 8, !tbaa !21
  %128 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 0
  store i8 %127, ptr %128, align 8, !tbaa !21
  %129 = getelementptr inbounds %struct.Token, ptr %6, i32 0, i32 1
  %130 = load ptr, ptr %129, align 8, !tbaa !15
  %131 = call ptr @AST_copy(ptr noundef %130)
  %132 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 1
  store ptr %131, ptr %132, align 8, !tbaa !15
  store i32 0, ptr %14, align 4
  br label %133

133:                                              ; preds = %120, %109, %105, %78
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #5
  %134 = load i32, ptr %14, align 4
  switch i32 %134, label %147 [
    i32 0, label %135
    i32 2, label %16
  ]

135:                                              ; preds = %133
  br label %16, !llvm.loop !17

136:                                              ; preds = %16
  %137 = load ptr, ptr %4, align 8, !tbaa !5
  %138 = call zeroext i1 @Explist_singleton(ptr noundef %137)
  br i1 %138, label %142, label %139

139:                                              ; preds = %136
  %140 = load ptr, ptr @stderr, align 8, !tbaa !5
  %141 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %140, ptr noundef @.str.4, ptr noundef @.str.38) #5
  br label %142

142:                                              ; preds = %139, %136
  %143 = load ptr, ptr %4, align 8, !tbaa !5
  %144 = call ptr @Explist_toAST(ptr noundef %143)
  store ptr %144, ptr %8, align 8, !tbaa !5
  call void @Explist_free(ptr noundef %4)
  %145 = getelementptr inbounds %struct.Token, ptr %7, i32 0, i32 1
  call void @AST_free(ptr noundef %145)
  %146 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %146, ptr %2, align 8
  store i32 1, ptr %14, align 4
  br label %147

147:                                              ; preds = %142, %133
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 16, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #5
  %148 = load ptr, ptr %2, align 8
  ret ptr %148
}

; Function Attrs: nounwind uwtable
declare dso_local void @AST_free(ptr noundef) #2

; 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
declare dso_local ptr @AST_new() #2

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

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @AST_gettype(ptr noundef) #2

; Function Attrs: nounwind uwtable
declare dso_local { i8, ptr } @next_token(ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @Explist_new() #2

; Function Attrs: nounwind uwtable
declare dso_local void @Explist_free(ptr noundef) #2

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

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

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

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

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind "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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{i8 0, i8 2}
!12 = !{}
!13 = !{i64 0, i64 1, !14, i64 8, i64 8, !5}
!14 = !{!7, !7, i64 0}
!15 = !{!16, !6, i64 8}
!16 = !{!"Token", !7, i64 0, !6, i64 8}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!20, !20, i64 0}
!20 = !{!"int", !7, i64 0}
!21 = !{!16, !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"

%struct.Token = type { i8, ptr }

@stderr = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.37 = external hidden unnamed_addr constant [29 x i8], align 1
@.str.38 = external hidden unnamed_addr constant [21 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @parse(ptr noundef %0) local_unnamed_addr #2 {
.lr.ph:
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca %struct.Token, align 8
  %5 = alloca %struct.Token, align 8
  store ptr %0, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %6 = tail call ptr @Explist_new()
  store ptr %6, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %5, i8 0, i64 16, i1 false)
  %.sroa.410.0..sroa_idx = getelementptr inbounds i8, ptr %4, i64 8
  %7 = getelementptr inbounds i8, ptr %5, i64 8
  %8 = call { i8, ptr } @next_token(ptr noundef nonnull %1)
  %9 = extractvalue { i8, ptr } %8, 0
  %10 = extractvalue { i8, ptr } %8, 1
  store i8 %9, ptr %4, align 8, !tbaa !9
  store ptr %10, ptr %.sroa.410.0..sroa_idx, align 8, !tbaa !5
  %11 = icmp eq ptr %10, null
  br i1 %11, label %.outer._crit_edge, label %.lr.ph26

.lr.ph26:                                         ; preds = %.lr.ph, %59
  %12 = phi ptr [ %65, %59 ], [ %10, %.lr.ph ]
  %13 = call i32 @AST_gettype(ptr noundef nonnull %12)
  %14 = load i8, ptr %5, align 8, !tbaa !10
  %15 = icmp eq i8 %14, 41
  br i1 %15, label %16, label %25

16:                                               ; preds = %.lr.ph26
  %17 = icmp eq i32 %13, 0
  %18 = load i8, ptr %4, align 8
  %19 = icmp eq i8 %18, 40
  %or.cond = select i1 %17, i1 true, i1 %19
  br i1 %or.cond, label %20, label %25

20:                                               ; preds = %16
  %21 = call ptr @AST_new()
  %22 = call ptr @AST_settype(ptr noundef %21, i32 noundef 6)
  %23 = load ptr, ptr %2, align 8, !tbaa !5
  %24 = call ptr @Explist_add(ptr noundef %22, ptr noundef %23)
  store ptr %24, ptr %2, align 8, !tbaa !5
  br label %thread-pre-split

25:                                               ; preds = %16, %.lr.ph26
  %26 = load ptr, ptr %7, align 8, !tbaa !12
  %.not = icmp eq ptr %26, null
  br i1 %.not, label %thread-pre-split, label %27

27:                                               ; preds = %25
  %28 = call i32 @AST_gettype(ptr noundef nonnull %26)
  %29 = icmp eq i32 %28, 0
  %30 = load i8, ptr %4, align 8
  %31 = icmp eq i8 %30, 40
  %or.cond7 = select i1 %29, i1 %31, i1 false
  br i1 %or.cond7, label %32, label %37

32:                                               ; preds = %27
  %33 = call ptr @AST_new()
  %34 = call ptr @AST_settype(ptr noundef %33, i32 noundef 6)
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = call ptr @Explist_add(ptr noundef %34, ptr noundef %35)
  store ptr %36, ptr %2, align 8, !tbaa !5
  br label %thread-pre-split

thread-pre-split:                                 ; preds = %20, %32, %25
  %.pr = load i8, ptr %4, align 8, !tbaa !10
  br label %37

37:                                               ; preds = %thread-pre-split, %27
  %38 = phi i8 [ %.pr, %thread-pre-split ], [ %30, %27 ]
  switch i8 %38, label %54 [
    i8 40, label %39
    i8 41, label %46
  ]

39:                                               ; preds = %37
  %40 = load ptr, ptr %.sroa.410.0..sroa_idx, align 8, !tbaa !12
  %41 = load ptr, ptr %2, align 8, !tbaa !5
  %42 = call ptr @Explist_add(ptr noundef %40, ptr noundef %41)
  %43 = call ptr @Explist_new()
  %44 = call ptr @Explist_prepend(ptr noundef %43, ptr noundef %42)
  store ptr %44, ptr %2, align 8, !tbaa !5
  call void @AST_free(ptr noundef nonnull %7)
  %45 = load i8, ptr %4, align 8, !tbaa !10
  store i8 %45, ptr %5, align 8, !tbaa !10
  br label %59, !llvm.loop !13

46:                                               ; preds = %37
  %47 = load ptr, ptr %2, align 8, !tbaa !5
  %48 = call ptr @Explist_collapse(ptr noundef %47)
  store ptr %48, ptr %3, align 8, !tbaa !5
  %49 = icmp eq ptr %47, %48
  br i1 %49, label %.thread, label %52

.thread:                                          ; preds = %46
  %50 = load ptr, ptr @stderr, align 8, !tbaa !5
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.37) #5
  br label %74

52:                                               ; preds = %46
  store ptr %48, ptr %2, align 8, !tbaa !5
  call void @AST_free(ptr noundef nonnull %.sroa.410.0..sroa_idx)
  call void @AST_free(ptr noundef nonnull %7)
  %53 = load i8, ptr %4, align 8, !tbaa !10
  store i8 %53, ptr %5, align 8, !tbaa !10
  br label %59, !llvm.loop !13

54:                                               ; preds = %37
  %55 = load ptr, ptr %.sroa.410.0..sroa_idx, align 8, !tbaa !12
  %56 = load ptr, ptr %2, align 8, !tbaa !5
  %57 = call ptr @Explist_add(ptr noundef %55, ptr noundef %56)
  store ptr %57, ptr %2, align 8, !tbaa !5
  call void @AST_free(ptr noundef nonnull %7)
  %58 = load i8, ptr %4, align 8, !tbaa !10
  store i8 %58, ptr %5, align 8, !tbaa !10
  br label %59

59:                                               ; preds = %54, %52, %39
  %60 = phi ptr [ %57, %54 ], [ %48, %52 ], [ %44, %39 ]
  %61 = load ptr, ptr %.sroa.410.0..sroa_idx, align 8, !tbaa !12
  %62 = call ptr @AST_copy(ptr noundef %61)
  store ptr %62, ptr %7, align 8, !tbaa !12
  %63 = call { i8, ptr } @next_token(ptr noundef nonnull %1)
  %64 = extractvalue { i8, ptr } %63, 0
  %65 = extractvalue { i8, ptr } %63, 1
  store i8 %64, ptr %4, align 8, !tbaa !9
  store ptr %65, ptr %.sroa.410.0..sroa_idx, align 8, !tbaa !5
  %66 = icmp eq ptr %65, null
  br i1 %66, label %.outer._crit_edge, label %.lr.ph26

.outer._crit_edge:                                ; preds = %59, %.lr.ph
  %.lcssa = phi ptr [ %6, %.lr.ph ], [ %60, %59 ]
  %67 = call zeroext i1 @Explist_singleton(ptr noundef %.lcssa)
  br i1 %67, label %71, label %68

68:                                               ; preds = %.outer._crit_edge
  %69 = load ptr, ptr @stderr, align 8, !tbaa !5
  %70 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %69, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.38) #5
  br label %71

71:                                               ; preds = %68, %.outer._crit_edge
  %72 = load ptr, ptr %2, align 8, !tbaa !5
  %73 = call ptr @Explist_toAST(ptr noundef %72)
  br label %74

74:                                               ; preds = %.thread, %71
  %.sink = phi ptr [ %3, %.thread ], [ %2, %71 ]
  %.sroa.410.0..sroa_idx.sink = phi ptr [ %.sroa.410.0..sroa_idx, %.thread ], [ %7, %71 ]
  %.2 = phi ptr [ null, %.thread ], [ %73, %71 ]
  call void @Explist_free(ptr noundef nonnull %.sink)
  call void @AST_free(ptr noundef nonnull %.sroa.410.0..sroa_idx.sink)
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret ptr %.2
}

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

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @AST_new() local_unnamed_addr #2

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local { i8, ptr } @next_token(ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3

; Function Attrs: nounwind uwtable
declare dso_local ptr @Explist_new() local_unnamed_addr #2

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

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

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nofree nounwind "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #4 = { nounwind }
attributes #5 = { cold 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 = !{!7, !7, i64 0}
!10 = !{!11, !7, i64 0}
!11 = !{!"Token", !7, i64 0, !6, i64 8}
!12 = !{!11, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass