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

; 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: nounwind uwtable
define dso_local ptr @getstate(ptr noundef %0) #1 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @Configlist_sortbasis()
  %8 = call ptr @Configlist_basis()
  store ptr %8, ptr %4, align 8, !tbaa !5
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = call ptr @State_find(ptr noundef %9)
  store ptr %10, ptr %5, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %49

13:                                               ; preds = %1
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %14 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %14, ptr %6, align 8, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.state, ptr %15, i32 0, i32 0
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  store ptr %17, ptr %7, align 8, !tbaa !5
  br label %18

18:                                               ; preds = %39, %13
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %21, label %24

21:                                               ; preds = %18
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br label %24

24:                                               ; preds = %21, %18
  %25 = phi i1 [ false, %18 ], [ %23, %21 ]
  br i1 %25, label %26, label %46

26:                                               ; preds = %24
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.config, ptr %27, i32 0, i32 4
  %29 = load ptr, ptr %6, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.config, ptr %29, i32 0, i32 4
  %31 = load ptr, ptr %30, align 8, !tbaa !12
  call void @Plink_copy(ptr noundef %28, ptr noundef %31)
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.config, ptr %32, i32 0, i32 3
  %34 = load ptr, ptr %33, align 8, !tbaa !14
  call void @Plink_delete(ptr noundef %34)
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.config, ptr %35, i32 0, i32 4
  store ptr null, ptr %36, align 8, !tbaa !12
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.config, ptr %37, i32 0, i32 3
  store ptr null, ptr %38, align 8, !tbaa !14
  br label %39

39:                                               ; preds = %26
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.config, ptr %40, i32 0, i32 8
  %42 = load ptr, ptr %41, align 8, !tbaa !15
  store ptr %42, ptr %6, align 8, !tbaa !5
  %43 = load ptr, ptr %7, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.config, ptr %43, i32 0, i32 8
  %45 = load ptr, ptr %44, align 8, !tbaa !15
  store ptr %45, ptr %7, align 8, !tbaa !5
  br label %18, !llvm.loop !16

46:                                               ; preds = %24
  %47 = call ptr @Configlist_return()
  store ptr %47, ptr %3, align 8, !tbaa !5
  %48 = load ptr, ptr %3, align 8, !tbaa !5
  call void @Configlist_eat(ptr noundef %48)
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  br label %78

49:                                               ; preds = %1
  %50 = load ptr, ptr %2, align 8, !tbaa !5
  call void @Configlist_closure(ptr noundef %50)
  call void @Configlist_sort()
  %51 = call ptr @Configlist_return()
  store ptr %51, ptr %3, align 8, !tbaa !5
  %52 = call ptr @State_new()
  store ptr %52, ptr %5, align 8, !tbaa !5
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = icmp eq ptr %53, null
  br i1 %54, label %55, label %56

55:                                               ; preds = %49
  call void @memory_error()
  br label %56

56:                                               ; preds = %55, %49
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = load ptr, ptr %5, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.state, ptr %58, i32 0, i32 0
  store ptr %57, ptr %59, align 8, !tbaa !9
  %60 = load ptr, ptr %3, align 8, !tbaa !5
  %61 = load ptr, ptr %5, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.state, ptr %61, i32 0, i32 1
  store ptr %60, ptr %62, align 8, !tbaa !18
  %63 = load ptr, ptr %2, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.lemon, ptr %63, i32 0, i32 3
  %65 = load i32, ptr %64, align 8, !tbaa !19
  %66 = add nsw i32 %65, 1
  store i32 %66, ptr %64, align 8, !tbaa !19
  %67 = load ptr, ptr %5, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.state, ptr %67, i32 0, i32 2
  store i32 %65, ptr %68, align 8, !tbaa !21
  %69 = load ptr, ptr %5, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.state, ptr %69, i32 0, i32 3
  store ptr null, ptr %70, align 8, !tbaa !22
  %71 = load ptr, ptr %5, align 8, !tbaa !5
  %72 = load ptr, ptr %5, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.state, ptr %72, i32 0, i32 0
  %74 = load ptr, ptr %73, align 8, !tbaa !9
  %75 = call i32 @State_insert(ptr noundef %71, ptr noundef %74)
  %76 = load ptr, ptr %2, align 8, !tbaa !5
  %77 = load ptr, ptr %5, align 8, !tbaa !5
  call void @buildshifts(ptr noundef %76, ptr noundef %77)
  br label %78

78:                                               ; preds = %56, %46
  %79 = load ptr, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret ptr %79
}

; Function Attrs: nounwind uwtable
declare dso_local void @Configlist_sortbasis() #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @Configlist_basis() #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @State_find(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
declare dso_local void @Plink_delete(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @Configlist_return() #1

; Function Attrs: nounwind uwtable
declare dso_local void @Configlist_eat(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @Configlist_closure(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @Configlist_sort() #1

; Function Attrs: nounwind uwtable
declare dso_local ptr @State_new() #1

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @memory_error() #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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, !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 = !{!"state", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !6, i64 56, !11, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !6, i64 32}
!13 = !{!"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}
!14 = !{!13, !6, i64 24}
!15 = !{!13, !6, i64 64}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!10, !6, i64 8}
!19 = !{!20, !11, i64 24}
!20 = !{!"lemon", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !6, i64 72, !11, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !11, i64 248, !11, i64 252, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !6, i64 280}
!21 = !{!10, !11, i64 16}
!22 = !{!10, !6, i64 24}


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

; Function Attrs: nounwind uwtable
define dso_local ptr @getstate(ptr noundef %0) local_unnamed_addr #0 {
  tail call void @Configlist_sortbasis()
  %2 = tail call ptr @Configlist_basis()
  %3 = tail call ptr @State_find(ptr noundef %2)
  %.not = icmp eq ptr %3, null
  br i1 %.not, label %19, label %.preheader

.preheader:                                       ; preds = %1
  %.031 = load ptr, ptr %3, align 8, !tbaa !5
  %4 = icmp ne ptr %2, null
  %5 = icmp ne ptr %.031, null
  %6 = select i1 %4, i1 %5, i1 false
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader, %.lr.ph
  %.033 = phi ptr [ %.0, %.lr.ph ], [ %.031, %.preheader ]
  %.02832 = phi ptr [ %13, %.lr.ph ], [ %2, %.preheader ]
  %7 = getelementptr inbounds i8, ptr %.033, i64 32
  %8 = getelementptr inbounds i8, ptr %.02832, i64 32
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  tail call void @Plink_copy(ptr noundef nonnull %7, ptr noundef %9)
  %10 = getelementptr inbounds i8, ptr %.02832, i64 24
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  tail call void @Plink_delete(ptr noundef %11)
  %12 = getelementptr inbounds i8, ptr %.02832, i64 64
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %10, i8 0, i64 16, i1 false)
  %13 = load ptr, ptr %12, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %.033, i64 64
  %.0 = load ptr, ptr %14, align 8, !tbaa !5
  %15 = icmp ne ptr %13, null
  %16 = icmp ne ptr %.0, null
  %17 = select i1 %15, i1 %16, i1 false
  br i1 %17, label %.lr.ph, label %._crit_edge, !llvm.loop !14

._crit_edge:                                      ; preds = %.lr.ph, %.preheader
  %18 = tail call ptr @Configlist_return()
  tail call void @Configlist_eat(ptr noundef %18)
  br label %32

19:                                               ; preds = %1
  tail call void @Configlist_closure(ptr noundef %0)
  tail call void @Configlist_sort()
  %20 = tail call ptr @Configlist_return()
  %21 = tail call ptr @State_new()
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %24

23:                                               ; preds = %19
  tail call void @memory_error()
  br label %24

24:                                               ; preds = %23, %19
  store ptr %2, ptr %21, align 8, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %21, i64 8
  store ptr %20, ptr %25, align 8, !tbaa !18
  %26 = getelementptr inbounds i8, ptr %0, i64 24
  %27 = load i32, ptr %26, align 8, !tbaa !19
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %26, align 8, !tbaa !19
  %29 = getelementptr inbounds i8, ptr %21, i64 16
  store i32 %27, ptr %29, align 8, !tbaa !21
  %30 = getelementptr inbounds i8, ptr %21, i64 24
  store ptr null, ptr %30, align 8, !tbaa !22
  %31 = tail call i32 @State_insert(ptr noundef nonnull %21, ptr noundef %2)
  tail call void @buildshifts(ptr noundef %0, ptr noundef nonnull %21)
  br label %32

32:                                               ; preds = %24, %._crit_edge
  %.029 = phi ptr [ %3, %._crit_edge ], [ %21, %24 ]
  ret ptr %.029
}

; Function Attrs: nounwind uwtable
declare dso_local void @Configlist_sortbasis() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @Configlist_basis() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @State_find(ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @Plink_copy(ptr noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @Configlist_return() local_unnamed_addr #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @Configlist_sort() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local ptr @State_new() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @buildshifts(ptr noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @memory_error() local_unnamed_addr #0

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

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

!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 32}
!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, !6, i64 24}
!13 = !{!10, !6, i64 64}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!17, !6, i64 0}
!17 = !{!"state", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !6, i64 56, !11, i64 64}
!18 = !{!17, !6, i64 8}
!19 = !{!20, !11, i64 24}
!20 = !{!"lemon", !6, i64 0, !6, i64 8, !6, i64 16, !11, i64 24, !11, i64 28, !11, i64 32, !11, i64 36, !11, i64 40, !11, i64 44, !11, i64 48, !11, i64 52, !11, i64 56, !11, i64 60, !11, i64 64, !11, i64 68, !6, i64 72, !11, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !6, i64 112, !6, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152, !6, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !11, i64 248, !11, i64 252, !11, i64 256, !11, i64 260, !11, i64 264, !11, i64 268, !11, i64 272, !6, i64 280}
!21 = !{!17, !11, i64 16}
!22 = !{!17, !6, i64 24}


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