; 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 = or i64 %11, 51238316
  %13 = lshr i64 %12, 3
  %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 %44

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 ugt i32 %24, %25
  br i1 %26, label %39, label %27

27:                                               ; preds = %22
  %28 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %29 = getelementptr inbounds i8, ptr %28, i64 2
  %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 1
  %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 2
  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 1
  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 = zext i32 %40 to i64
  %42 = add i64 %41, 2
  %43 = trunc i64 %42 to i32
  store i32 %43, ptr %6, align 4, !tbaa !9
  br label %16, !llvm.loop !12

44:                                               ; preds = %16
  %45 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %46 = load i32, ptr %45, align 4, !tbaa !9
  %47 = zext i32 %46 to i64
  %48 = xor i64 %47, 119333056
  %49 = xor i64 %48, 982322350
  %50 = trunc i64 %49 to i32
  %51 = load ptr, ptr %4, align 8, !tbaa !5
  %52 = getelementptr inbounds i32, ptr %51, i64 0
  store i32 %50, ptr %52, 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 = lshr i32 %3, 3
  %5 = or i32 %4, 6404789
  %.sroa.5.0.extract.shift = lshr i32 %5, 8
  %.sroa.5.0.extract.trunc = trunc i32 %.sroa.5.0.extract.shift to i8
  %.sroa.7.0.extract.shift = lshr i32 %5, 16
  %.sroa.7.0.extract.trunc = trunc i32 %.sroa.7.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
  %8 = lshr i32 %3, 3
  %.pre = and i32 %8, 520093696
  %.pre30 = and i32 %5, 255
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

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

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

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.sroa.7.028 = phi i8 [ %.sroa.7.0.extract.trunc, %.lr.ph.preheader.new ], [ %spec.select25.1, %.lr.ph ]
  %.027 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %18, %.lr.ph ]
  %.sroa.5.026 = phi i8 [ %.sroa.5.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.028 to i32
  %.sroa.7.0.insert.shift = shl nuw nsw i32 %.sroa.7.0.insert.ext, 16
  %.sroa.5.0.insert.ext = zext i8 %.sroa.5.026 to i32
  %.sroa.5.0.insert.shift = shl nuw nsw i32 %.sroa.5.0.insert.ext, 8
  %13 = or disjoint i32 %.sroa.7.0.insert.shift, %.sroa.5.0.insert.shift
  %.sroa.5.0.insert.insert = or disjoint i32 %13, %.pre
  %.sroa.0.0.insert.insert = or disjoint i32 %.sroa.5.0.insert.insert, %.pre30
  %14 = icmp ugt i32 %.sroa.0.0.insert.insert, %.027
  %spec.select = select i1 %14, i8 %.sroa.5.026, i8 %.sroa.7.028
  %spec.select25 = select i1 %14, i8 %.sroa.7.028, i8 %.sroa.5.026
  %15 = or disjoint i32 %.027, 2
  %.sroa.7.0.insert.ext.1 = zext i8 %spec.select25 to i32
  %.sroa.7.0.insert.shift.1 = shl nuw nsw i32 %.sroa.7.0.insert.ext.1, 16
  %.sroa.5.0.insert.ext.1 = zext i8 %spec.select to i32
  %.sroa.5.0.insert.shift.1 = shl nuw nsw i32 %.sroa.5.0.insert.ext.1, 8
  %16 = or disjoint i32 %.sroa.7.0.insert.shift.1, %.sroa.5.0.insert.shift.1
  %.sroa.5.0.insert.insert.1 = or disjoint i32 %16, %.pre
  %.sroa.0.0.insert.insert.1 = or disjoint i32 %.sroa.5.0.insert.insert.1, %.pre30
  %17 = icmp ugt i32 %.sroa.0.0.insert.insert.1, %15
  %spec.select.1 = select i1 %17, i8 %spec.select, i8 %spec.select25
  %spec.select25.1 = select i1 %17, i8 %spec.select25, i8 %spec.select
  %18 = add nuw i32 %.027, 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.select25.lcssa.ph = phi i8 [ poison, %.lr.ph.preheader ], [ %spec.select25.1, %.lr.ph ]
  %.sroa.7.028.unr = phi i8 [ %.sroa.7.0.extract.trunc, %.lr.ph.preheader ], [ %spec.select25.1, %.lr.ph ]
  %.027.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %18, %.lr.ph ]
  %.sroa.5.026.unr = phi i8 [ %.sroa.5.0.extract.trunc, %.lr.ph.preheader ], [ %spec.select.1, %.lr.ph ]
  %19 = and i32 %9, 2
  %lcmp.mod.not.not = icmp eq i32 %19, 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.028.unr to i32
  %.sroa.7.0.insert.shift.epil = shl nuw nsw i32 %.sroa.7.0.insert.ext.epil, 16
  %.sroa.5.0.insert.ext.epil = zext i8 %.sroa.5.026.unr to i32
  %.sroa.5.0.insert.shift.epil = shl nuw nsw i32 %.sroa.5.0.insert.ext.epil, 8
  %20 = or disjoint i32 %.sroa.7.0.insert.shift.epil, %.sroa.5.0.insert.shift.epil
  %.sroa.5.0.insert.insert.epil = or disjoint i32 %20, %.pre
  %.sroa.0.0.insert.insert.epil = or disjoint i32 %.sroa.5.0.insert.insert.epil, %.pre30
  %21 = icmp ugt i32 %.sroa.0.0.insert.insert.epil, %.027.unr
  %spec.select.epil = select i1 %21, i8 %.sroa.5.026.unr, i8 %.sroa.7.028.unr
  %spec.select25.epil = select i1 %21, i8 %.sroa.7.028.unr, i8 %.sroa.5.026.unr
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %2
  %.sroa.5.0.lcssa = phi i8 [ %.sroa.5.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.select25.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %spec.select25.epil, %.lr.ph.epil ]
  %.sroa.7.0.insert.ext14 = zext i8 %.sroa.7.0.lcssa to i32
  %.sroa.7.0.insert.shift15 = shl nuw nsw i32 %.sroa.7.0.insert.ext14, 16
  %.sroa.5.0.insert.ext9 = zext i8 %.sroa.5.0.lcssa to i32
  %.sroa.5.0.insert.shift10 = shl nuw nsw i32 %.sroa.5.0.insert.ext9, 8
  %22 = or disjoint i32 %.sroa.7.0.insert.shift15, %.sroa.5.0.insert.shift10
  %.sroa.5.0.insert.insert12 = or disjoint i32 %22, %.pre
  %.sroa.0.0.insert.insert7 = or disjoint i32 %.sroa.5.0.insert.insert12, %.pre30
  %23 = xor i32 %.sroa.0.0.insert.insert7, 1032973422
  store i32 %23, 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