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

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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.7 = 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3GTL14GML_print_listEPNS_8GML_pairEi(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  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
  %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 4, ptr %6) #3
  br label %8

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

11:                                               ; preds = %8
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %18, %11
  %13 = load i32, ptr %6, align 4, !tbaa !9
  %14 = load i32, ptr %4, align 4, !tbaa !9
  %15 = icmp slt i32 %13, %14
  br i1 %15, label %16, label %21

16:                                               ; preds = %12
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %18

18:                                               ; preds = %16
  %19 = load i32, ptr %6, align 4, !tbaa !9
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %6, align 4, !tbaa !9
  br label %12, !llvm.loop !11

21:                                               ; preds = %12
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %22, i32 0, i32 0
  %24 = load ptr, ptr %23, align 8, !tbaa !13
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, ptr noundef %24)
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %26, i32 0, i32 1
  %28 = load i32, ptr %27, align 8, !tbaa !16
  switch i32 %28, label %51 [
    i32 1, label %29
    i32 2, label %34
    i32 3, label %39
    i32 7, label %44
  ]

29:                                               ; preds = %21
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %30, i32 0, i32 2
  %32 = load i64, ptr %31, align 8, !tbaa !17
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i64 noundef %32)
  br label %52

34:                                               ; preds = %21
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %35, i32 0, i32 2
  %37 = load double, ptr %36, align 8, !tbaa !17
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, double noundef %37)
  br label %52

39:                                               ; preds = %21
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %40, i32 0, i32 2
  %42 = load ptr, ptr %41, align 8, !tbaa !17
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, ptr noundef %42)
  br label %52

44:                                               ; preds = %21
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %46 = load ptr, ptr %5, align 8, !tbaa !5
  %47 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !17
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = add nsw i32 %49, 1
  call void @_ZN3GTL14GML_print_listEPNS_8GML_pairEi(ptr noundef %48, i32 noundef %50)
  br label %52

51:                                               ; preds = %21
  br label %52

52:                                               ; preds = %51, %44, %39, %34, %29
  %53 = load ptr, ptr %5, align 8, !tbaa !5
  %54 = getelementptr inbounds %"struct.GTL::GML_pair", ptr %53, i32 0, i32 3
  %55 = load ptr, ptr %54, align 8, !tbaa !18
  store ptr %55, ptr %5, align 8, !tbaa !5
  br label %8, !llvm.loop !19

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

declare i32 @printf(ptr noundef, ...) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !6, i64 0}
!14 = !{!"_ZTSN3GTL8GML_pairE", !6, i64 0, !15, i64 8, !7, i64 16, !6, i64 24}
!15 = !{!"_ZTSN3GTL9GML_valueE", !7, i64 0}
!16 = !{!14, !15, i64 8}
!17 = !{!7, !7, i64 0}
!18 = !{!14, !6, i64 24}
!19 = distinct !{!19, !12}


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

@.str.2 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [21 x i8], align 1

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

.preheader.lr.ph:                                 ; preds = %2
  %3 = icmp sgt i32 %1, 0
  %4 = add nsw i32 %1, 1
  br i1 %3, label %.preheader.us, label %.preheader

.preheader.us:                                    ; preds = %.preheader.lr.ph, %21
  %.01216.us = phi ptr [ %23, %21 ], [ %0, %.preheader.lr.ph ]
  br label %24

5:                                                ; preds = %._crit_edge.us
  %6 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %7 = getelementptr inbounds i8, ptr %.01216.us, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !5
  tail call void @_ZN3GTL14GML_print_listEPNS_8GML_pairEi(ptr noundef %8, i32 noundef %4)
  br label %21

9:                                                ; preds = %._crit_edge.us
  %10 = getelementptr inbounds i8, ptr %.01216.us, i64 16
  %11 = load ptr, ptr %10, align 8, !tbaa !5
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %11)
  br label %21

13:                                               ; preds = %._crit_edge.us
  %14 = getelementptr inbounds i8, ptr %.01216.us, i64 16
  %15 = load double, ptr %14, align 8, !tbaa !5
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, double noundef %15)
  br label %21

17:                                               ; preds = %._crit_edge.us
  %18 = getelementptr inbounds i8, ptr %.01216.us, i64 16
  %19 = load i64, ptr %18, align 8, !tbaa !5
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %19)
  br label %21

21:                                               ; preds = %17, %13, %9, %5, %._crit_edge.us
  %22 = getelementptr inbounds i8, ptr %.01216.us, i64 24
  %23 = load ptr, ptr %22, align 8, !tbaa !8
  %.not.us = icmp eq ptr %23, null
  br i1 %.not.us, label %._crit_edge17, label %.preheader.us, !llvm.loop !12

24:                                               ; preds = %.preheader.us, %24
  %.014.us = phi i32 [ 0, %.preheader.us ], [ %26, %24 ]
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %26 = add nuw nsw i32 %.014.us, 1
  %exitcond.not = icmp eq i32 %26, %1
  br i1 %exitcond.not, label %._crit_edge.us, label %24, !llvm.loop !14

._crit_edge.us:                                   ; preds = %24
  %27 = load ptr, ptr %.01216.us, align 8, !tbaa !15
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, ptr noundef %27)
  %29 = getelementptr inbounds i8, ptr %.01216.us, i64 8
  %30 = load i32, ptr %29, align 8, !tbaa !16
  switch i32 %30, label %21 [
    i32 1, label %17
    i32 2, label %13
    i32 3, label %9
    i32 7, label %5
  ]

.preheader:                                       ; preds = %.preheader.lr.ph, %51
  %.01216 = phi ptr [ %53, %51 ], [ %0, %.preheader.lr.ph ]
  %31 = load ptr, ptr %.01216, align 8, !tbaa !15
  %32 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, ptr noundef %31)
  %33 = getelementptr inbounds i8, ptr %.01216, i64 8
  %34 = load i32, ptr %33, align 8, !tbaa !16
  switch i32 %34, label %51 [
    i32 1, label %35
    i32 2, label %39
    i32 3, label %43
    i32 7, label %47
  ]

35:                                               ; preds = %.preheader
  %36 = getelementptr inbounds i8, ptr %.01216, i64 16
  %37 = load i64, ptr %36, align 8, !tbaa !5
  %38 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i64 noundef %37)
  br label %51

39:                                               ; preds = %.preheader
  %40 = getelementptr inbounds i8, ptr %.01216, i64 16
  %41 = load double, ptr %40, align 8, !tbaa !5
  %42 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, double noundef %41)
  br label %51

43:                                               ; preds = %.preheader
  %44 = getelementptr inbounds i8, ptr %.01216, i64 16
  %45 = load ptr, ptr %44, align 8, !tbaa !5
  %46 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, ptr noundef %45)
  br label %51

47:                                               ; preds = %.preheader
  %48 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %49 = getelementptr inbounds i8, ptr %.01216, i64 16
  %50 = load ptr, ptr %49, align 8, !tbaa !5
  tail call void @_ZN3GTL14GML_print_listEPNS_8GML_pairEi(ptr noundef %50, i32 noundef %4)
  br label %51

51:                                               ; preds = %.preheader, %47, %43, %39, %35
  %52 = getelementptr inbounds i8, ptr %.01216, i64 24
  %53 = load ptr, ptr %52, align 8, !tbaa !8
  %.not = icmp eq ptr %53, null
  br i1 %.not, label %._crit_edge17, label %.preheader, !llvm.loop !12

._crit_edge17:                                    ; preds = %51, %21, %2
  ret void
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #1

attributes #0 = { mustprogress nofree 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 = { 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" }

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !10, i64 24}
!9 = !{!"_ZTSN3GTL8GML_pairE", !10, i64 0, !11, i64 8, !6, i64 16, !10, i64 24}
!10 = !{!"any pointer", !6, i64 0}
!11 = !{!"_ZTSN3GTL9GML_valueE", !6, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = !{!9, !10, i64 0}
!16 = !{!9, !11, i64 8}


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