; 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 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 = add i64 %11, 914778474
  %13 = xor i64 %12, 11
  %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 %41

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 = and i32 %29, 31
  %31 = shl i32 %30, 4
  %32 = load i16, ptr %6, align 2, !tbaa !9
  %33 = zext i16 %32 to i64
  %34 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %33
  %35 = load i16, ptr %34, align 2, !tbaa !9
  %36 = zext i16 %35 to i32
  %37 = or i32 %36, %31
  %38 = trunc i32 %37 to i16
  store i16 %38, ptr %34, align 2, !tbaa !9
  %39 = load i16, ptr %6, align 2, !tbaa !9
  %40 = add i16 %39, 1
  store i16 %40, ptr %6, align 2, !tbaa !9
  br label %16, !llvm.loop !11

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

42:                                               ; preds = %50, %41
  %43 = load i16, ptr %6, align 2, !tbaa !9
  %44 = zext i16 %43 to i32
  %45 = load ptr, ptr %3, align 8, !tbaa !5
  %46 = getelementptr inbounds i16, ptr %45, i64 1
  %47 = load i16, ptr %46, align 2, !tbaa !9
  %48 = zext i16 %47 to i32
  %49 = icmp slt i32 %44, %48
  br i1 %49, label %50, label %66

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

66:                                               ; preds = %42
  %67 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %68 = load i16, ptr %67, align 2, !tbaa !9
  %69 = zext i16 %68 to i32
  %70 = add nsw i32 %69, 44338
  %71 = trunc i32 %70 to i16
  %72 = load ptr, ptr %4, align 8, !tbaa !5
  %73 = getelementptr inbounds i16, ptr %72, i64 0
  store i16 %71, ptr %73, 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.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 = !{!"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 {
  %3 = load i16, ptr %0, align 2, !tbaa !5
  %4 = add i16 %3, 26986
  %5 = trunc i16 %4 to i8
  %.sroa.0.0.extract.trunc = xor i8 %5, 11
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  %7 = load i16, ptr %6, align 2, !tbaa !5
  %.not = icmp eq i16 %7, 0
  br i1 %.not, label %.preheader, label %.lr.ph.preheader

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

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

.preheader.loopexit.unr-lcssa:                    ; preds = %.lr.ph, %.lr.ph.preheader
  %.lcssa.ph = phi i16 [ poison, %.lr.ph.preheader ], [ %24, %.lr.ph ]
  %.sroa.0.0.extract.trunc15.lcssa.ph = phi i8 [ poison, %.lr.ph.preheader ], [ %.sroa.0.0.extract.trunc15.1, %.lr.ph ]
  %.sroa.0.024.unr = phi i8 [ %.sroa.0.0.extract.trunc, %.lr.ph.preheader ], [ %.sroa.0.0.extract.trunc15.1, %.lr.ph ]
  %.sroa.8.0.in.in23.unr = phi i16 [ %4, %.lr.ph.preheader ], [ %24, %.lr.ph ]
  %lcmp.mod.not = icmp eq i16 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.preheader, label %.lr.ph.epil

.lr.ph.epil:                                      ; preds = %.preheader.loopexit.unr-lcssa
  %.sroa.8.0.insert.shift18.epil = and i16 %.sroa.8.0.in.in23.unr, -256
  %.sroa.0.0.insert.ext12.epil = zext i8 %.sroa.0.024.unr to i16
  %9 = shl nuw nsw i16 %.sroa.0.0.insert.ext12.epil, 4
  %10 = and i16 %9, 496
  %11 = or i16 %.sroa.8.0.insert.shift18.epil, %10
  %12 = or i16 %11, %.sroa.0.0.insert.ext12.epil
  %.sroa.0.0.extract.trunc15.epil = trunc i16 %12 to i8
  br label %.preheader

.preheader:                                       ; preds = %.lr.ph.epil, %.preheader.loopexit.unr-lcssa, %2
  %.sroa.8.0.in.in.lcssa = phi i16 [ %4, %2 ], [ %.lcssa.ph, %.preheader.loopexit.unr-lcssa ], [ %12, %.lr.ph.epil ]
  %.sroa.0.0.lcssa = phi i8 [ %.sroa.0.0.extract.trunc, %2 ], [ %.sroa.0.0.extract.trunc15.lcssa.ph, %.preheader.loopexit.unr-lcssa ], [ %.sroa.0.0.extract.trunc15.epil, %.lr.ph.epil ]
  %.sroa.8.0.in.le = lshr i16 %.sroa.8.0.in.in.lcssa, 8
  %.sroa.8.0.le = trunc nuw i16 %.sroa.8.0.in.le to i8
  %13 = add i16 %7, 1
  %14 = lshr i16 %13, 1
  %15 = add nuw i16 %14, 1
  %xtraiter30 = and i16 %15, 7
  %16 = icmp ult i16 %13, 14
  br i1 %16, label %.unr-lcssa, label %.preheader.new

.preheader.new:                                   ; preds = %.preheader
  %unroll_iter34 = and i16 %15, -8
  br label %25

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.sroa.0.024 = phi i8 [ %.sroa.0.0.extract.trunc, %.lr.ph.preheader.new ], [ %.sroa.0.0.extract.trunc15.1, %.lr.ph ]
  %.sroa.8.0.in.in23 = phi i16 [ %4, %.lr.ph.preheader.new ], [ %24, %.lr.ph ]
  %niter = phi i16 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %.sroa.8.0.insert.shift18 = and i16 %.sroa.8.0.in.in23, -256
  %.sroa.0.0.insert.ext12 = zext i8 %.sroa.0.024 to i16
  %17 = shl nuw nsw i16 %.sroa.0.0.insert.ext12, 4
  %18 = and i16 %17, 256
  %19 = or i16 %.sroa.8.0.insert.shift18, %18
  %20 = trunc i16 %17 to i8
  %.sroa.0.0.extract.trunc15 = or i8 %.sroa.0.024, %20
  %.sroa.0.0.insert.ext12.1 = zext i8 %.sroa.0.0.extract.trunc15 to i16
  %21 = shl nuw nsw i16 %.sroa.0.0.insert.ext12.1, 4
  %22 = and i16 %21, 496
  %23 = or i16 %19, %22
  %24 = or i16 %23, %.sroa.0.0.insert.ext12.1
  %.sroa.0.0.extract.trunc15.1 = trunc i16 %24 to i8
  %niter.next.1 = add i16 %niter, 2
  %niter.ncmp.1 = icmp eq i16 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.preheader.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !9

25:                                               ; preds = %25, %.preheader.new
  %niter35 = phi i16 [ 0, %.preheader.new ], [ %niter35.next.7, %25 ]
  %niter35.next.7 = add i16 %niter35, 8
  %niter35.ncmp.7.not = icmp eq i16 %niter35.next.7, %unroll_iter34
  br i1 %niter35.ncmp.7.not, label %.unr-lcssa, label %25, !llvm.loop !11

.unr-lcssa:                                       ; preds = %25, %.preheader
  %lcmp.mod31.not = icmp eq i16 %xtraiter30, 0
  br i1 %lcmp.mod31.not, label %.epilog-lcssa, label %.epil.preheader

.epil.preheader:                                  ; preds = %.unr-lcssa, %.epil.preheader
  %.sroa.8.1.epil = phi i8 [ %.sroa.0.1.epil, %.epil.preheader ], [ %.sroa.8.0.le, %.unr-lcssa ]
  %.sroa.0.1.epil = phi i8 [ %.sroa.8.1.epil, %.epil.preheader ], [ %.sroa.0.0.lcssa, %.unr-lcssa ]
  %epil.iter = phi i16 [ %epil.iter.next, %.epil.preheader ], [ 0, %.unr-lcssa ]
  %epil.iter.next = add i16 %epil.iter, 1
  %epil.iter.cmp.not = icmp eq i16 %epil.iter.next, %xtraiter30
  br i1 %epil.iter.cmp.not, label %.epilog-lcssa, label %.epil.preheader, !llvm.loop !12

.epilog-lcssa:                                    ; preds = %.epil.preheader, %.unr-lcssa
  %.sroa.8.1.lcssa = phi i8 [ %.sroa.0.0.lcssa, %.unr-lcssa ], [ %.sroa.8.1.epil, %.epil.preheader ]
  %.sroa.0.1.lcssa = phi i8 [ %.sroa.8.0.le, %.unr-lcssa ], [ %.sroa.0.1.epil, %.epil.preheader ]
  %.sroa.8.0.insert.ext = zext i8 %.sroa.8.1.lcssa to i16
  %.sroa.8.0.insert.shift = shl nuw i16 %.sroa.8.0.insert.ext, 8
  %.sroa.0.0.insert.ext = zext i8 %.sroa.0.1.lcssa to i16
  %.sroa.0.0.insert.insert = add nuw nsw i16 %.sroa.0.0.insert.ext, -21198
  %26 = add i16 %.sroa.0.0.insert.insert, %.sroa.8.0.insert.shift
  store i16 %26, ptr %1, align 2, !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 = !{!"short", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.unroll.disable"}


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