; 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
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__.Configlist_add = external hidden unnamed_addr constant [50 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
declare dso_local ptr @newconfig() #2

; Function Attrs: nounwind uwtable
define dso_local ptr @Configlist_add(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 @currentend, 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.9, ptr noundef @.str.3, i32 noundef 1352, ptr noundef @__PRETTY_FUNCTION__.Configlist_add) #4
  unreachable

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

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

46:                                               ; preds = %19, %11
  %47 = 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 %47
}

; 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
@.str.9 = external hidden unnamed_addr constant [14 x i8], align 1
@__PRETTY_FUNCTION__.Configlist_add = external hidden unnamed_addr constant [50 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
declare dso_local ptr @newconfig() local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local ptr @Configlist_add(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 @currentend, 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.9, ptr noundef nonnull @.str.3, i32 noundef 1352, ptr noundef nonnull @__PRETTY_FUNCTION__.Configlist_add) #5
  unreachable

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

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

19:                                               ; preds = %10, %6
  %.0 = phi ptr [ %11, %10 ], [ %8, %6 ]
  call void @llvm.lifetime.end.p0(i64 72, ptr nonnull %3) #4
  ret ptr %.0
}

; 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