; LLVM IR from yuikns/panther :: ann/test/rand.ll (Z7annRan0v)

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

@annIdum = external dso_local global i32, align 4
@_ZZ7annRan0vE1y = external hidden global double, align 8
@_ZZ7annRan0vE1v = external hidden global [97 x double], align 16
@_ZZ7annRan0vE3iff = external hidden global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z7annRan0v() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca double, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %1) #3
  store i32 97, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #3
  store double 0x41E0000000000000, ptr %3, align 8, !tbaa !9
  %4 = load i32, ptr @annIdum, align 4, !tbaa !5
  %5 = icmp slt i32 %4, 0
  br i1 %5, label %9, label %6

6:                                                ; preds = %0
  %7 = load i32, ptr @_ZZ7annRan0vE3iff, align 4, !tbaa !5
  %8 = icmp eq i32 %7, 0
  br i1 %8, label %9, label %35

9:                                                ; preds = %6, %0
  store i32 1, ptr @_ZZ7annRan0vE3iff, align 4, !tbaa !5
  %10 = load i32, ptr @annIdum, align 4, !tbaa !5
  call void @srandom(i32 noundef %10) #3
  store i32 1, ptr @annIdum, align 4, !tbaa !5
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %11

11:                                               ; preds = %16, %9
  %12 = load i32, ptr %2, align 4, !tbaa !5
  %13 = icmp slt i32 %12, 97
  br i1 %13, label %14, label %19

14:                                               ; preds = %11
  %15 = call i64 @random() #3
  br label %16

16:                                               ; preds = %14
  %17 = load i32, ptr %2, align 4, !tbaa !5
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %2, align 4, !tbaa !5
  br label %11, !llvm.loop !11

19:                                               ; preds = %11
  store i32 0, ptr %2, align 4, !tbaa !5
  br label %20

20:                                               ; preds = %29, %19
  %21 = load i32, ptr %2, align 4, !tbaa !5
  %22 = icmp slt i32 %21, 97
  br i1 %22, label %23, label %32

23:                                               ; preds = %20
  %24 = call i64 @random() #3
  %25 = sitofp i64 %24 to double
  %26 = load i32, ptr %2, align 4, !tbaa !5
  %27 = sext i32 %26 to i64
  %28 = getelementptr inbounds [97 x double], ptr @_ZZ7annRan0vE1v, i64 0, i64 %27
  store double %25, ptr %28, align 8, !tbaa !9
  br label %29

29:                                               ; preds = %23
  %30 = load i32, ptr %2, align 4, !tbaa !5
  %31 = add nsw i32 %30, 1
  store i32 %31, ptr %2, align 4, !tbaa !5
  br label %20, !llvm.loop !13

32:                                               ; preds = %20
  %33 = call i64 @random() #3
  %34 = sitofp i64 %33 to double
  store double %34, ptr @_ZZ7annRan0vE1y, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %32, %6
  %36 = load double, ptr @_ZZ7annRan0vE1y, align 8, !tbaa !9
  %37 = fdiv double %36, 0x41E0000000000000
  %38 = fmul double 9.700000e+01, %37
  %39 = fptosi double %38 to i32
  store i32 %39, ptr %2, align 4, !tbaa !5
  %40 = load i32, ptr %2, align 4, !tbaa !5
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds [97 x double], ptr @_ZZ7annRan0vE1v, i64 0, i64 %41
  %43 = load double, ptr %42, align 8, !tbaa !9
  store double %43, ptr @_ZZ7annRan0vE1y, align 8, !tbaa !9
  %44 = call i64 @random() #3
  %45 = sitofp i64 %44 to double
  %46 = load i32, ptr %2, align 4, !tbaa !5
  %47 = sext i32 %46 to i64
  %48 = getelementptr inbounds [97 x double], ptr @_ZZ7annRan0vE1v, i64 0, i64 %47
  store double %45, ptr %48, align 8, !tbaa !9
  %49 = load double, ptr @_ZZ7annRan0vE1y, align 8, !tbaa !9
  %50 = fdiv double %49, 0x41E0000000000000
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  ret double %50
}

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

; Function Attrs: nounwind
declare void @srandom(i32 noundef) #2

; Function Attrs: nounwind
declare i64 @random() #2

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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !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"

@annIdum = external dso_local local_unnamed_addr global i32, align 4
@_ZZ7annRan0vE1y = external hidden local_unnamed_addr global double, align 8
@_ZZ7annRan0vE1v = external hidden local_unnamed_addr global [97 x double], align 16
@_ZZ7annRan0vE3iff = external hidden local_unnamed_addr global i32, align 4

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef double @_Z7annRan0v() local_unnamed_addr #0 {
  %1 = load i32, ptr @annIdum, align 4, !tbaa !5
  %2 = icmp slt i32 %1, 0
  %3 = load i32, ptr @_ZZ7annRan0vE3iff, align 4
  %4 = icmp eq i32 %3, 0
  %or.cond = select i1 %2, i1 true, i1 %4
  br i1 %or.cond, label %.preheader.preheader, label %._crit_edge

._crit_edge:                                      ; preds = %0
  %.pre = load double, ptr @_ZZ7annRan0vE1y, align 8, !tbaa !9
  br label %108

.preheader.preheader:                             ; preds = %0
  store i32 1, ptr @_ZZ7annRan0vE3iff, align 4, !tbaa !5
  tail call void @srandom(i32 noundef %1) #2
  store i32 1, ptr @annIdum, align 4, !tbaa !5
  %5 = tail call i64 @random() #2
  %6 = tail call i64 @random() #2
  %7 = tail call i64 @random() #2
  %8 = tail call i64 @random() #2
  %9 = tail call i64 @random() #2
  %10 = tail call i64 @random() #2
  %11 = tail call i64 @random() #2
  %12 = tail call i64 @random() #2
  %13 = tail call i64 @random() #2
  %14 = tail call i64 @random() #2
  %15 = tail call i64 @random() #2
  %16 = tail call i64 @random() #2
  %17 = tail call i64 @random() #2
  %18 = tail call i64 @random() #2
  %19 = tail call i64 @random() #2
  %20 = tail call i64 @random() #2
  %21 = tail call i64 @random() #2
  %22 = tail call i64 @random() #2
  %23 = tail call i64 @random() #2
  %24 = tail call i64 @random() #2
  %25 = tail call i64 @random() #2
  %26 = tail call i64 @random() #2
  %27 = tail call i64 @random() #2
  %28 = tail call i64 @random() #2
  %29 = tail call i64 @random() #2
  %30 = tail call i64 @random() #2
  %31 = tail call i64 @random() #2
  %32 = tail call i64 @random() #2
  %33 = tail call i64 @random() #2
  %34 = tail call i64 @random() #2
  %35 = tail call i64 @random() #2
  %36 = tail call i64 @random() #2
  %37 = tail call i64 @random() #2
  %38 = tail call i64 @random() #2
  %39 = tail call i64 @random() #2
  %40 = tail call i64 @random() #2
  %41 = tail call i64 @random() #2
  %42 = tail call i64 @random() #2
  %43 = tail call i64 @random() #2
  %44 = tail call i64 @random() #2
  %45 = tail call i64 @random() #2
  %46 = tail call i64 @random() #2
  %47 = tail call i64 @random() #2
  %48 = tail call i64 @random() #2
  %49 = tail call i64 @random() #2
  %50 = tail call i64 @random() #2
  %51 = tail call i64 @random() #2
  %52 = tail call i64 @random() #2
  %53 = tail call i64 @random() #2
  %54 = tail call i64 @random() #2
  %55 = tail call i64 @random() #2
  %56 = tail call i64 @random() #2
  %57 = tail call i64 @random() #2
  %58 = tail call i64 @random() #2
  %59 = tail call i64 @random() #2
  %60 = tail call i64 @random() #2
  %61 = tail call i64 @random() #2
  %62 = tail call i64 @random() #2
  %63 = tail call i64 @random() #2
  %64 = tail call i64 @random() #2
  %65 = tail call i64 @random() #2
  %66 = tail call i64 @random() #2
  %67 = tail call i64 @random() #2
  %68 = tail call i64 @random() #2
  %69 = tail call i64 @random() #2
  %70 = tail call i64 @random() #2
  %71 = tail call i64 @random() #2
  %72 = tail call i64 @random() #2
  %73 = tail call i64 @random() #2
  %74 = tail call i64 @random() #2
  %75 = tail call i64 @random() #2
  %76 = tail call i64 @random() #2
  %77 = tail call i64 @random() #2
  %78 = tail call i64 @random() #2
  %79 = tail call i64 @random() #2
  %80 = tail call i64 @random() #2
  %81 = tail call i64 @random() #2
  %82 = tail call i64 @random() #2
  %83 = tail call i64 @random() #2
  %84 = tail call i64 @random() #2
  %85 = tail call i64 @random() #2
  %86 = tail call i64 @random() #2
  %87 = tail call i64 @random() #2
  %88 = tail call i64 @random() #2
  %89 = tail call i64 @random() #2
  %90 = tail call i64 @random() #2
  %91 = tail call i64 @random() #2
  %92 = tail call i64 @random() #2
  %93 = tail call i64 @random() #2
  %94 = tail call i64 @random() #2
  %95 = tail call i64 @random() #2
  %96 = tail call i64 @random() #2
  %97 = tail call i64 @random() #2
  %98 = tail call i64 @random() #2
  %99 = tail call i64 @random() #2
  %100 = tail call i64 @random() #2
  %101 = tail call i64 @random() #2
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %.preheader
  %indvars.iv = phi i64 [ 0, %.preheader.preheader ], [ %indvars.iv.next, %.preheader ]
  %102 = tail call i64 @random() #2
  %103 = sitofp i64 %102 to double
  %104 = getelementptr inbounds [97 x double], ptr @_ZZ7annRan0vE1v, i64 0, i64 %indvars.iv
  store double %103, ptr %104, align 8, !tbaa !9
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 97
  br i1 %exitcond.not, label %105, label %.preheader, !llvm.loop !11

105:                                              ; preds = %.preheader
  %106 = tail call i64 @random() #2
  %107 = sitofp i64 %106 to double
  br label %108

108:                                              ; preds = %._crit_edge, %105
  %109 = phi double [ %.pre, %._crit_edge ], [ %107, %105 ]
  %110 = fmul double %109, 0x3E00000000000000
  %111 = fmul double %110, 9.700000e+01
  %112 = fptosi double %111 to i32
  %113 = sext i32 %112 to i64
  %114 = getelementptr inbounds [97 x double], ptr @_ZZ7annRan0vE1v, i64 0, i64 %113
  %115 = load double, ptr %114, align 8, !tbaa !9
  store double %115, ptr @_ZZ7annRan0vE1y, align 8, !tbaa !9
  %116 = tail call i64 @random() #2
  %117 = sitofp i64 %116 to double
  store double %117, ptr %114, align 8, !tbaa !9
  %118 = load double, ptr @_ZZ7annRan0vE1y, align 8, !tbaa !9
  %119 = fmul double %118, 0x3E00000000000000
  ret double %119
}

; Function Attrs: nounwind
declare void @srandom(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind
declare i64 @random() local_unnamed_addr #1

attributes #0 = { 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 #1 = { 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 #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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"double", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass,TailCallElimPass