; 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 i16], align 2
  %6 = alloca i16, align 2
  %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 2, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 2, 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 i16, ptr %8, i64 0
  %10 = load i16, ptr %9, align 2, !tbaa !9
  %11 = zext i16 %10 to i64
  %12 = and i64 %11, 914778474
  %13 = shl i64 %12, 7
  %14 = trunc i64 %13 to i16
  %15 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  store i16 %14, ptr %15, align 2, !tbaa !9
  store i16 0, ptr %6, align 2, !tbaa !9
  br label %16

16:                                               ; preds = %24, %2
  %17 = load i16, ptr %6, align 2, !tbaa !9
  %18 = zext i16 %17 to i32
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = getelementptr inbounds i16, ptr %19, i64 1
  %21 = load i16, ptr %20, align 2, !tbaa !9
  %22 = zext i16 %21 to i32
  %23 = icmp slt i32 %18, %22
  br i1 %23, label %24, label %37

24:                                               ; preds = %16
  %25 = load i16, ptr %6, align 2, !tbaa !9
  %26 = zext i16 %25 to i64
  %27 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %26
  %28 = load i16, ptr %27, align 2, !tbaa !9
  %29 = zext i16 %28 to i32
  %30 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %31 = load i16, ptr %30, align 2, !tbaa !9
  %32 = zext i16 %31 to i32
  %33 = and i32 %32, %29
  %34 = trunc i32 %33 to i16
  store i16 %34, ptr %30, align 2, !tbaa !9
  %35 = load i16, ptr %6, align 2, !tbaa !9
  %36 = add i16 %35, 1
  store i16 %36, ptr %6, align 2, !tbaa !9
  br label %16, !llvm.loop !11

37:                                               ; preds = %16
  store i16 0, ptr %6, align 2, !tbaa !9
  br label %38

38:                                               ; preds = %46, %37
  %39 = load i16, ptr %6, align 2, !tbaa !9
  %40 = zext i16 %39 to i32
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = getelementptr inbounds i16, ptr %41, i64 1
  %43 = load i16, ptr %42, align 2, !tbaa !9
  %44 = zext i16 %43 to i32
  %45 = icmp slt i32 %40, %44
  br i1 %45, label %46, label %68

46:                                               ; preds = %38
  %47 = load i16, ptr %6, align 2, !tbaa !9
  %48 = zext i16 %47 to i64
  %49 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %48
  %50 = getelementptr inbounds i8, ptr %49, i64 0
  %51 = load i8, ptr %50, align 1, !tbaa !13
  store i8 %51, ptr %7, align 1, !tbaa !13
  %52 = load i16, ptr %6, align 2, !tbaa !9
  %53 = zext i16 %52 to i64
  %54 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %53
  %55 = getelementptr inbounds i8, ptr %54, i64 1
  %56 = load i8, ptr %55, align 1, !tbaa !13
  %57 = load i16, ptr %6, align 2, !tbaa !9
  %58 = zext i16 %57 to i64
  %59 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %58
  %60 = getelementptr inbounds i8, ptr %59, i64 0
  store i8 %56, ptr %60, align 1, !tbaa !13
  %61 = load i8, ptr %7, align 1, !tbaa !13
  %62 = load i16, ptr %6, align 2, !tbaa !9
  %63 = zext i16 %62 to i64
  %64 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %63
  %65 = getelementptr inbounds i8, ptr %64, i64 1
  store i8 %61, ptr %65, align 1, !tbaa !13
  %66 = load i16, ptr %6, align 2, !tbaa !9
  %67 = add i16 %66, 1
  store i16 %67, ptr %6, align 2, !tbaa !9
  br label %38, !llvm.loop !14

68:                                               ; preds = %38
  %69 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %70 = load i16, ptr %69, align 2, !tbaa !9
  %71 = zext i16 %70 to i64
  %72 = xor i64 %71, 875420553
  %73 = lshr i64 %72, 1
  %74 = trunc i64 %73 to i16
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = getelementptr inbounds i16, ptr %75, i64 0
  store i16 %74, ptr %76, align 2, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 2, 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 = !{!"short", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!7, !7, i64 0}
!14 = distinct !{!14, !12}


; 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 {
.preheader:
  %2 = alloca [1 x i16], align 2
  call void @llvm.lifetime.start.p0(i64 2, ptr nonnull %2) #2
  %3 = load i16, ptr %0, align 2, !tbaa !5
  %4 = shl i16 %3, 7
  %5 = and i16 %4, -19200
  store i16 %5, ptr %2, align 2, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  %7 = load i16, ptr %6, align 2, !tbaa !5
  %invariant.gep = getelementptr inbounds i8, ptr %2, i64 1
  %.not = icmp eq i16 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %.preheader
  %wide.trip.count = zext i16 %7 to i64
  %xtraiter = and i64 %wide.trip.count, 3
  %8 = icmp ult i16 %7, 4
  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 i64 %wide.trip.count, 65532
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.3, %.lr.ph ]
  %9 = phi i8 [ 0, %.lr.ph.preheader.new ], [ %13, %.lr.ph ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.3, %.lr.ph ]
  %gep = getelementptr inbounds [1 x i16], ptr %invariant.gep, i64 0, i64 %indvars.iv
  %10 = load i8, ptr %gep, align 1, !tbaa !9
  store i8 %9, ptr %gep, align 1, !tbaa !9
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %gep.1 = getelementptr inbounds [1 x i16], ptr %invariant.gep, i64 0, i64 %indvars.iv.next
  %11 = load i8, ptr %gep.1, align 1, !tbaa !9
  store i8 %10, ptr %gep.1, align 1, !tbaa !9
  %indvars.iv.next.1 = or disjoint i64 %indvars.iv, 2
  %gep.2 = getelementptr inbounds [1 x i16], ptr %invariant.gep, i64 0, i64 %indvars.iv.next.1
  %12 = load i8, ptr %gep.2, align 1, !tbaa !9
  store i8 %11, ptr %gep.2, align 1, !tbaa !9
  %indvars.iv.next.2 = or disjoint i64 %indvars.iv, 3
  %gep.3 = getelementptr inbounds [1 x i16], ptr %invariant.gep, i64 0, i64 %indvars.iv.next.2
  %13 = load i8, ptr %gep.3, align 1, !tbaa !9
  store i8 %12, ptr %gep.3, align 1, !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 %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !10

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

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil
  %indvars.iv.epil = phi i64 [ %indvars.iv.next.epil, %.lr.ph.epil ], [ %indvars.iv.unr, %._crit_edge.loopexit.unr-lcssa ]
  %14 = phi i8 [ %15, %.lr.ph.epil ], [ %.unr, %._crit_edge.loopexit.unr-lcssa ]
  %epil.iter = phi i64 [ %epil.iter.next, %.lr.ph.epil ], [ 0, %._crit_edge.loopexit.unr-lcssa ]
  %gep.epil = getelementptr inbounds [1 x i16], ptr %invariant.gep, i64 0, i64 %indvars.iv.epil
  %15 = load i8, ptr %gep.epil, align 1, !tbaa !9
  store i8 %14, ptr %gep.epil, align 1, !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 %._crit_edge, label %.lr.ph.epil, !llvm.loop !12

._crit_edge:                                      ; preds = %._crit_edge.loopexit.unr-lcssa, %.lr.ph.epil, %.preheader
  %.lcssa13 = phi i8 [ 0, %.preheader ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %15, %.lr.ph.epil ]
  store i8 %.lcssa13, ptr %2, align 2, !tbaa !9
  %16 = load i16, ptr %2, align 2, !tbaa !5
  %17 = lshr i16 %16, 1
  %18 = xor i16 %17, -4668
  store i16 %18, ptr %1, align 2, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 2, ptr nonnull %2) #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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}


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