; LLVM IR from Smorodov/Multitarget-tracker :: src/Tracker/graph/GTL/src (gml_parser)

; 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.GTL::GML_list_elem" = type { ptr, ptr }
%"struct.GTL::GML_pair" = type { ptr, i32, %"union.GTL::GML_pair_val", ptr }
%"union.GTL::GML_pair_val" = type { i64 }

; 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
declare void @free(ptr noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3GTL13GML_free_listEPNS_8GML_pairEPNS_13GML_list_elemE(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #3
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %7, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  br label %8

8:                                                ; preds = %11, %2
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = icmp ne ptr %9, null
  br i1 %10, label %11, label %20

11:                                               ; preds = %8
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %"struct.GTL::GML_list_elem", ptr %12, i32 0, i32 0
  %14 = load ptr, ptr %13, align 8, !tbaa !9
  call void @free(ptr noundef %14) #3
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.GTL::GML_list_elem", ptr %15, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  store ptr %17, ptr %6, align 8, !tbaa !5
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  call void @free(ptr noundef %18) #3
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %19, ptr %4, align 8, !tbaa !5
  br label %8, !llvm.loop !12

20:                                               ; preds = %8
  br label %21

21:                                               ; preds = %37, %20
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = icmp ne ptr %22, null
  br i1 %23, label %24, label %43

24:                                               ; preds = %21
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %25, i32 0, i32 1
  %27 = load i32, ptr %26, align 8, !tbaa !14
  switch i32 %27, label %36 [
    i32 7, label %28
    i32 3, label %32
  ]

28:                                               ; preds = %24
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !17
  call void @_ZN3GTL13GML_free_listEPNS_8GML_pairEPNS_13GML_list_elemE(ptr noundef %31, ptr noundef null)
  br label %37

32:                                               ; preds = %24
  %33 = load ptr, ptr %3, align 8, !tbaa !5
  %34 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %33, i32 0, i32 2
  %35 = load ptr, ptr %34, align 8, !tbaa !17
  call void @free(ptr noundef %35) #3
  br label %37

36:                                               ; preds = %24
  br label %37

37:                                               ; preds = %36, %32, %28
  %38 = load ptr, ptr %3, align 8, !tbaa !5
  %39 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %38, i32 0, i32 3
  %40 = load ptr, ptr %39, align 8, !tbaa !18
  store ptr %40, ptr %5, align 8, !tbaa !5
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %41) #3
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %42, ptr %3, align 8, !tbaa !5
  br label %21, !llvm.loop !19

43:                                               ; preds = %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #3
  ret void
}

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 = { mustprogress 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 }

!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++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTSN3GTL13GML_list_elemE", !6, i64 0, !6, i64 8}
!11 = !{!10, !6, i64 8}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !16, i64 8}
!15 = !{!"_ZTSN3GTL8GML_pairE", !6, i64 0, !16, i64 8, !7, i64 16, !6, i64 24}
!16 = !{!"_ZTSN3GTL9GML_valueE", !7, i64 0}
!17 = !{!7, !7, i64 0}
!18 = !{!15, !6, i64 24}
!19 = distinct !{!19, !13}


; 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: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN3GTL13GML_free_listEPNS_8GML_pairEPNS_13GML_list_elemE(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %.not15 = icmp eq ptr %1, null
  br i1 %.not15, label %.preheader, label %.lr.ph

.preheader:                                       ; preds = %.lr.ph, %2
  %.not1417 = icmp eq ptr %0, null
  br i1 %.not1417, label %._crit_edge, label %.lr.ph19

.lr.ph:                                           ; preds = %2, %.lr.ph
  %.01316 = phi ptr [ %5, %.lr.ph ], [ %1, %2 ]
  %3 = load ptr, ptr %.01316, align 8, !tbaa !5
  tail call void @free(ptr noundef %3) #2
  %4 = getelementptr inbounds i8, ptr %.01316, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !10
  tail call void @free(ptr noundef nonnull %.01316) #2
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %.preheader, label %.lr.ph, !llvm.loop !11

.lr.ph19:                                         ; preds = %.preheader, %14
  %.018 = phi ptr [ %16, %14 ], [ %0, %.preheader ]
  %6 = getelementptr inbounds i8, ptr %.018, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !13
  switch i32 %7, label %14 [
    i32 7, label %8
    i32 3, label %11
  ]

8:                                                ; preds = %.lr.ph19
  %9 = getelementptr inbounds i8, ptr %.018, i64 16
  %10 = load ptr, ptr %9, align 8, !tbaa !16
  tail call void @_ZN3GTL13GML_free_listEPNS_8GML_pairEPNS_13GML_list_elemE(ptr noundef %10, ptr noundef null)
  br label %14

11:                                               ; preds = %.lr.ph19
  %12 = getelementptr inbounds i8, ptr %.018, i64 16
  %13 = load ptr, ptr %12, align 8, !tbaa !16
  tail call void @free(ptr noundef %13) #2
  br label %14

14:                                               ; preds = %.lr.ph19, %11, %8
  %15 = getelementptr inbounds i8, ptr %.018, i64 24
  %16 = load ptr, ptr %15, align 8, !tbaa !17
  tail call void @free(ptr noundef nonnull %.018) #2
  %.not14 = icmp eq ptr %16, null
  br i1 %.not14, label %._crit_edge, label %.lr.ph19, !llvm.loop !18

._crit_edge:                                      ; preds = %14, %.preheader
  ret void
}

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { mustprogress 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 0}
!6 = !{!"_ZTSN3GTL13GML_list_elemE", !7, i64 0, !7, i64 8}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !15, i64 8}
!14 = !{!"_ZTSN3GTL8GML_pairE", !7, i64 0, !15, i64 8, !8, i64 16, !7, i64 24}
!15 = !{!"_ZTSN3GTL9GML_valueE", !8, i64 0}
!16 = !{!8, !8, i64 0}
!17 = !{!14, !7, i64 24}
!18 = distinct !{!18, !12}


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