; LLVM IR from stivalaa/EstimNetDirected :: src/Random123-1.09/examples (time_boxmuller)

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

%struct.r123array2x32 = type { [2 x i32] }
%struct.r123array2x64 = type { [2 x i64] }

@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1
@stderr = external global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1

; 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 norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca %struct.r123array2x32, align 4
  %7 = alloca %struct.r123array2x64, align 8
  %8 = alloca i64, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca %struct.r123array2x32, align 4
  %13 = alloca %struct.r123array2x64, align 8
  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 8, ptr %6) #8
  call void @llvm.memset.p0.i64(ptr align 4 %6, i8 0, i64 8, i1 false)
  call void @llvm.lifetime.start.p0(i64 16, ptr %7) #8
  call void @llvm.memset.p0.i64(ptr align 8 %7, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #8
  store i64 200000, ptr %8, align 8, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #8
  %14 = call ptr @getenv(ptr noundef @.str.6) #8
  store ptr %14, ptr %9, align 8, !tbaa !9
  %15 = load i32, ptr %4, align 4, !tbaa !5
  %16 = icmp sgt i32 %15, 1
  br i1 %16, label %17, label %36

17:                                               ; preds = %2
  %18 = load ptr, ptr %5, align 8, !tbaa !9
  %19 = getelementptr inbounds ptr, ptr %18, i64 1
  %20 = load ptr, ptr %19, align 8, !tbaa !9
  %21 = getelementptr inbounds i8, ptr %20, i64 0
  %22 = load i8, ptr %21, align 1, !tbaa !13
  %23 = sext i8 %22 to i32
  %24 = icmp eq i32 %23, 45
  br i1 %24, label %25, label %31

25:                                               ; preds = %17
  %26 = load ptr, ptr @stderr, align 8, !tbaa !9
  %27 = load ptr, ptr %5, align 8, !tbaa !9
  %28 = getelementptr inbounds ptr, ptr %27, i64 0
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.7, ptr noundef %29) #8
  call void @exit(i32 noundef 1) #9
  unreachable

31:                                               ; preds = %17
  %32 = load ptr, ptr %5, align 8, !tbaa !9
  %33 = getelementptr inbounds ptr, ptr %32, i64 1
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  %35 = call i64 @atol(ptr noundef %34) #10
  store i64 %35, ptr %8, align 8, !tbaa !11
  br label %36

36:                                               ; preds = %31, %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #8
  store i32 0, ptr %10, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %61, %36
  %38 = load i32, ptr %10, align 4, !tbaa !5
  %39 = icmp slt i32 %38, 1
  br i1 %39, label %40, label %45

40:                                               ; preds = %37
  %41 = load i32, ptr %10, align 4, !tbaa !5
  %42 = add nsw i32 2, %41
  %43 = load i32, ptr %4, align 4, !tbaa !5
  %44 = icmp slt i32 %42, %43
  br label %45

45:                                               ; preds = %40, %37
  %46 = phi i1 [ false, %37 ], [ %44, %40 ]
  br i1 %46, label %48, label %47

47:                                               ; preds = %45
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #8
  br label %64

48:                                               ; preds = %45
  %49 = load ptr, ptr %5, align 8, !tbaa !9
  %50 = load i32, ptr %10, align 4, !tbaa !5
  %51 = add nsw i32 2, %50
  %52 = sext i32 %51 to i64
  %53 = getelementptr inbounds ptr, ptr %49, i64 %52
  %54 = load ptr, ptr %53, align 8, !tbaa !9
  %55 = call i64 @atol(ptr noundef %54) #10
  %56 = trunc i64 %55 to i32
  %57 = getelementptr inbounds %struct.r123array2x32, ptr %6, i32 0, i32 0
  %58 = load i32, ptr %10, align 4, !tbaa !5
  %59 = sext i32 %58 to i64
  %60 = getelementptr inbounds [2 x i32], ptr %57, i64 0, i64 %59
  store i32 %56, ptr %60, align 4, !tbaa !5
  br label %61

61:                                               ; preds = %48
  %62 = load i32, ptr %10, align 4, !tbaa !5
  %63 = add nsw i32 %62, 1
  store i32 %63, ptr %10, align 4, !tbaa !5
  br label %37, !llvm.loop !14

64:                                               ; preds = %47
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #8
  store i32 0, ptr %11, align 4, !tbaa !5
  br label %65

65:                                               ; preds = %88, %64
  %66 = load i32, ptr %11, align 4, !tbaa !5
  %67 = icmp slt i32 %66, 1
  br i1 %67, label %68, label %73

68:                                               ; preds = %65
  %69 = load i32, ptr %11, align 4, !tbaa !5
  %70 = add nsw i32 2, %69
  %71 = load i32, ptr %4, align 4, !tbaa !5
  %72 = icmp slt i32 %70, %71
  br label %73

73:                                               ; preds = %68, %65
  %74 = phi i1 [ false, %65 ], [ %72, %68 ]
  br i1 %74, label %76, label %75

75:                                               ; preds = %73
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #8
  br label %91

76:                                               ; preds = %73
  %77 = load ptr, ptr %5, align 8, !tbaa !9
  %78 = load i32, ptr %11, align 4, !tbaa !5
  %79 = add nsw i32 2, %78
  %80 = sext i32 %79 to i64
  %81 = getelementptr inbounds ptr, ptr %77, i64 %80
  %82 = load ptr, ptr %81, align 8, !tbaa !9
  %83 = call i64 @atol(ptr noundef %82) #10
  %84 = getelementptr inbounds %struct.r123array2x64, ptr %7, i32 0, i32 0
  %85 = load i32, ptr %11, align 4, !tbaa !5
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds [2 x i64], ptr %84, i64 0, i64 %86
  store i64 %83, ptr %87, align 8, !tbaa !11
  br label %88

88:                                               ; preds = %76
  %89 = load i32, ptr %11, align 4, !tbaa !5
  %90 = add nsw i32 %89, 1
  store i32 %90, ptr %11, align 4, !tbaa !5
  br label %65, !llvm.loop !16

91:                                               ; preds = %75
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %12, ptr align 4 %6, i64 8, i1 false), !tbaa.struct !17
  %92 = load i64, ptr %8, align 8, !tbaa !11
  %93 = load ptr, ptr %9, align 8, !tbaa !9
  %94 = getelementptr inbounds %struct.r123array2x32, ptr %12, i32 0, i32 0
  %95 = load i64, ptr %94, align 4
  call void @_Z9timedcallIN4r12312Philox4x32_RILj10EEEfNS0_6float2EEvPKcNT_9ukey_typeEmPc(ptr noundef @.str.8, i64 %95, i64 noundef %92, ptr noundef %93)
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %13, ptr align 8 %7, i64 16, i1 false), !tbaa.struct !18
  %96 = load i64, ptr %8, align 8, !tbaa !11
  %97 = load ptr, ptr %9, align 8, !tbaa !9
  %98 = getelementptr inbounds { i64, i64 }, ptr %13, i32 0, i32 0
  %99 = load i64, ptr %98, align 8
  %100 = getelementptr inbounds { i64, i64 }, ptr %13, i32 0, i32 1
  %101 = load i64, ptr %100, align 8
  call void @_Z9timedcallIN4r12314Threefry2x64_RILj20EEEdNS0_7double2EEvPKcNT_9ukey_typeEmPc(ptr noundef @.str.9, i64 %99, i64 %101, i64 noundef %96, ptr noundef %97)
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #8
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #8
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #8
  ret i32 0
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

; Function Attrs: nounwind
declare ptr @getenv(ptr noundef) #3

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #3

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

; Function Attrs: inlinehint mustprogress nounwind willreturn memory(read) uwtable
declare i64 @atol(ptr noundef nonnull) #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9timedcallIN4r12312Philox4x32_RILj10EEEfNS0_6float2EEvPKcNT_9ukey_typeEmPc(ptr noundef, i64, i64 noundef, ptr noundef) #6

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #7

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9timedcallIN4r12314Threefry2x64_RILj20EEEdNS0_7double2EEvPKcNT_9ukey_typeEmPc(ptr noundef, i64, i64, i64 noundef, ptr noundef) #6

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress norecurse 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { 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 = { 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 #5 = { inlinehint mustprogress nounwind willreturn memory(read) 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 #6 = { 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 #7 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #8 = { nounwind }
attributes #9 = { noreturn nounwind }
attributes #10 = { nounwind willreturn memory(read) }

!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 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = !{i64 0, i64 8, !13}
!18 = !{i64 0, i64 16, !13}


; 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.6 = external hidden unnamed_addr constant [19 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.7 = external hidden unnamed_addr constant [49 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = tail call ptr @getenv(ptr noundef nonnull @.str.6) #6
  %4 = icmp sgt i32 %0, 1
  br i1 %4, label %5, label %.preheader.thread

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = load i8, ptr %7, align 1, !tbaa !9
  %9 = icmp eq i8 %8, 45
  br i1 %9, label %10, label %14

10:                                               ; preds = %5
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = load ptr, ptr %1, align 8, !tbaa !5
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.7, ptr noundef %12) #7
  tail call void @exit(i32 noundef 1) #8
  unreachable

14:                                               ; preds = %5
  %15 = tail call i64 @atol(ptr nocapture noundef %7) #9
  %.not = icmp eq i32 %0, 2
  br i1 %.not, label %.preheader.thread, label %.lr.ph31.split

.preheader.thread:                                ; preds = %2, %14, %.lr.ph31.split
  %.sroa.026.0.lcssa38 = phi i64 [ %19, %.lr.ph31.split ], [ 0, %14 ], [ 0, %2 ]
  %.03437 = phi i64 [ %15, %.lr.ph31.split ], [ %15, %14 ], [ 200000, %2 ]
  %.sroa.0.0.lcssa = phi i64 [ %20, %.lr.ph31.split ], [ 0, %14 ], [ 0, %2 ]
  tail call void @_Z9timedcallIN4r12312Philox4x32_RILj10EEEfNS0_6float2EEvPKcNT_9ukey_typeEmPc(ptr noundef nonnull @.str.8, i64 %.sroa.026.0.lcssa38, i64 noundef %.03437, ptr noundef %3)
  tail call void @_Z9timedcallIN4r12314Threefry2x64_RILj20EEEdNS0_7double2EEvPKcNT_9ukey_typeEmPc(ptr noundef nonnull @.str.9, i64 %.sroa.0.0.lcssa, i64 0, i64 noundef %.03437, ptr noundef %3)
  ret i32 0

.lr.ph31.split:                                   ; preds = %14
  %16 = getelementptr inbounds i8, ptr %1, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !5
  %18 = tail call i64 @atol(ptr nocapture noundef %17) #9
  %19 = and i64 %18, 4294967295
  %20 = tail call i64 @atol(ptr nocapture noundef %17) #9
  br label %.preheader.thread
}

; Function Attrs: nofree nounwind memory(read)
declare noundef ptr @getenv(ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

; Function Attrs: inlinehint mustprogress nofree nounwind willreturn memory(read) uwtable
declare i64 @atol(ptr nocapture noundef nonnull) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9timedcallIN4r12312Philox4x32_RILj10EEEfNS0_6float2EEvPKcNT_9ukey_typeEmPc(ptr noundef, i64, i64 noundef, ptr noundef) local_unnamed_addr #5

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z9timedcallIN4r12314Threefry2x64_RILj20EEEdNS0_7double2EEvPKcNT_9ukey_typeEmPc(ptr noundef, i64, i64, i64 noundef, ptr noundef) local_unnamed_addr #5

attributes #0 = { mustprogress norecurse 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 = { nofree nounwind memory(read) "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 = { 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 #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 mustprogress nofree nounwind willreturn memory(read) 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 = { 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 #6 = { nounwind }
attributes #7 = { cold nounwind }
attributes #8 = { noreturn nounwind }
attributes #9 = { nounwind willreturn memory(read) }

!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 = !{!7, !7, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LCSSAPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass,TailCallElimPass