; 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local void @RandomFunc(ptr noundef %0, ptr noundef %1) #1 {
  %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 = xor i32 %10, 700325083
  %12 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  store i32 %11, ptr %12, align 4, !tbaa !9
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %36, %2
  %14 = load i32, ptr %6, align 4, !tbaa !9
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds i32, ptr %15, i64 1
  %17 = load i32, ptr %16, align 4, !tbaa !9
  %18 = icmp ult i32 %14, %17
  br i1 %18, label %19, label %41

19:                                               ; preds = %13
  %20 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %21 = load i32, ptr %20, align 4, !tbaa !9
  %22 = load i32, ptr %6, align 4, !tbaa !9
  %23 = icmp ne i32 %21, %22
  br i1 %23, label %36, label %24

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

36:                                               ; preds = %24, %19
  %37 = load i32, ptr %6, align 4, !tbaa !9
  %38 = zext i32 %37 to i64
  %39 = add i64 %38, 2
  %40 = trunc i64 %39 to i32
  store i32 %40, ptr %6, align 4, !tbaa !9
  br label %13, !llvm.loop !12

41:                                               ; preds = %13
  %42 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %43 = load i32, ptr %42, align 4, !tbaa !9
  %44 = shl i32 %43, 5
  %45 = shl i32 %44, 7
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds i32, ptr %46, i64 0
  store i32 %45, ptr %47, 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.end.p0(i64 immarg, ptr nocapture) #0

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = xor i32 %3, 700325083
  %.sroa.0.0.extract.trunc = trunc i32 %4 to i8
  %.sroa.7.0.extract.shift = lshr i32 %4, 8
  %.sroa.7.0.extract.trunc = trunc i32 %.sroa.7.0.extract.shift to i8
  %.sroa.9.0.extract.shift = and i32 %4, -65536
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not26 = icmp eq i32 %6, 0
  br i1 %.not26, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %7 = add i32 %6, -1
  %8 = icmp ult i32 %6, 3
  br i1 %8, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %9 = lshr i32 %7, 1
  %10 = add nuw i32 %9, 1
  %unroll_iter = and i32 %10, -2
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.sroa.7.024 = phi i8 [ %.sroa.7.0.extract.trunc, %.lr.ph.preheader.new ], [ %spec.select21.1, %.lr.ph ]
  %.023 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %14, %.lr.ph ]
  %.sroa.0.022 = 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.7.0.insert.ext = zext i8 %.sroa.7.024 to i32
  %.sroa.7.0.insert.shift = shl nuw nsw i32 %.sroa.7.0.insert.ext, 8
  %.sroa.0.0.insert.ext = zext i8 %.sroa.0.022 to i32
  %11 = or disjoint i32 %.sroa.7.0.insert.shift, %.sroa.0.0.insert.ext
  %.sroa.0.0.insert.insert = or disjoint i32 %11, %.sroa.9.0.extract.shift
  %.not = icmp eq i32 %.sroa.0.0.insert.insert, %.023
  %spec.select = select i1 %.not, i8 %.sroa.7.024, i8 %.sroa.0.022
  %spec.select21 = select i1 %.not, i8 %.sroa.0.022, i8 %.sroa.7.024
  %12 = or disjoint i32 %.023, 2
  %.sroa.7.0.insert.ext.1 = zext i8 %spec.select21 to i32
  %.sroa.7.0.insert.shift.1 = shl nuw nsw i32 %.sroa.7.0.insert.ext.1, 8
  %.sroa.0.0.insert.ext.1 = zext i8 %spec.select to i32
  %13 = or disjoint i32 %.sroa.7.0.insert.shift.1, %.sroa.0.0.insert.ext.1
  %.sroa.0.0.insert.insert.1 = or disjoint i32 %13, %.sroa.9.0.extract.shift
  %.not.1 = icmp eq i32 %.sroa.0.0.insert.insert.1, %12
  %spec.select.1 = select i1 %.not.1, i8 %spec.select21, i8 %spec.select
  %spec.select21.1 = select i1 %.not.1, i8 %spec.select, i8 %spec.select21
  %14 = add nuw i32 %.023, 4
  %niter.next.1 = add nuw i32 %niter, 2
  %niter.ncmp.1.not = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1.not, 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.select21.lcssa.ph = phi i8 [ poison, %.lr.ph.preheader ], [ %spec.select21.1, %.lr.ph ]
  %.sroa.7.024.unr = phi i8 [ %.sroa.7.0.extract.trunc, %.lr.ph.preheader ], [ %spec.select21.1, %.lr.ph ]
  %.023.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %14, %.lr.ph ]
  %.sroa.0.022.unr = phi i8 [ %.sroa.0.0.extract.trunc, %.lr.ph.preheader ], [ %spec.select.1, %.lr.ph ]
  %15 = and i32 %7, 2
  %lcmp.mod.not.not = icmp eq i32 %15, 0
  br i1 %lcmp.mod.not.not, label %.lr.ph.epil, label %._crit_edge

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %.sroa.7.0.insert.ext.epil = zext i8 %.sroa.7.024.unr to i32
  %.sroa.7.0.insert.shift.epil = shl nuw nsw i32 %.sroa.7.0.insert.ext.epil, 8
  %.sroa.0.0.insert.ext.epil = zext i8 %.sroa.0.022.unr to i32
  %16 = or disjoint i32 %.sroa.7.0.insert.shift.epil, %.sroa.0.0.insert.ext.epil
  %.sroa.0.0.insert.insert.epil = or disjoint i32 %16, %.sroa.9.0.extract.shift
  %.not.epil = icmp eq i32 %.sroa.0.0.insert.insert.epil, %.023.unr
  %spec.select.epil = select i1 %.not.epil, i8 %.sroa.7.024.unr, i8 %.sroa.0.022.unr
  %spec.select21.epil = select i1 %.not.epil, i8 %.sroa.0.022.unr, i8 %.sroa.7.024.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.7.0.lcssa = phi i8 [ %.sroa.7.0.extract.trunc, %2 ], [ %spec.select21.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %spec.select21.epil, %.lr.ph.epil ]
  %.sroa.9.0.insert.shift16 = and i32 %4, 983040
  %.sroa.7.0.insert.ext10 = zext i8 %.sroa.7.0.lcssa to i32
  %.sroa.7.0.insert.shift11 = shl nuw nsw i32 %.sroa.7.0.insert.ext10, 8
  %.sroa.7.0.insert.insert13 = or disjoint i32 %.sroa.7.0.insert.shift11, %.sroa.9.0.insert.shift16
  %.sroa.0.0.insert.ext6 = zext i8 %.sroa.0.0.lcssa to i32
  %.sroa.0.0.insert.insert8 = or disjoint i32 %.sroa.7.0.insert.insert13, %.sroa.0.0.insert.ext6
  %17 = shl nuw i32 %.sroa.0.0.insert.insert8, 12
  store i32 %17, 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: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass