; 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 i16, align 2
  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 2, 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 = %22, %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 = load i32, ptr %6, align 4, !tbaa !9
  %24 = zext i32 %23 to i64
  %25 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %24
  %26 = getelementptr inbounds i16, ptr %25, i64 1
  %27 = load i16, ptr %26, align 2, !tbaa !11
  store i16 %27, ptr %7, align 2, !tbaa !11
  %28 = load i32, ptr %6, align 4, !tbaa !9
  %29 = zext i32 %28 to i64
  %30 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %29
  %31 = getelementptr inbounds i16, ptr %30, i64 0
  %32 = load i16, ptr %31, align 2, !tbaa !11
  %33 = load i32, ptr %6, align 4, !tbaa !9
  %34 = zext i32 %33 to i64
  %35 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %34
  %36 = getelementptr inbounds i16, ptr %35, i64 1
  store i16 %32, ptr %36, align 2, !tbaa !11
  %37 = load i16, ptr %7, align 2, !tbaa !11
  %38 = load i32, ptr %6, align 4, !tbaa !9
  %39 = zext i32 %38 to i64
  %40 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %39
  %41 = getelementptr inbounds i16, ptr %40, i64 0
  store i16 %37, ptr %41, align 2, !tbaa !11
  %42 = load i32, ptr %6, align 4, !tbaa !9
  %43 = add i32 %42, 1
  store i32 %43, ptr %6, align 4, !tbaa !9
  br label %16, !llvm.loop !13

44:                                               ; preds = %16
  store i32 0, ptr %6, align 4, !tbaa !9
  br label %45

45:                                               ; preds = %51, %44
  %46 = load i32, ptr %6, align 4, !tbaa !9
  %47 = load ptr, ptr %3, align 8, !tbaa !5
  %48 = getelementptr inbounds i32, ptr %47, i64 1
  %49 = load i32, ptr %48, align 4, !tbaa !9
  %50 = icmp ult i32 %46, %49
  br i1 %50, label %51, label %66

51:                                               ; preds = %45
  %52 = load i32, ptr %6, align 4, !tbaa !9
  %53 = zext i32 %52 to i64
  %54 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %53
  %55 = load i32, ptr %54, align 4, !tbaa !9
  %56 = load i32, ptr %6, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %57
  %59 = load i32, ptr %58, align 4, !tbaa !9
  %60 = add i32 %55, %59
  %61 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  store i32 %60, ptr %61, align 4, !tbaa !9
  %62 = load i32, ptr %6, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  %64 = add i64 %63, 2
  %65 = trunc i64 %64 to i32
  store i32 %65, ptr %6, align 4, !tbaa !9
  br label %45, !llvm.loop !15

66:                                               ; preds = %45
  %67 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %68 = load i32, ptr %67, align 4, !tbaa !9
  %69 = zext i32 %68 to i64
  %70 = add i64 %69, 973391845
  %71 = sub i64 %70, 2800048120
  %72 = trunc i64 %71 to i32
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds i32, ptr %73, i64 0
  store i32 %72, ptr %74, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 2, 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 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 = alloca [1 x i32], align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #2
  %4 = load i32, ptr %0, align 4, !tbaa !5
  %5 = mul i32 %4, -1620706538
  %6 = add i32 %5, -440795876
  store i32 %6, ptr %3, align 4, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  %8 = load i32, ptr %7, align 4, !tbaa !5
  %invariant.gep = getelementptr inbounds i8, ptr %3, i64 2
  %9 = trunc i32 %6 to i16
  %.not = icmp eq i32 %8, 0
  br i1 %.not, label %.preheader.thread, label %.lr.ph.preheader

.preheader.thread:                                ; preds = %2
  store i16 %9, ptr %3, align 4, !tbaa !9
  %.promoted1725 = load i32, ptr %3, align 4, !tbaa !5
  br label %._crit_edge

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext i32 %8 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %10 = icmp ult i32 %8, 4
  br i1 %10, label %.preheader.unr-lcssa, label %.lr.ph.preheader.new

.lr.ph.preheader.new:                             ; preds = %.lr.ph.preheader
  %unroll_iter = and i64 %wide.trip.count, 4294967292
  br label %.lr.ph

.preheader.unr-lcssa:                             ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa28.ph = phi i16 [ poison, %.lr.ph.preheader ], [ %21, %.lr.ph ]
  %indvars.iv.unr = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next.3, %.lr.ph ]
  %.unr = phi i16 [ %9, %.lr.ph.preheader ], [ %21, %.lr.ph ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.preheader.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %.preheader.unr-lcssa ]
  %11 = phi i16 [ %12, %.lr.ph.epil ], [ %.unr, %.preheader.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %.preheader.unr-lcssa ]
  %gep.epil = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv.epil
  %12 = load i16, ptr %gep.epil, align 2, !tbaa !9
  store i16 %11, ptr %gep.epil, align 2, !tbaa !9
  %indvars.iv.next.epil = add nuw nsw i64 %indvars.iv.epil, 1
  %epil.iter.next = add i64 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i64 %epil.iter.next, %xtraiter
  br i1 %epil.iter.cmp.not, label %.preheader, label %.lr.ph.epil, !llvm.loop !11

.preheader:                                       ; preds = %.lr.ph.epil, %.preheader.unr-lcssa
  %.lcssa28 = phi i16 [ %.lcssa28.ph, %.preheader.unr-lcssa ], [ %12, %.lr.ph.epil ]
  store i16 %.lcssa28, ptr %3, align 4, !tbaa !9
  %.promoted17 = load i32, ptr %3, align 4, !tbaa !5
  br i1 %.not, label %._crit_edge, label %.lr.ph20.preheader

.lr.ph20.preheader:                               ; preds = %.preheader
  %13 = add i32 %8, -1
  %14 = lshr i32 %13, 1
  %15 = add nuw i32 %14, 1
  %xtraiter30 = and i32 %15, 7
  %16 = icmp ult i32 %8, 15
  br i1 %16, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph20.preheader.new

.lr.ph20.preheader.new:                           ; preds = %.lr.ph20.preheader
  %unroll_iter35 = and i32 %15, -8
  br label %.lr.ph20

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %17 = phi i16 [ %9, %.lr.ph.preheader.new ], [ %21, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %gep = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv
  %18 = load i16, ptr %gep, align 2, !tbaa !9
  store i16 %17, ptr %gep, align 2, !tbaa !9
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %gep.1 = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv.next
  %19 = load i16, ptr %gep.1, align 2, !tbaa !9
  store i16 %18, ptr %gep.1, align 2, !tbaa !9
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %gep.2 = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv.next.1
  %20 = load i16, ptr %gep.2, align 2, !tbaa !9
  store i16 %19, ptr %gep.2, align 2, !tbaa !9
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %gep.3 = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv.next.2
  %21 = load i16, ptr %gep.3, align 2, !tbaa !9
  store i16 %20, ptr %gep.3, align 2, !tbaa !9
  %indvars.iv.next.3 = add nuw nsw i64 %indvars.iv, 4
  %niter.next.3 = add i64 %niter, 4
  %niter.ncmp.3 = icmp eq i64 %niter.next.3, %unroll_iter
  br i1 %niter.ncmp.3, label %.preheader.unr-lcssa, label %.lr.ph, !llvm.loop !13

.lr.ph20:                                         ; preds = %.lr.ph20, %.lr.ph20.preheader.new
  %22 = phi i32 [ %.promoted17, %.lr.ph20.preheader.new ], [ %23, %.lr.ph20 ]
  %niter36 = phi i32 [ 0, %.lr.ph20.preheader.new ], [ %niter36.next.7, %.lr.ph20 ]
  %23 = shl i32 %22, 8
  %niter36.next.7 = add i32 %niter36, 8
  %niter36.ncmp.7.not = icmp eq i32 %niter36.next.7, %unroll_iter35
  br i1 %niter36.ncmp.7.not, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph20, !llvm.loop !15

._crit_edge.loopexit.unr-lcssa:                   ; preds = %.lr.ph20, %.lr.ph20.preheader
  %.lcssa.ph = phi i32 [ poison, %.lr.ph20.preheader ], [ %23, %.lr.ph20 ]
  %.unr32 = phi i32 [ %.promoted17, %.lr.ph20.preheader ], [ %23, %.lr.ph20 ]
  %lcmp.mod33.not = icmp eq i32 %xtraiter30, 0
  br i1 %lcmp.mod33.not, label %._crit_edge, label %.lr.ph20.epil

.lr.ph20.epil:                                    ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph20.epil
  %24 = phi i32 [ %25, %.lr.ph20.epil ], [ %.unr32, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter31 = phi i32 [ %epil.iter31.next, %.lr.ph20.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %25 = shl i32 %24, 1
  %epil.iter31.next = add i32 %epil.iter31, 1
  %epil.iter31.cmp.not = icmp eq i32 %epil.iter31.next, %xtraiter30
  br i1 %epil.iter31.cmp.not, label %._crit_edge, label %.lr.ph20.epil, !llvm.loop !16

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph20.epil, %.preheader.thread, %.preheader
  %.lcssa18 = phi i32 [ %.promoted17, %.preheader ], [ %.promoted1725, %.preheader.thread ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %25, %.lr.ph20.epil ]
  %26 = add i32 %.lcssa18, -1826656275
  store i32 %26, ptr %1, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #2
  ret void
}

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

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

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" }
attributes #1 = { mustprogress 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"short", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.unroll.disable"}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !12}


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