; LLVM IR from lemire/testingRNG :: practrand/src (testlehmer64)

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

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external global ptr, align 8

; Function Attrs: nounwind uwtable
define dso_local i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i64, align 8
  %9 = alloca [512 x i32], align 16
  %10 = alloca i32, align 4
  %11 = alloca [512 x i64], align 16
  %12 = alloca i32, align 4
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #6
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %13

13:                                               ; preds = %22, %2
  %14 = load i32, ptr %4, align 4, !tbaa !5
  %15 = load ptr, ptr %5, align 8, !tbaa !9
  %16 = call i32 @getopt(i32 noundef %14, ptr noundef %15, ptr noundef @.str) #6
  store i32 %16, ptr %6, align 4, !tbaa !5
  %17 = icmp ne i32 %16, -1
  br i1 %17, label %18, label %23

18:                                               ; preds = %13
  %19 = load i32, ptr %6, align 4, !tbaa !5
  switch i32 %19, label %21 [
    i32 72, label %20
  ]

20:                                               ; preds = %18
  store i32 1, ptr %7, align 4, !tbaa !5
  br label %22

21:                                               ; preds = %18
  call void @abort() #7
  unreachable

22:                                               ; preds = %20
  br label %13, !llvm.loop !11

23:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  store i64 12345678, ptr %8, align 8, !tbaa !13
  %24 = load i64, ptr %8, align 8, !tbaa !13
  call void @lehmer64_seed(i64 noundef %24)
  %25 = load i32, ptr %7, align 4, !tbaa !5
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %48

27:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 2048, ptr %9) #6
  br label %28

28:                                               ; preds = %44, %27
  br label %29

29:                                               ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %30

30:                                               ; preds = %41, %29
  %31 = load i32, ptr %10, align 4, !tbaa !5
  %32 = icmp slt i32 %31, 512
  br i1 %32, label %34, label %33

33:                                               ; preds = %30
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %44

34:                                               ; preds = %30
  %35 = call i64 @lehmer64()
  %36 = lshr i64 %35, 32
  %37 = trunc i64 %36 to i32
  %38 = load i32, ptr %10, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [512 x i32], ptr %9, i64 0, i64 %39
  store i32 %37, ptr %40, align 4, !tbaa !5
  br label %41

41:                                               ; preds = %34
  %42 = load i32, ptr %10, align 4, !tbaa !5
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %10, align 4, !tbaa !5
  br label %30, !llvm.loop !15

44:                                               ; preds = %33
  %45 = getelementptr inbounds [512 x i32], ptr %9, i64 0, i64 0
  %46 = load ptr, ptr @stdout, align 8, !tbaa !9
  %47 = call i64 @fwrite(ptr noundef %45, i64 noundef 2048, i64 noundef 1, ptr noundef %46)
  br label %28

48:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 4096, ptr %11) #6
  br label %49

49:                                               ; preds = %63, %48
  br label %50

50:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %60, %50
  %52 = load i32, ptr %12, align 4, !tbaa !5
  %53 = icmp slt i32 %52, 512
  br i1 %53, label %55, label %54

54:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %63

55:                                               ; preds = %51
  %56 = call i64 @lehmer64()
  %57 = load i32, ptr %12, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = getelementptr inbounds [512 x i64], ptr %11, i64 0, i64 %58
  store i64 %56, ptr %59, align 8, !tbaa !13
  br label %60

60:                                               ; preds = %55
  %61 = load i32, ptr %12, align 4, !tbaa !5
  %62 = add nsw i32 %61, 1
  store i32 %62, ptr %12, align 4, !tbaa !5
  br label %51, !llvm.loop !16

63:                                               ; preds = %54
  %64 = getelementptr inbounds [512 x i64], ptr %11, i64 0, i64 0
  %65 = load ptr, ptr @stdout, align 8, !tbaa !9
  %66 = call i64 @fwrite(ptr noundef %64, i64 noundef 4096, i64 noundef 1, ptr noundef %65)
  br label %49
}

; 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 i32 @getopt(i32 noundef, ptr noundef, ptr noundef) #2

; Function Attrs: noreturn nounwind
declare void @abort() #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @lehmer64_seed(i64 noundef) #4

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

declare i64 @fwrite(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @lehmer64() #4

attributes #0 = { 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 = { noreturn 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 = { inlinehint 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 #5 = { "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 #6 = { nounwind }
attributes #7 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !12}
!16 = distinct !{!16, !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"

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@stdout = external local_unnamed_addr global ptr, align 8

; Function Attrs: noreturn nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
.peel.begin:
  %2 = alloca [512 x i32], align 16
  %3 = alloca [512 x i64], align 16
  %4 = tail call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str) #6
  switch i32 %4, label %.loopexit [
    i32 -1, label %15
    i32 72, label %.peel.next
  ]

.peel.next:                                       ; preds = %.peel.begin, %.peel.next
  %5 = tail call i32 @getopt(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str) #6
  switch i32 %5, label %.loopexit [
    i32 -1, label %6
    i32 72, label %.peel.next
  ], !llvm.loop !5

.loopexit:                                        ; preds = %.peel.next, %.peel.begin
  tail call void @abort() #7
  unreachable

6:                                                ; preds = %.peel.next
  tail call void @lehmer64_seed(i64 noundef 12345678)
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %2) #6
  br label %10

7:                                                ; preds = %10
  %8 = load ptr, ptr @stdout, align 8, !tbaa !8
  %9 = call i64 @fwrite(ptr noundef nonnull %2, i64 noundef 2048, i64 noundef 1, ptr noundef %8)
  br label %.backedge26

10:                                               ; preds = %.backedge26, %6
  %indvars.iv = phi i64 [ 0, %6 ], [ %indvars.iv.be, %.backedge26 ]
  %11 = tail call i64 @lehmer64()
  %12 = lshr i64 %11, 32
  %13 = trunc nuw i64 %12 to i32
  %14 = getelementptr inbounds [512 x i32], ptr %2, i64 0, i64 %indvars.iv
  store i32 %13, ptr %14, align 4, !tbaa !12
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 512
  br i1 %exitcond.not, label %7, label %.backedge26

.backedge26:                                      ; preds = %10, %7
  %indvars.iv.be = phi i64 [ %indvars.iv.next, %10 ], [ 0, %7 ]
  br label %10, !llvm.loop !14

15:                                               ; preds = %.peel.begin
  tail call void @lehmer64_seed(i64 noundef 12345678)
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %3) #6
  br label %19

16:                                               ; preds = %19
  %17 = load ptr, ptr @stdout, align 8, !tbaa !8
  %18 = call i64 @fwrite(ptr noundef nonnull %3, i64 noundef 4096, i64 noundef 1, ptr noundef %17)
  br label %.backedge

19:                                               ; preds = %.backedge, %15
  %indvars.iv21 = phi i64 [ 0, %15 ], [ %indvars.iv21.be, %.backedge ]
  %20 = tail call i64 @lehmer64()
  %21 = getelementptr inbounds [512 x i64], ptr %3, i64 0, i64 %indvars.iv21
  store i64 %20, ptr %21, align 8, !tbaa !15
  %indvars.iv.next22 = add nuw nsw i64 %indvars.iv21, 1
  %exitcond24.not = icmp eq i64 %indvars.iv.next22, 512
  br i1 %exitcond24.not, label %16, label %.backedge

.backedge:                                        ; preds = %19, %16
  %indvars.iv21.be = phi i64 [ %indvars.iv.next22, %19 ], [ 0, %16 ]
  br label %19, !llvm.loop !17
}

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

; Function Attrs: nounwind
declare i32 @getopt(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #3

; Function Attrs: inlinehint nounwind uwtable
declare hidden void @lehmer64_seed(i64 noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i64 @fwrite(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #5

; Function Attrs: inlinehint nounwind uwtable
declare hidden i64 @lehmer64() local_unnamed_addr #4

attributes #0 = { noreturn 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 = { mustprogress 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 = { noreturn 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 = { inlinehint 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 #5 = { nofree 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 #6 = { nounwind }
attributes #7 = { noreturn 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, !7}
!6 = !{!"llvm.loop.mustprogress"}
!7 = !{!"llvm.loop.peeled.count", i32 1}
!8 = !{!9, !9, i64 0}
!9 = !{!"any pointer", !10, i64 0}
!10 = !{!"omnipotent char", !11, i64 0}
!11 = !{!"Simple C/C++ TBAA"}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !10, i64 0}
!14 = distinct !{!14, !6}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !10, i64 0}
!17 = distinct !{!17, !6}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LoopFullUnrollPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass