; LLVM IR from tum-i4/obfuscation-benchmarks :: tigress-generated-programs (RandomFunc)

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

; Function Attrs: nounwind uwtable
define dso_local void @RandomFunc(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [1 x i32], align 4
  %6 = alloca i32, align 4
  %7 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 1, ptr %7) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds i32, ptr %8, i64 0
  %10 = load i32, ptr %9, align 4, !tbaa !9
  %11 = zext i32 %10 to i64
  %12 = add i64 %11, 914778474
  %13 = mul i64 %12, 2674260758
  %14 = trunc i64 %13 to i32
  %15 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  store i32 %14, ptr %15, align 4, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %16

16:                                               ; preds = %39, %2
  %17 = load i32, ptr %6, align 4, !tbaa !9
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = getelementptr inbounds i32, ptr %18, i64 1
  %20 = load i32, ptr %19, align 4, !tbaa !9
  %21 = icmp ult i32 %17, %20
  br i1 %21, label %22, label %42

22:                                               ; preds = %16
  %23 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %24 = load i32, ptr %23, align 4, !tbaa !9
  %25 = load i32, ptr %6, align 4, !tbaa !9
  %26 = icmp ult i32 %24, %25
  br i1 %26, label %27, label %39

27:                                               ; preds = %22
  %28 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %29 = getelementptr inbounds i8, ptr %28, i64 0
  %30 = load i8, ptr %29, align 1, !tbaa !11
  store i8 %30, ptr %7, align 1, !tbaa !11
  %31 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %32 = getelementptr inbounds i8, ptr %31, i64 3
  %33 = load i8, ptr %32, align 1, !tbaa !11
  %34 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %35 = getelementptr inbounds i8, ptr %34, i64 0
  store i8 %33, ptr %35, align 1, !tbaa !11
  %36 = load i8, ptr %7, align 1, !tbaa !11
  %37 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %38 = getelementptr inbounds i8, ptr %37, i64 3
  store i8 %36, ptr %38, align 1, !tbaa !11
  br label %39

39:                                               ; preds = %27, %22
  %40 = load i32, ptr %6, align 4, !tbaa !9
  %41 = add i32 %40, 1
  store i32 %41, ptr %6, align 4, !tbaa !9
  br label %16, !llvm.loop !12

42:                                               ; preds = %16
  %43 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %44 = load i32, ptr %43, align 4, !tbaa !9
  %45 = zext i32 %44 to i64
  %46 = add i64 %45, 940836162
  %47 = add i64 %46, 153539963
  %48 = trunc i64 %47 to i32
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds i32, ptr %49, i64 0
  store i32 %48, ptr %50, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  ret void
}

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

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

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 }

!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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

; Function Attrs: nofree norecurse nosync nounwind memory(argmem: readwrite) uwtable
define dso_local void @RandomFunc(ptr nocapture noundef readonly %0, ptr nocapture noundef writeonly %1) local_unnamed_addr #0 {
  %3 = load i32, ptr %0, align 4, !tbaa !5
  %4 = mul i32 %3, -1620706538
  %5 = add i32 %4, -440795876
  %.sroa.0.0.extract.trunc = trunc i32 %5 to i8
  %.sroa.714.0.extract.shift = lshr i32 %5, 24
  %.sroa.714.0.extract.trunc = trunc nuw i32 %.sroa.714.0.extract.shift to i8
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %.not = icmp eq i32 %7, 0
  %.pre = and i32 %5, 16776960
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %xtraiter = and i32 %7, 1
  %8 = icmp eq i32 %7, 1
  br i1 %8, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i32 %7, -2
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.sroa.714.025 = phi i8 [ %.sroa.714.0.extract.trunc, %.lr.ph.preheader.new ], [ %spec.select22.1, %.lr.ph ]
  %.024 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %12, %.lr.ph ]
  %.sroa.0.023 = phi i8 [ %.sroa.0.0.extract.trunc, %.lr.ph.preheader.new ], [ %spec.select.1, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %.sroa.714.0.insert.ext = zext i8 %.sroa.714.025 to i32
  %.sroa.714.0.insert.shift = shl nuw i32 %.sroa.714.0.insert.ext, 24
  %.sroa.0.0.insert.ext = zext i8 %.sroa.0.023 to i32
  %9 = or disjoint i32 %.sroa.714.0.insert.shift, %.sroa.0.0.insert.ext
  %.sroa.0.0.insert.insert = or disjoint i32 %9, %.pre
  %10 = icmp ult i32 %.sroa.0.0.insert.insert, %.024
  %spec.select = select i1 %10, i8 %.sroa.714.025, i8 %.sroa.0.023
  %spec.select22 = select i1 %10, i8 %.sroa.0.023, i8 %.sroa.714.025
  %.sroa.714.0.insert.ext.1 = zext i8 %spec.select22 to i32
  %.sroa.714.0.insert.shift.1 = shl nuw i32 %.sroa.714.0.insert.ext.1, 24
  %.sroa.0.0.insert.ext.1 = zext i8 %spec.select to i32
  %11 = or disjoint i32 %.sroa.714.0.insert.shift.1, %.sroa.0.0.insert.ext.1
  %.sroa.0.0.insert.insert.1 = or disjoint i32 %11, %.pre
  %.not29 = icmp ugt i32 %.sroa.0.0.insert.insert.1, %.024
  %spec.select.1 = select i1 %.not29, i8 %spec.select, i8 %spec.select22
  %spec.select22.1 = select i1 %.not29, i8 %spec.select22, i8 %spec.select
  %12 = add nuw i32 %.024, 2
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph, %.lr.ph.preheader
  %spec.select.lcssa.ph = phi i8 [ poison, %.lr.ph.preheader ], [ %spec.select.1, %.lr.ph ]
  %spec.select22.lcssa.ph = phi i8 [ poison, %.lr.ph.preheader ], [ %spec.select22.1, %.lr.ph ]
  %.sroa.714.025.unr = phi i8 [ %.sroa.714.0.extract.trunc, %.lr.ph.preheader ], [ %spec.select22.1, %.lr.ph ]
  %.024.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %12, %.lr.ph ]
  %.sroa.0.023.unr = phi i8 [ %.sroa.0.0.extract.trunc, %.lr.ph.preheader ], [ %spec.select.1, %.lr.ph ]
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %.sroa.714.0.insert.ext.epil = zext i8 %.sroa.714.025.unr to i32
  %.sroa.714.0.insert.shift.epil = shl nuw i32 %.sroa.714.0.insert.ext.epil, 24
  %.sroa.0.0.insert.ext.epil = zext i8 %.sroa.0.023.unr to i32
  %13 = or disjoint i32 %.sroa.714.0.insert.shift.epil, %.sroa.0.0.insert.ext.epil
  %.sroa.0.0.insert.insert.epil = or disjoint i32 %13, %.pre
  %14 = icmp ult i32 %.sroa.0.0.insert.insert.epil, %.024.unr
  %spec.select.epil = select i1 %14, i8 %.sroa.714.025.unr, i8 %.sroa.0.023.unr
  %spec.select22.epil = select i1 %14, i8 %.sroa.0.023.unr, i8 %.sroa.714.025.unr
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %2
  %.sroa.0.0.lcssa = phi i8 [ %.sroa.0.0.extract.trunc, %2 ], [ %spec.select.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %spec.select.epil, %.lr.ph.epil ]
  %.sroa.714.0.lcssa = phi i8 [ %.sroa.714.0.extract.trunc, %2 ], [ %spec.select22.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %spec.select22.epil, %.lr.ph.epil ]
  %.sroa.714.0.insert.ext16 = zext i8 %.sroa.714.0.lcssa to i32
  %.sroa.714.0.insert.shift17 = shl nuw i32 %.sroa.714.0.insert.ext16, 24
  %.sroa.0.0.insert.ext6 = zext i8 %.sroa.0.0.lcssa to i32
  %.sroa.7.0.insert.insert13 = add nuw nsw i32 %.pre, 1094376125
  %.sroa.0.0.insert.insert8 = add nuw nsw i32 %.sroa.7.0.insert.insert13, %.sroa.0.0.insert.ext6
  %15 = add i32 %.sroa.0.0.insert.insert8, %.sroa.714.0.insert.shift17
  store i32 %15, ptr %1, align 4, !tbaa !5
  ret void
}

attributes #0 = { nofree norecurse nosync nounwind memory(argmem: readwrite) 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" }

!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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass