; LLVM IR from awawa-dev/HyperHDR :: sources/effects/Animation_Plasma.ll (ZN16Animation_PlasmaC2Ev)

; 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.Animation_Plasma = type { %class.AnimationBase.base, i64, [3600 x i32], [1080 x i8] }
%class.AnimationBase.base = type <{ ptr, i32, i8 }>

@_ZTV16Animation_Plasma = external dso_local unnamed_addr constant { [10 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16Animation_PlasmaC2Ev(ptr noundef nonnull align 8 dereferenceable(15504) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %10 = load ptr, ptr %2, align 8
  call void @_ZN13AnimationBaseC2Ev(ptr noundef nonnull align 8 dereferenceable(13) %10)
  store ptr getelementptr inbounds inrange(-16, 64) ({ [10 x ptr] }, ptr @_ZTV16Animation_Plasma, i32 0, i32 0, i32 2), ptr %10, align 8, !tbaa !9
  %11 = invoke noundef i64 @_ZN13InternalClock3nowEv()
          to label %12 unwind label %18

12:                                               ; preds = %1
  %13 = getelementptr inbounds %class.Animation_Plasma, ptr %10, i32 0, i32 1
  store i64 %11, ptr %13, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 0, ptr %5, align 4, !tbaa !17
  br label %14

14:                                               ; preds = %40, %12
  %15 = load i32, ptr %5, align 4, !tbaa !17
  %16 = icmp slt i32 %15, 360
  br i1 %16, label %22, label %17

17:                                               ; preds = %14
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  br label %43

18:                                               ; preds = %1
  %19 = landingpad { ptr, i32 }
          cleanup
  %20 = extractvalue { ptr, i32 } %19, 0
  store ptr %20, ptr %3, align 8
  %21 = extractvalue { ptr, i32 } %19, 1
  store i32 %21, ptr %4, align 4
  call void @_ZN13AnimationBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(13) %10) #4
  br label %70

22:                                               ; preds = %14
  %23 = getelementptr inbounds %class.Animation_Plasma, ptr %10, i32 0, i32 3
  %24 = load i32, ptr %5, align 4, !tbaa !17
  %25 = mul nsw i32 %24, 3
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [1080 x i8], ptr %23, i64 0, i64 %26
  store i8 0, ptr %27, align 1, !tbaa !18
  %28 = getelementptr inbounds %class.Animation_Plasma, ptr %10, i32 0, i32 3
  %29 = load i32, ptr %5, align 4, !tbaa !17
  %30 = mul nsw i32 %29, 3
  %31 = add nsw i32 %30, 1
  %32 = sext i32 %31 to i64
  %33 = getelementptr inbounds [1080 x i8], ptr %28, i64 0, i64 %32
  store i8 0, ptr %33, align 1, !tbaa !18
  %34 = getelementptr inbounds %class.Animation_Plasma, ptr %10, i32 0, i32 3
  %35 = load i32, ptr %5, align 4, !tbaa !17
  %36 = mul nsw i32 %35, 3
  %37 = add nsw i32 %36, 2
  %38 = sext i32 %37 to i64
  %39 = getelementptr inbounds [1080 x i8], ptr %34, i64 0, i64 %38
  store i8 0, ptr %39, align 1, !tbaa !18
  br label %40

40:                                               ; preds = %22
  %41 = load i32, ptr %5, align 4, !tbaa !17
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %5, align 4, !tbaa !17
  br label %14, !llvm.loop !19

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

44:                                               ; preds = %66, %43
  %45 = load i32, ptr %6, align 4, !tbaa !17
  %46 = icmp slt i32 %45, 45
  br i1 %46, label %48, label %47

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

48:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 0, ptr %8, align 4, !tbaa !17
  br label %49

49:                                               ; preds = %62, %48
  %50 = load i32, ptr %8, align 4, !tbaa !17
  %51 = icmp slt i32 %50, 80
  br i1 %51, label %53, label %52

52:                                               ; preds = %49
  store i32 8, ptr %7, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %65

53:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %54 = load i32, ptr %6, align 4, !tbaa !17
  %55 = mul nsw i32 %54, 80
  store i32 %55, ptr %9, align 4, !tbaa !17
  %56 = getelementptr inbounds %class.Animation_Plasma, ptr %10, i32 0, i32 2
  %57 = load i32, ptr %9, align 4, !tbaa !17
  %58 = load i32, ptr %8, align 4, !tbaa !17
  %59 = add nsw i32 %57, %58
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [3600 x i32], ptr %56, i64 0, i64 %60
  store i32 0, ptr %61, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  br label %62

62:                                               ; preds = %53
  %63 = load i32, ptr %8, align 4, !tbaa !17
  %64 = add nsw i32 %63, 1
  store i32 %64, ptr %8, align 4, !tbaa !17
  br label %49, !llvm.loop !21

65:                                               ; preds = %52
  br label %66

66:                                               ; preds = %65
  %67 = load i32, ptr %6, align 4, !tbaa !17
  %68 = add nsw i32 %67, 1
  store i32 %68, ptr %6, align 4, !tbaa !17
  br label %44, !llvm.loop !22

69:                                               ; preds = %47
  ret void

70:                                               ; preds = %18
  %71 = load ptr, ptr %3, align 8
  %72 = load i32, ptr %4, align 4
  %73 = insertvalue { ptr, i32 } poison, ptr %71, 0
  %74 = insertvalue { ptr, i32 } %73, i32 %72, 1
  resume { ptr, i32 } %74
}

declare void @_ZN13AnimationBaseC2Ev(ptr noundef nonnull align 8 dereferenceable(13)) unnamed_addr #1

declare noundef i64 @_ZN13InternalClock3nowEv() #1

declare i32 @__gxx_personality_v0(...)

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN13AnimationBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(13)) 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 = { "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 willreturn memory(argmem: readwrite) }
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 = !{!"vtable pointer", !8, i64 0}
!11 = !{!12, !16, i64 16}
!12 = !{!"_ZTS16Animation_Plasma", !13, i64 0, !16, i64 16, !7, i64 24, !7, i64 14424}
!13 = !{!"_ZTS13AnimationBase", !14, i64 8, !15, i64 12}
!14 = !{!"int", !7, i64 0}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"long long", !7, i64 0}
!17 = !{!14, !14, i64 0}
!18 = !{!7, !7, i64 0}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}
!21 = distinct !{!21, !20}
!22 = distinct !{!22, !20}


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

@_ZTV16Animation_Plasma = external dso_local unnamed_addr constant { [10 x ptr] }, align 8

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN16Animation_PlasmaC2Ev(ptr noundef nonnull align 8 dereferenceable(15504) %0) unnamed_addr #0 align 2 personality ptr @__gxx_personality_v0 {
  tail call void @_ZN13AnimationBaseC2Ev(ptr noundef nonnull align 8 dereferenceable(13) %0)
  store ptr getelementptr inbounds inrange(-16, 64) (i8, ptr @_ZTV16Animation_Plasma, i64 16), ptr %0, align 8, !tbaa !5
  %2 = invoke noundef i64 @_ZN13InternalClock3nowEv()
          to label %.preheader16 unwind label %4

.preheader16:                                     ; preds = %1
  %3 = getelementptr inbounds i8, ptr %0, i64 16
  store i64 %2, ptr %3, align 8, !tbaa !8
  %scevgep22 = getelementptr inbounds i8, ptr %0, i64 24
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(15480) %scevgep22, i8 0, i64 15480, i1 false)
  ret void

4:                                                ; preds = %1
  %5 = landingpad { ptr, i32 }
          cleanup
  tail call void @_ZN13AnimationBaseD2Ev(ptr noundef nonnull align 8 dereferenceable(13) %0) #4
  resume { ptr, i32 } %5
}

declare void @_ZN13AnimationBaseC2Ev(ptr noundef nonnull align 8 dereferenceable(13)) unnamed_addr #1

declare noundef i64 @_ZN13InternalClock3nowEv() local_unnamed_addr #1

declare i32 @__gxx_personality_v0(...)

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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 = { 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"vtable pointer", !7, i64 0}
!7 = !{!"Simple C++ TBAA"}
!8 = !{!9, !14, i64 16}
!9 = !{!"_ZTS16Animation_Plasma", !10, i64 0, !14, i64 16, !12, i64 24, !12, i64 14424}
!10 = !{!"_ZTS13AnimationBase", !11, i64 8, !13, i64 12}
!11 = !{!"int", !12, i64 0}
!12 = !{!"omnipotent char", !7, i64 0}
!13 = !{!"bool", !12, i64 0}
!14 = !{!"long long", !12, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopIdiomRecognizePass,LoopRotatePass,LoopSimplifyPass,MemCpyOptPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass