; LLVM IR from Lut1n/ImpGears :: tests/image/test.ll (Z4hsymRN3imp5ImageERKNS_4Vec4E)

; 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.imp::Vec4" = type { %"class.imp::Vec.3" }
%"class.imp::Vec.3" = type { %"class.imp::Object", [4 x float] }
%"class.imp::Object" = type { ptr, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4hsymRN3imp5ImageERKNS_4Vec4E(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 8 dereferenceable(40) %1) #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca %"class.imp::Vec4", align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  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 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %53, %2
  %12 = load i32, ptr %5, align 4, !tbaa !9
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = call noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88) %13)
  %15 = icmp slt i32 %12, %14
  br i1 %15, label %17, label %16

16:                                               ; preds = %11
  store i32 2, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %56

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %49, %17
  %19 = load i32, ptr %7, align 4, !tbaa !9
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = call noundef i32 @_ZNK3imp5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(88) %20)
  %22 = icmp slt i32 %19, %21
  br i1 %22, label %24, label %23

23:                                               ; preds = %18
  store i32 5, ptr %6, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  br label %52

24:                                               ; preds = %18
  call void @llvm.lifetime.start.p0(i64 40, ptr %8) #4
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = load i32, ptr %5, align 4, !tbaa !9
  %27 = load i32, ptr %7, align 4, !tbaa !9
  call void @_ZNK3imp5Image8getPixelEii(ptr dead_on_unwind writable sret(%"class.imp::Vec4") align 8 %8, ptr noundef nonnull align 8 dereferenceable(88) %25, i32 noundef %26, i32 noundef %27)
  %28 = invoke noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi4EfEixEj(ptr noundef nonnull align 8 dereferenceable(40) %8, i32 noundef 3)
          to label %29 unwind label %44

29:                                               ; preds = %24
  store float 2.550000e+02, ptr %28, align 4, !tbaa !11
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = invoke noundef zeroext i1 @_ZNK3imp3VecILi4EfEeqERKS1_(ptr noundef nonnull align 8 dereferenceable(40) %8, ptr noundef nonnull align 8 dereferenceable(40) %30)
          to label %32 unwind label %44

32:                                               ; preds = %29
  br i1 %31, label %33, label %48

33:                                               ; preds = %32
  %34 = load ptr, ptr %3, align 8, !tbaa !5
  %35 = load ptr, ptr %3, align 8, !tbaa !5
  %36 = invoke noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88) %35)
          to label %37 unwind label %44

37:                                               ; preds = %33
  %38 = sub nsw i32 %36, 1
  %39 = load i32, ptr %5, align 4, !tbaa !9
  %40 = sub nsw i32 %38, %39
  %41 = load i32, ptr %7, align 4, !tbaa !9
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  invoke void @_ZN3imp5Image8setPixelEiiRKNS_4Vec4E(ptr noundef nonnull align 8 dereferenceable(88) %34, i32 noundef %40, i32 noundef %41, ptr noundef nonnull align 8 dereferenceable(40) %42)
          to label %43 unwind label %44

43:                                               ; preds = %37
  br label %48

44:                                               ; preds = %37, %33, %29, %24
  %45 = landingpad { ptr, i32 }
          cleanup
  %46 = extractvalue { ptr, i32 } %45, 0
  store ptr %46, ptr %9, align 8
  %47 = extractvalue { ptr, i32 } %45, 1
  store i32 %47, ptr %10, align 4
  call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %8) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %57

48:                                               ; preds = %43, %32
  call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %8) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %8) #4
  br label %49

49:                                               ; preds = %48
  %50 = load i32, ptr %7, align 4, !tbaa !9
  %51 = add nsw i32 %50, 1
  store i32 %51, ptr %7, align 4, !tbaa !9
  br label %18, !llvm.loop !13

52:                                               ; preds = %23
  br label %53

53:                                               ; preds = %52
  %54 = load i32, ptr %5, align 4, !tbaa !9
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %5, align 4, !tbaa !9
  br label %11, !llvm.loop !15

56:                                               ; preds = %16
  ret void

57:                                               ; preds = %44
  %58 = load ptr, ptr %9, align 8
  %59 = load i32, ptr %10, align 4
  %60 = insertvalue { ptr, i32 } poison, ptr %58, 0
  %61 = insertvalue { ptr, i32 } %60, i32 %59, 1
  resume { ptr, i32 } %61
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88)) #2

declare noundef i32 @_ZNK3imp5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(88)) #2

declare void @_ZNK3imp5Image8getPixelEii(ptr dead_on_unwind writable sret(%"class.imp::Vec4") align 8, ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi4EfEixEj(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3imp3VecILi4EfEeqERKS1_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(40)) #0 align 2

declare void @_ZN3imp5Image8setPixelEiiRKNS_4Vec4E(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(40)) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 = !{!"float", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


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

%"class.imp::Vec4" = type { %"class.imp::Vec.3" }
%"class.imp::Vec.3" = type { %"class.imp::Object", [4 x float] }
%"class.imp::Object" = type { ptr, %"class.std::shared_ptr" }
%"class.std::shared_ptr" = type { %"class.std::__shared_ptr" }
%"class.std::__shared_ptr" = type { ptr, %"class.std::__shared_count" }
%"class.std::__shared_count" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_Z4hsymRN3imp5ImageERKNS_4Vec4E(ptr noundef nonnull align 8 dereferenceable(88) %0, ptr noundef nonnull align 8 dereferenceable(40) %1) local_unnamed_addr #0 personality ptr @__gxx_personality_v0 {
  %3 = alloca %"class.imp::Vec4", align 8
  %4 = tail call noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %5 = icmp sgt i32 %4, 0
  br i1 %5, label %.preheader, label %._crit_edge19

.preheader:                                       ; preds = %2, %._crit_edge
  %.018 = phi i32 [ %9, %._crit_edge ], [ 0, %2 ]
  %6 = call noundef i32 @_ZNK3imp5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %7 = icmp sgt i32 %6, 0
  br i1 %7, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %.preheader
  %8 = xor i32 %.018, -1
  br label %12

._crit_edge19:                                    ; preds = %._crit_edge, %2
  ret void

._crit_edge:                                      ; preds = %22, %.preheader
  %9 = add nuw nsw i32 %.018, 1
  %10 = call noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %11 = icmp slt i32 %9, %10
  br i1 %11, label %.preheader, label %._crit_edge19, !llvm.loop !5

12:                                               ; preds = %.lr.ph, %22
  %.01617 = phi i32 [ 0, %.lr.ph ], [ %23, %22 ]
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %3) #4
  call void @_ZNK3imp5Image8getPixelEii(ptr dead_on_unwind nonnull writable sret(%"class.imp::Vec4") align 8 %3, ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef %.018, i32 noundef %.01617)
  %13 = call noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi4EfEixEj(ptr noundef nonnull align 8 dereferenceable(40) %3, i32 noundef 3)
  store float 2.550000e+02, ptr %13, align 4, !tbaa !7
  %14 = invoke noundef zeroext i1 @_ZNK3imp3VecILi4EfEeqERKS1_(ptr noundef nonnull align 8 dereferenceable(40) %3, ptr noundef nonnull align 8 dereferenceable(40) %1)
          to label %15 unwind label %20

15:                                               ; preds = %12
  br i1 %14, label %16, label %22

16:                                               ; preds = %15
  %17 = invoke noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
          to label %18 unwind label %20

18:                                               ; preds = %16
  %19 = add i32 %17, %8
  invoke void @_ZN3imp5Image8setPixelEiiRKNS_4Vec4E(ptr noundef nonnull align 8 dereferenceable(88) %0, i32 noundef %19, i32 noundef %.01617, ptr noundef nonnull align 8 dereferenceable(40) %1)
          to label %22 unwind label %20

20:                                               ; preds = %18, %16, %12
  %21 = landingpad { ptr, i32 }
          cleanup
  call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %3) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #4
  resume { ptr, i32 } %21

22:                                               ; preds = %18, %15
  call void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(40) %3) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %3) #4
  %23 = add nuw nsw i32 %.01617, 1
  %24 = call noundef i32 @_ZNK3imp5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(88) %0)
  %25 = icmp slt i32 %23, %24
  br i1 %25, label %12, label %._crit_edge, !llvm.loop !11
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare noundef i32 @_ZNK3imp5Image5widthEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

declare noundef i32 @_ZNK3imp5Image6heightEv(ptr noundef nonnull align 8 dereferenceable(88)) local_unnamed_addr #2

declare void @_ZNK3imp5Image8getPixelEii(ptr dead_on_unwind writable sret(%"class.imp::Vec4") align 8, ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef nonnull align 4 dereferenceable(4) ptr @_ZN3imp3VecILi4EfEixEj(ptr noundef nonnull align 8 dereferenceable(40), i32 noundef) local_unnamed_addr #3 align 2

declare i32 @__gxx_personality_v0(...)

; Function Attrs: mustprogress uwtable
declare dso_local noundef zeroext i1 @_ZNK3imp3VecILi4EfEeqERKS1_(ptr noundef nonnull align 8 dereferenceable(40), ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #0 align 2

declare void @_ZN3imp5Image8setPixelEiiRKNS_4Vec4E(ptr noundef nonnull align 8 dereferenceable(88), i32 noundef, i32 noundef, ptr noundef nonnull align 8 dereferenceable(40)) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3imp6ObjectD2Ev(ptr noundef nonnull align 8 dereferenceable(24)) unnamed_addr #3 align 2

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 = distinct !{!5, !6}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!8, !8, i64 0}
!8 = !{!"float", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = distinct !{!11, !6}


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