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

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

25:                                               ; preds = %17
  store i16 0, ptr %6, align 2, !tbaa !9
  br label %26

26:                                               ; preds = %78, %25
  %27 = load i16, ptr %6, align 2, !tbaa !9
  %28 = zext i16 %27 to i32
  %29 = load ptr, ptr %3, align 8, !tbaa !5
  %30 = getelementptr inbounds i16, ptr %29, i64 1
  %31 = load i16, ptr %30, align 2, !tbaa !9
  %32 = zext i16 %31 to i32
  %33 = icmp slt i32 %28, %32
  br i1 %33, label %34, label %81

34:                                               ; preds = %26
  %35 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %36 = load i16, ptr %35, align 2, !tbaa !9
  %37 = zext i16 %36 to i32
  %38 = load i16, ptr %6, align 2, !tbaa !9
  %39 = zext i16 %38 to i32
  %40 = load i16, ptr %7, align 2, !tbaa !9
  %41 = zext i16 %40 to i32
  %42 = add nsw i32 %39, %41
  %43 = icmp slt i32 %37, %42
  br i1 %43, label %44, label %56

44:                                               ; preds = %34
  %45 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %46 = getelementptr inbounds i8, ptr %45, i64 1
  %47 = load i8, ptr %46, align 1, !tbaa !11
  store i8 %47, ptr %8, align 1, !tbaa !11
  %48 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %49 = getelementptr inbounds i8, ptr %48, i64 0
  %50 = load i8, ptr %49, align 1, !tbaa !11
  %51 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %52 = getelementptr inbounds i8, ptr %51, i64 1
  store i8 %50, ptr %52, align 1, !tbaa !11
  %53 = load i8, ptr %8, align 1, !tbaa !11
  %54 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %55 = getelementptr inbounds i8, ptr %54, i64 0
  store i8 %53, ptr %55, align 1, !tbaa !11
  br label %78

56:                                               ; preds = %34
  %57 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %58 = load i16, ptr %57, align 2, !tbaa !9
  %59 = zext i16 %58 to i32
  %60 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %61 = load i16, ptr %60, align 2, !tbaa !9
  %62 = zext i16 %61 to i32
  %63 = add nsw i32 %62, %59
  %64 = trunc i32 %63 to i16
  store i16 %64, ptr %60, align 2, !tbaa !9
  %65 = load i16, ptr %7, align 2, !tbaa !9
  %66 = zext i16 %65 to i64
  %67 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %66
  %68 = load i16, ptr %67, align 2, !tbaa !9
  %69 = zext i16 %68 to i32
  %70 = load i16, ptr %6, align 2, !tbaa !9
  %71 = zext i16 %70 to i64
  %72 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 %71
  %73 = load i16, ptr %72, align 2, !tbaa !9
  %74 = zext i16 %73 to i32
  %75 = add nsw i32 %69, %74
  %76 = trunc i32 %75 to i16
  %77 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  store i16 %76, ptr %77, align 2, !tbaa !9
  br label %78

78:                                               ; preds = %56, %44
  %79 = load i16, ptr %6, align 2, !tbaa !9
  %80 = add i16 %79, 1
  store i16 %80, ptr %6, align 2, !tbaa !9
  br label %26, !llvm.loop !12

81:                                               ; preds = %26
  %82 = load i16, ptr %7, align 2, !tbaa !9
  %83 = add i16 %82, 1
  store i16 %83, ptr %7, align 2, !tbaa !9
  br label %17, !llvm.loop !14

84:                                               ; preds = %17
  %85 = getelementptr inbounds [1 x i16], ptr %5, i64 0, i64 0
  %86 = load i16, ptr %85, align 2, !tbaa !9
  %87 = zext i16 %86 to i64
  %88 = sub i64 %87, 505297367
  %89 = trunc i64 %88 to i16
  %90 = load ptr, ptr %4, align 8, !tbaa !5
  %91 = getelementptr inbounds i16, ptr %90, i64 0
  store i16 %89, ptr %91, align 2, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 2, 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}


; 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, -2637
  %.sroa.0.0.extract.trunc = trunc i16 %4 to i8
  %.sroa.8.0.extract.shift = lshr i16 %4, 8
  %.sroa.8.0.extract.trunc = trunc nuw i16 %.sroa.8.0.extract.shift to i8
  %5 = getelementptr inbounds i8, ptr %0, i64 2
  %6 = load i16, ptr %5, align 2, !tbaa !5
  %.not = icmp eq i16 %6, 0
  br i1 %.not, label %._crit_edge, label %.preheader.preheader

.preheader.preheader:                             ; preds = %2
  %wide.trip.count38 = zext i16 %6 to i32
  %xtraiter = and i32 %wide.trip.count38, 1
  %7 = icmp eq i16 %6, 1
  %unroll_iter = and i32 %wide.trip.count38, 65534
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br label %.preheader

.preheader:                                       ; preds = %.preheader.preheader, %20
  %indvars.iv36 = phi i32 [ 0, %.preheader.preheader ], [ %indvars.iv.next37, %20 ]
  %.sroa.0.033 = phi i8 [ %.sroa.0.0.extract.trunc, %.preheader.preheader ], [ %.sroa.0.2.lcssa, %20 ]
  %.sroa.8.032 = phi i8 [ %.sroa.8.0.extract.trunc, %.preheader.preheader ], [ %.sroa.8.2.lcssa, %20 ]
  br i1 %7, label %.unr-lcssa, label %.preheader.new

.preheader.new:                                   ; preds = %.preheader, %.preheader.new
  %indvars.iv = phi i32 [ %indvars.iv.next.1, %.preheader.new ], [ 0, %.preheader ]
  %.sroa.0.130 = phi i8 [ %.sroa.0.2.1, %.preheader.new ], [ %.sroa.0.033, %.preheader ]
  %.sroa.8.129 = phi i8 [ %.sroa.8.2.1, %.preheader.new ], [ %.sroa.8.032, %.preheader ]
  %niter = phi i32 [ %niter.next.1, %.preheader.new ], [ 0, %.preheader ]
  %.sroa.8.0.insert.ext = zext i8 %.sroa.8.129 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.130 to i16
  %.sroa.0.0.insert.insert = or disjoint i16 %.sroa.8.0.insert.shift, %.sroa.0.0.insert.ext
  %8 = zext i16 %.sroa.0.0.insert.insert to i32
  %9 = add nuw nsw i32 %indvars.iv36, %indvars.iv
  %10 = icmp ugt i32 %9, %8
  %11 = shl i16 %.sroa.0.0.insert.insert, 2
  %.sroa.0.0.extract.trunc17 = trunc i16 %11 to i8
  %.sroa.8.0.extract.shift22 = lshr i16 %11, 8
  %.sroa.8.0.extract.trunc23 = trunc nuw i16 %.sroa.8.0.extract.shift22 to i8
  %.sroa.8.2 = select i1 %10, i8 %.sroa.0.130, i8 %.sroa.8.0.extract.trunc23
  %.sroa.0.2 = select i1 %10, i8 %.sroa.8.129, i8 %.sroa.0.0.extract.trunc17
  %indvars.iv.next = or disjoint i32 %indvars.iv, 1
  %.sroa.8.0.insert.ext.1 = zext i8 %.sroa.8.2 to i16
  %.sroa.8.0.insert.shift.1 = shl nuw i16 %.sroa.8.0.insert.ext.1, 8
  %.sroa.0.0.insert.ext.1 = zext i8 %.sroa.0.2 to i16
  %.sroa.0.0.insert.insert.1 = or disjoint i16 %.sroa.8.0.insert.shift.1, %.sroa.0.0.insert.ext.1
  %12 = zext i16 %.sroa.0.0.insert.insert.1 to i32
  %13 = add nuw nsw i32 %indvars.iv36, %indvars.iv.next
  %14 = icmp ugt i32 %13, %12
  %15 = shl i16 %.sroa.0.0.insert.insert.1, 2
  %.sroa.0.0.extract.trunc17.1 = trunc i16 %15 to i8
  %.sroa.8.0.extract.shift22.1 = lshr i16 %15, 8
  %.sroa.8.0.extract.trunc23.1 = trunc nuw i16 %.sroa.8.0.extract.shift22.1 to i8
  %.sroa.8.2.1 = select i1 %14, i8 %.sroa.0.2, i8 %.sroa.8.0.extract.trunc23.1
  %.sroa.0.2.1 = select i1 %14, i8 %.sroa.8.2, i8 %.sroa.0.0.extract.trunc17.1
  %indvars.iv.next.1 = add nuw nsw i32 %indvars.iv, 2
  %niter.next.1 = add i32 %niter, 2
  %niter.ncmp.1 = icmp eq i32 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %.unr-lcssa, label %.preheader.new, !llvm.loop !9

.unr-lcssa:                                       ; preds = %.preheader.new, %.preheader
  %.sroa.8.2.lcssa.ph = phi i8 [ poison, %.preheader ], [ %.sroa.8.2.1, %.preheader.new ]
  %.sroa.0.2.lcssa.ph = phi i8 [ poison, %.preheader ], [ %.sroa.0.2.1, %.preheader.new ]
  %indvars.iv.unr = phi i32 [ 0, %.preheader ], [ %indvars.iv.next.1, %.preheader.new ]
  %.sroa.0.130.unr = phi i8 [ %.sroa.0.033, %.preheader ], [ %.sroa.0.2.1, %.preheader.new ]
  %.sroa.8.129.unr = phi i8 [ %.sroa.8.032, %.preheader ], [ %.sroa.8.2.1, %.preheader.new ]
  br i1 %lcmp.mod.not, label %20, label %.epilog-lcssa

.epilog-lcssa:                                    ; preds = %.unr-lcssa
  %.sroa.8.0.insert.ext.epil = zext i8 %.sroa.8.129.unr to i16
  %.sroa.8.0.insert.shift.epil = shl nuw i16 %.sroa.8.0.insert.ext.epil, 8
  %.sroa.0.0.insert.ext.epil = zext i8 %.sroa.0.130.unr to i16
  %.sroa.0.0.insert.insert.epil = or disjoint i16 %.sroa.8.0.insert.shift.epil, %.sroa.0.0.insert.ext.epil
  %16 = zext i16 %.sroa.0.0.insert.insert.epil to i32
  %17 = add nuw nsw i32 %indvars.iv36, %indvars.iv.unr
  %18 = icmp ugt i32 %17, %16
  %19 = shl i16 %.sroa.0.0.insert.insert.epil, 2
  %.sroa.0.0.extract.trunc17.epil = trunc i16 %19 to i8
  %.sroa.8.0.extract.shift22.epil = lshr i16 %19, 8
  %.sroa.8.0.extract.trunc23.epil = trunc nuw i16 %.sroa.8.0.extract.shift22.epil to i8
  %.sroa.8.2.epil = select i1 %18, i8 %.sroa.0.130.unr, i8 %.sroa.8.0.extract.trunc23.epil
  %.sroa.0.2.epil = select i1 %18, i8 %.sroa.8.129.unr, i8 %.sroa.0.0.extract.trunc17.epil
  br label %20

20:                                               ; preds = %.unr-lcssa, %.epilog-lcssa
  %.sroa.8.2.lcssa = phi i8 [ %.sroa.8.2.lcssa.ph, %.unr-lcssa ], [ %.sroa.8.2.epil, %.epilog-lcssa ]
  %.sroa.0.2.lcssa = phi i8 [ %.sroa.0.2.lcssa.ph, %.unr-lcssa ], [ %.sroa.0.2.epil, %.epilog-lcssa ]
  %indvars.iv.next37 = add nuw nsw i32 %indvars.iv36, 1
  %exitcond39.not = icmp eq i32 %indvars.iv.next37, %wide.trip.count38
  br i1 %exitcond39.not, label %._crit_edge, label %.preheader, !llvm.loop !11

._crit_edge:                                      ; preds = %20, %2
  %.sroa.8.0.lcssa = phi i8 [ %.sroa.8.0.extract.trunc, %2 ], [ %.sroa.8.2.lcssa, %20 ]
  %.sroa.0.0.lcssa = phi i8 [ %.sroa.0.0.extract.trunc, %2 ], [ %.sroa.0.2.lcssa, %20 ]
  %.sroa.8.0.insert.ext25 = zext i8 %.sroa.8.0.lcssa to i16
  %.sroa.8.0.insert.shift26 = shl nuw i16 %.sroa.8.0.insert.ext25, 8
  %.sroa.0.0.insert.ext19 = zext i8 %.sroa.0.0.lcssa to i16
  %.sroa.0.0.insert.insert21 = add nuw nsw i16 %.sroa.0.0.insert.ext19, -14807
  %21 = add i16 %.sroa.0.0.insert.insert21, %.sroa.8.0.insert.shift26
  store i16 %21, 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}


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