; LLVM IR from kobalicek/simdtests :: 3rdparty/real.ll (ZN3lol4log2ERKNS_4realE)

; 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.lol::real" = type { [16 x i32], i32 }

@_ZN3lol4real7R_LOG2EE = external dso_local global %"class.lol::real", align 4

; 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
declare dso_local void @_ZNK3lol4realplERKS0_(ptr dead_on_unwind noalias writable sret(%"class.lol::real") align 4, ptr noundef nonnull align 4 dereferenceable(68), ptr noundef nonnull align 4 dereferenceable(68)) #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3lol4realmlERKS0_(ptr dead_on_unwind noalias writable sret(%"class.lol::real") align 4, ptr noundef nonnull align 4 dereferenceable(68), ptr noundef nonnull align 4 dereferenceable(68)) #1 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN3lolL8fast_logERKNS_4realE(ptr dead_on_unwind noalias writable sret(%"class.lol::real") align 4, ptr noundef nonnull align 4 dereferenceable(68)) #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3lol4log2ERKNS_4realE(ptr dead_on_unwind noalias writable sret(%"class.lol::real") align 4 %0, ptr noundef nonnull align 4 dereferenceable(68) %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca %"class.lol::real", align 4
  %6 = alloca i32, align 4
  %7 = alloca %"class.lol::real", align 4
  %8 = alloca %"class.lol::real", align 4
  %9 = alloca %"class.lol::real", align 4
  store ptr %0, ptr %3, align 8
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 68, ptr %5) #2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_ZN3lol4realC1ERKS0_(ptr noundef nonnull align 4 dereferenceable(68) %5, ptr noundef nonnull align 4 dereferenceable(68) %10)
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = getelementptr inbounds %"class.lol::real", ptr %11, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !9
  %14 = lshr i32 %13, 31
  %15 = icmp ne i32 %14, 0
  br i1 %15, label %21, label %16

16:                                               ; preds = %2
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %"class.lol::real", ptr %17, i32 0, i32 1
  %19 = load i32, ptr %18, align 4, !tbaa !9
  %20 = icmp eq i32 %19, 0
  br i1 %20, label %21, label %25

21:                                               ; preds = %16, %2
  %22 = getelementptr inbounds %"class.lol::real", ptr %5, i32 0, i32 1
  store i32 -1, ptr %22, align 4, !tbaa !9
  %23 = getelementptr inbounds %"class.lol::real", ptr %5, i32 0, i32 0
  %24 = getelementptr inbounds [16 x i32], ptr %23, i64 0, i64 0
  store i32 -1, ptr %24, align 4, !tbaa !12
  call void @_ZN3lol4realC1ERKS0_(ptr noundef nonnull align 4 dereferenceable(68) %0, ptr noundef nonnull align 4 dereferenceable(68) %5)
  store i32 1, ptr %6, align 4
  br label %32

25:                                               ; preds = %16
  %26 = getelementptr inbounds %"class.lol::real", ptr %5, i32 0, i32 1
  store i32 1073741823, ptr %26, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 68, ptr %7) #2
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %"class.lol::real", ptr %27, i32 0, i32 1
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = sub i32 %29, 1073741824
  %31 = add i32 %30, 1
  call void @_ZN3lol4realC1Ei(ptr noundef nonnull align 4 dereferenceable(68) %7, i32 noundef %31)
  call void @llvm.lifetime.start.p0(i64 68, ptr %8) #2
  call void @llvm.lifetime.start.p0(i64 68, ptr %9) #2
  call void @_ZN3lolL8fast_logERKNS_4realE(ptr dead_on_unwind writable sret(%"class.lol::real") align 4 %9, ptr noundef nonnull align 4 dereferenceable(68) %5)
  call void @_ZNK3lol4realmlERKS0_(ptr dead_on_unwind writable sret(%"class.lol::real") align 4 %8, ptr noundef nonnull align 4 dereferenceable(68) %9, ptr noundef nonnull align 4 dereferenceable(68) @_ZN3lol4real7R_LOG2EE)
  call void @_ZNK3lol4realplERKS0_(ptr dead_on_unwind writable sret(%"class.lol::real") align 4 %0, ptr noundef nonnull align 4 dereferenceable(68) %7, ptr noundef nonnull align 4 dereferenceable(68) %8)
  call void @llvm.lifetime.end.p0(i64 68, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 68, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 68, ptr %7) #2
  store i32 1, ptr %6, align 4
  br label %32

32:                                               ; preds = %25, %21
  call void @llvm.lifetime.end.p0(i64 68, ptr %5) #2
  ret void
}

declare void @_ZN3lol4realC1ERKS0_(ptr, ptr)

declare void @_ZN3lol4realC1Ei(ptr, i32)

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 = { 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, !11, i64 64}
!10 = !{!"_ZTSN3lol4realE", !7, i64 0, !11, i64 64}
!11 = !{!"int", !7, i64 0}
!12 = !{!11, !11, i64 0}


; 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.lol::real" = type { [16 x i32], i32 }

@_ZN3lol4real7R_LOG2EE = external dso_local global %"class.lol::real", align 4

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

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

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3lol4realplERKS0_(ptr dead_on_unwind noalias writable sret(%"class.lol::real") align 4, ptr noundef nonnull align 4 dereferenceable(68), ptr noundef nonnull align 4 dereferenceable(68)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare dso_local void @_ZNK3lol4realmlERKS0_(ptr dead_on_unwind noalias writable sret(%"class.lol::real") align 4, ptr noundef nonnull align 4 dereferenceable(68), ptr noundef nonnull align 4 dereferenceable(68)) local_unnamed_addr #1 align 2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZN3lolL8fast_logERKNS_4realE(ptr dead_on_unwind noalias writable sret(%"class.lol::real") align 4, ptr noundef nonnull align 4 dereferenceable(68)) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3lol4log2ERKNS_4realE(ptr dead_on_unwind noalias writable sret(%"class.lol::real") align 4 %0, ptr noundef nonnull align 4 dereferenceable(68) %1) local_unnamed_addr #1 {
  %3 = alloca %"class.lol::real", align 4
  %4 = alloca %"class.lol::real", align 4
  %5 = alloca %"class.lol::real", align 4
  %6 = alloca %"class.lol::real", align 4
  call void @llvm.lifetime.start.p0(i64 68, ptr nonnull %3) #2
  call void @_ZN3lol4realC1ERKS0_(ptr noundef nonnull align 4 dereferenceable(68) %3, ptr noundef nonnull align 4 dereferenceable(68) %1)
  %7 = getelementptr inbounds i8, ptr %1, i64 64
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %or.cond = icmp slt i32 %8, 1
  %9 = getelementptr inbounds i8, ptr %3, i64 64
  br i1 %or.cond, label %10, label %11

10:                                               ; preds = %2
  store i32 -1, ptr %9, align 4, !tbaa !5
  store i32 -1, ptr %3, align 4, !tbaa !10
  call void @_ZN3lol4realC1ERKS0_(ptr noundef nonnull align 4 dereferenceable(68) %0, ptr noundef nonnull align 4 dereferenceable(68) %3)
  br label %13

11:                                               ; preds = %2
  store i32 1073741823, ptr %9, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 68, ptr nonnull %4) #2
  %12 = add nsw i32 %8, -1073741823
  call void @_ZN3lol4realC1Ei(ptr noundef nonnull align 4 dereferenceable(68) %4, i32 noundef %12)
  call void @llvm.lifetime.start.p0(i64 68, ptr nonnull %5) #2
  call void @llvm.lifetime.start.p0(i64 68, ptr nonnull %6) #2
  call void @_ZN3lolL8fast_logERKNS_4realE(ptr dead_on_unwind nonnull writable sret(%"class.lol::real") align 4 %6, ptr noundef nonnull align 4 dereferenceable(68) %3)
  call void @_ZNK3lol4realmlERKS0_(ptr dead_on_unwind nonnull writable sret(%"class.lol::real") align 4 %5, ptr noundef nonnull align 4 dereferenceable(68) %6, ptr noundef nonnull align 4 dereferenceable(68) @_ZN3lol4real7R_LOG2EE)
  call void @_ZNK3lol4realplERKS0_(ptr dead_on_unwind writable sret(%"class.lol::real") align 4 %0, ptr noundef nonnull align 4 dereferenceable(68) %4, ptr noundef nonnull align 4 dereferenceable(68) %5)
  call void @llvm.lifetime.end.p0(i64 68, ptr nonnull %6) #2
  call void @llvm.lifetime.end.p0(i64 68, ptr nonnull %5) #2
  call void @llvm.lifetime.end.p0(i64 68, ptr nonnull %4) #2
  br label %13

13:                                               ; preds = %11, %10
  call void @llvm.lifetime.end.p0(i64 68, ptr nonnull %3) #2
  ret void
}

declare void @_ZN3lol4realC1ERKS0_(ptr, ptr) local_unnamed_addr

declare void @_ZN3lol4realC1Ei(ptr, i32) local_unnamed_addr

attributes #0 = { mustprogress 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 = { 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, !9, i64 64}
!6 = !{!"_ZTSN3lol4realE", !7, i64 0, !9, i64 64}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!"int", !7, i64 0}
!10 = !{!9, !9, i64 0}


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