; LLVM IR from jorgemf/c-evolutionary-library :: examples/tsp/TSPIndividual2.ll (ZN14TSPIndividual2C2Ei)

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

%class.TSPIndividual = type { %class.Individual.base, i32, ptr }
%class.Individual.base = type <{ ptr, i8, [7 x i8], double, i32, [4 x i8], double, ptr, i32 }>
%class.TSPIndividual2 = type { %class.TSPIndividual, ptr, ptr }

@_ZTV14TSPIndividual2 = external dso_local unnamed_addr constant { [6 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14TSPIndividual2C2Ei(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %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
  %7 = load ptr, ptr %3, align 8
  %8 = load i32, ptr %4, align 4, !tbaa !9
  call void @_ZN13TSPIndividualC2Ei(ptr noundef nonnull align 8 dereferenceable(64) %7, i32 noundef %8)
  store ptr getelementptr inbounds inrange(-16, 32) ({ [6 x ptr] }, ptr @_ZTV14TSPIndividual2, i32 0, i32 0, i32 2), ptr %7, align 8, !tbaa !11
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = getelementptr inbounds %class.TSPIndividual, ptr %7, i32 0, i32 1
  store i32 %9, ptr %10, align 4, !tbaa !13
  %11 = getelementptr inbounds %class.TSPIndividual, ptr %7, i32 0, i32 1
  %12 = load i32, ptr %11, align 4, !tbaa !13
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %39

14:                                               ; preds = %2
  %15 = getelementptr inbounds %class.TSPIndividual, ptr %7, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !13
  %17 = sext i32 %16 to i64
  %18 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %17, i64 8)
  %19 = extractvalue { i64, i1 } %18, 1
  %20 = extractvalue { i64, i1 } %18, 0
  %21 = select i1 %19, i64 -1, i64 %20
  %22 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %21) #5
          to label %23 unwind label %35

23:                                               ; preds = %14
  %24 = getelementptr inbounds %class.TSPIndividual2, ptr %7, i32 0, i32 1
  store ptr %22, ptr %24, align 8, !tbaa !18
  %25 = getelementptr inbounds %class.TSPIndividual, ptr %7, i32 0, i32 1
  %26 = load i32, ptr %25, align 4, !tbaa !13
  %27 = sext i32 %26 to i64
  %28 = call { i64, i1 } @llvm.umul.with.overflow.i64(i64 %27, i64 8)
  %29 = extractvalue { i64, i1 } %28, 1
  %30 = extractvalue { i64, i1 } %28, 0
  %31 = select i1 %29, i64 -1, i64 %30
  %32 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %31) #5
          to label %33 unwind label %35

33:                                               ; preds = %23
  %34 = getelementptr inbounds %class.TSPIndividual2, ptr %7, i32 0, i32 2
  store ptr %32, ptr %34, align 8, !tbaa !20
  br label %39

35:                                               ; preds = %23, %14
  %36 = landingpad { ptr, i32 }
          cleanup
  %37 = extractvalue { ptr, i32 } %36, 0
  store ptr %37, ptr %5, align 8
  %38 = extractvalue { ptr, i32 } %36, 1
  store i32 %38, ptr %6, align 4
  call void @_ZN13TSPIndividualD2Ev(ptr noundef nonnull align 8 dereferenceable(64) %7) #6
  br label %40

39:                                               ; preds = %33, %2
  ret void

40:                                               ; preds = %35
  %41 = load ptr, ptr %5, align 8
  %42 = load i32, ptr %6, align 4
  %43 = insertvalue { ptr, i32 } poison, ptr %41, 0
  %44 = insertvalue { ptr, i32 } %43, i32 %42, 1
  resume { ptr, i32 } %44
}

declare void @_ZN13TSPIndividualC2Ei(ptr noundef nonnull align 8 dereferenceable(64), i32 noundef) unnamed_addr #1

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare { i64, i1 } @llvm.umul.with.overflow.i64(i64, i64) #2

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) #3

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN13TSPIndividualD2Ev(ptr noundef nonnull align 8 dereferenceable(64)) unnamed_addr #4

attributes #0 = { 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 #1 = { "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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { nobuiltin allocsize(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 #4 = { 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 #5 = { builtin allocsize(0) }
attributes #6 = { 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 = !{!12, !12, i64 0}
!12 = !{!"vtable pointer", !8, i64 0}
!13 = !{!14, !10, i64 52}
!14 = !{!"_ZTS13TSPIndividual", !15, i64 0, !10, i64 52, !6, i64 56}
!15 = !{!"_ZTS10Individual", !16, i64 8, !17, i64 16, !10, i64 24, !17, i64 32, !6, i64 40, !10, i64 48}
!16 = !{!"bool", !7, i64 0}
!17 = !{!"double", !7, i64 0}
!18 = !{!19, !6, i64 64}
!19 = !{!"_ZTS14TSPIndividual2", !14, i64 0, !6, i64 64, !6, i64 72}
!20 = !{!19, !6, i64 72}


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

@_ZTV14TSPIndividual2 = external dso_local unnamed_addr constant { [6 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN14TSPIndividual2C2Ei(ptr noundef nonnull align 8 dereferenceable(80) %0, i32 noundef %1) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN13TSPIndividualC2Ei(ptr noundef nonnull align 8 dereferenceable(64) %0, i32 noundef %1)
  store ptr getelementptr inbounds inrange(-16, 32) (i8, ptr @_ZTV14TSPIndividual2, i64 16), ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 52
  store i32 %1, ptr %3, align 4, !tbaa !8
  %4 = icmp sgt i32 %1, 0
  br i1 %4, label %5, label %16

5:                                                ; preds = %2
  %6 = zext nneg i32 %1 to i64
  %7 = shl nuw nsw i64 %6, 3
  %8 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %7) #4
          to label %9 unwind label %14

9:                                                ; preds = %5
  %10 = getelementptr inbounds i8, ptr %0, i64 64
  store ptr %8, ptr %10, align 8, !tbaa !16
  %11 = invoke noalias noundef nonnull ptr @_Znam(i64 noundef %7) #4
          to label %12 unwind label %14

12:                                               ; preds = %9
  %13 = getelementptr inbounds i8, ptr %0, i64 72
  store ptr %11, ptr %13, align 8, !tbaa !18
  br label %16

14:                                               ; preds = %9, %5
  %15 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN13TSPIndividualD2Ev(ptr noundef nonnull align 8 dereferenceable(64) %0) #5
  resume { ptr, i32 } %15

16:                                               ; preds = %12, %2
  ret void
}

declare void @_ZN13TSPIndividualC2Ei(ptr noundef nonnull align 8 dereferenceable(64), i32 noundef) unnamed_addr #1

; Function Attrs: nobuiltin allocsize(0)
declare noundef nonnull ptr @_Znam(i64 noundef) local_unnamed_addr #2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: nounwind
declare void @_ZN13TSPIndividualD2Ev(ptr noundef nonnull align 8 dereferenceable(64)) unnamed_addr #3

attributes #0 = { 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 #1 = { "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 = { nobuiltin allocsize(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 "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 #4 = { builtin allocsize(0) }
attributes #5 = { 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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !14, i64 52}
!9 = !{!"_ZTS13TSPIndividual", !10, i64 0, !14, i64 52, !15, i64 56}
!10 = !{!"_ZTS10Individual", !11, i64 8, !13, i64 16, !14, i64 24, !13, i64 32, !15, i64 40, !14, i64 48}
!11 = !{!"bool", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"double", !12, i64 0}
!14 = !{!"int", !12, i64 0}
!15 = !{!"any pointer", !12, i64 0}
!16 = !{!17, !15, i64 64}
!17 = !{!"_ZTS14TSPIndividual2", !9, i64 0, !15, i64 64, !15, i64 72}
!18 = !{!17, !15, i64 72}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass