; LLVM IR from musetronstar/tagd :: tagl/src (lemon)

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

@.str.3 = external hidden unnamed_addr constant [68 x i8], align 1
@currentend = external hidden global ptr, align 8
@basisend = external hidden global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__.Configlist_addbasis = external hidden unnamed_addr constant [55 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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @Configlist_addbasis(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct.config, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  call void @llvm.lifetime.start.p0(i64 72, ptr %6) #3
  %7 = load ptr, ptr @basisend, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %2
  br label %11

10:                                               ; preds = %2
  call void @__assert_fail(ptr noundef @.str.10, ptr noundef @.str.3, i32 noundef 1377, ptr noundef @__PRETTY_FUNCTION__.Configlist_addbasis) #4
  unreachable

11:                                               ; preds = %9
  %12 = load ptr, ptr @currentend, align 8, !tbaa !5
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  br label %16

15:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.3, i32 noundef 1378, ptr noundef @__PRETTY_FUNCTION__.Configlist_addbasis) #4
  unreachable

16:                                               ; preds = %14
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.config, ptr %6, i32 0, i32 0
  store ptr %17, ptr %18, align 8, !tbaa !11
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = getelementptr inbounds %struct.config, ptr %6, i32 0, i32 1
  store i32 %19, ptr %20, align 8, !tbaa !13
  %21 = call ptr @Configtable_find(ptr noundef %6)
  store ptr %21, ptr %5, align 8, !tbaa !5
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %55

24:                                               ; preds = %16
  %25 = call ptr @newconfig()
  store ptr %25, ptr %5, align 8, !tbaa !5
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.config, ptr %27, i32 0, i32 0
  store ptr %26, ptr %28, align 8, !tbaa !11
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.config, ptr %30, i32 0, i32 1
  store i32 %29, ptr %31, align 8, !tbaa !13
  %32 = call ptr @SetNew()
  %33 = load ptr, ptr %5, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.config, ptr %33, i32 0, i32 2
  store ptr %32, ptr %34, align 8, !tbaa !14
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.config, ptr %35, i32 0, i32 5
  store ptr null, ptr %36, align 8, !tbaa !15
  %37 = load ptr, ptr %5, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.config, ptr %37, i32 0, i32 4
  store ptr null, ptr %38, align 8, !tbaa !16
  %39 = load ptr, ptr %5, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.config, ptr %39, i32 0, i32 3
  store ptr null, ptr %40, align 8, !tbaa !17
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.config, ptr %41, i32 0, i32 7
  store ptr null, ptr %42, align 8, !tbaa !18
  %43 = load ptr, ptr %5, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.config, ptr %43, i32 0, i32 8
  store ptr null, ptr %44, align 8, !tbaa !19
  %45 = load ptr, ptr %5, align 8, !tbaa !5
  %46 = load ptr, ptr @currentend, align 8, !tbaa !5
  store ptr %45, ptr %46, align 8, !tbaa !5
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.config, ptr %47, i32 0, i32 7
  store ptr %48, ptr @currentend, align 8, !tbaa !5
  %49 = load ptr, ptr %5, align 8, !tbaa !5
  %50 = load ptr, ptr @basisend, align 8, !tbaa !5
  store ptr %49, ptr %50, align 8, !tbaa !5
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct.config, ptr %51, i32 0, i32 8
  store ptr %52, ptr @basisend, align 8, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = call i32 @Configtable_insert(ptr noundef %53)
  br label %55

55:                                               ; preds = %24, %16
  %56 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 72, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret ptr %56
}

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 = { nounwind }
attributes #4 = { noreturn 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 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"config", !6, i64 0, !10, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !10, i64 48, !6, i64 56, !6, i64 64}
!13 = !{!12, !10, i64 8}
!14 = !{!12, !6, i64 16}
!15 = !{!12, !6, i64 40}
!16 = !{!12, !6, i64 32}
!17 = !{!12, !6, i64 24}
!18 = !{!12, !6, i64 56}
!19 = !{!12, !6, 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"

%struct.config = type { ptr, i32, ptr, ptr, ptr, ptr, i32, ptr, ptr }

@.str.3 = external hidden unnamed_addr constant [68 x i8], align 1
@currentend = external hidden local_unnamed_addr global ptr, align 8
@basisend = external hidden local_unnamed_addr global ptr, align 8
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [12 x i8], align 1
@__PRETTY_FUNCTION__.Configlist_addbasis = external hidden unnamed_addr constant [55 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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #1

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

; Function Attrs: nounwind uwtable
define dso_local ptr @Configlist_addbasis(ptr noundef %0, i32 noundef %1) local_unnamed_addr #2 {
  %3 = alloca %struct.config, align 8
  call void @llvm.lifetime.start.p0(i64 72, ptr nonnull %3) #4
  %4 = load ptr, ptr @basisend, align 8, !tbaa !5
  %.not = icmp eq ptr %4, null
  br i1 %.not, label %5, label %6

5:                                                ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.3, i32 noundef 1377, ptr noundef nonnull @__PRETTY_FUNCTION__.Configlist_addbasis) #5
  unreachable

6:                                                ; preds = %2
  %7 = load ptr, ptr @currentend, align 8, !tbaa !5
  %.not19 = icmp eq ptr %7, null
  br i1 %.not19, label %8, label %9

8:                                                ; preds = %6
  tail call void @__assert_fail(ptr noundef nonnull @.str.9, ptr noundef nonnull @.str.3, i32 noundef 1378, ptr noundef nonnull @__PRETTY_FUNCTION__.Configlist_addbasis) #5
  unreachable

9:                                                ; preds = %6
  store ptr %0, ptr %3, align 8, !tbaa !9
  %10 = getelementptr inbounds i8, ptr %3, i64 8
  store i32 %1, ptr %10, align 8, !tbaa !12
  %11 = call ptr @Configtable_find(ptr noundef nonnull %3)
  %12 = icmp eq ptr %11, null
  br i1 %12, label %13, label %24

13:                                               ; preds = %9
  %14 = call ptr @newconfig()
  store ptr %0, ptr %14, align 8, !tbaa !9
  %15 = getelementptr inbounds i8, ptr %14, i64 8
  store i32 %1, ptr %15, align 8, !tbaa !12
  %16 = call ptr @SetNew()
  %17 = getelementptr inbounds i8, ptr %14, i64 16
  store ptr %16, ptr %17, align 8, !tbaa !13
  %18 = getelementptr inbounds i8, ptr %14, i64 24
  %19 = getelementptr inbounds i8, ptr %14, i64 56
  %20 = getelementptr inbounds i8, ptr %14, i64 64
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %18, i8 0, i64 24, i1 false)
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %19, i8 0, i64 16, i1 false)
  %21 = load ptr, ptr @currentend, align 8, !tbaa !5
  store ptr %14, ptr %21, align 8, !tbaa !5
  store ptr %19, ptr @currentend, align 8, !tbaa !5
  %22 = load ptr, ptr @basisend, align 8, !tbaa !5
  store ptr %14, ptr %22, align 8, !tbaa !5
  store ptr %20, ptr @basisend, align 8, !tbaa !5
  %23 = call i32 @Configtable_insert(ptr noundef nonnull %14)
  br label %24

24:                                               ; preds = %13, %9
  %.0 = phi ptr [ %14, %13 ], [ %11, %9 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %3) #4
  ret ptr %.0
}

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

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 = { nounwind }
attributes #5 = { noreturn 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, !6, i64 0}
!10 = !{!"config", !6, i64 0, !11, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !6, i64 56, !6, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 8}
!13 = !{!10, !6, i64 16}


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