; 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, 51238316
  %13 = add i64 %12, 274866410
  %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 = %65, %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 %70

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

27:                                               ; preds = %22
  %28 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %29 = load i32, ptr %28, align 4, !tbaa !9
  %30 = load i32, ptr %6, align 4, !tbaa !9
  %31 = icmp eq i32 %29, %30
  br i1 %31, label %32, label %41

32:                                               ; preds = %27
  %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 = load i32, ptr %35, align 4, !tbaa !9
  %37 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %38 = load i32, ptr %37, align 4, !tbaa !9
  %39 = add i32 %36, %38
  %40 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  store i32 %39, ptr %40, align 4, !tbaa !9
  br label %53

41:                                               ; preds = %27
  %42 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %43 = getelementptr inbounds i16, ptr %42, i64 0
  %44 = load i16, ptr %43, align 2, !tbaa !11
  store i16 %44, ptr %7, align 2, !tbaa !11
  %45 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %46 = getelementptr inbounds i16, ptr %45, i64 1
  %47 = load i16, ptr %46, align 2, !tbaa !11
  %48 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %49 = getelementptr inbounds i16, ptr %48, i64 0
  store i16 %47, ptr %49, align 2, !tbaa !11
  %50 = load i16, ptr %7, align 2, !tbaa !11
  %51 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %52 = getelementptr inbounds i16, ptr %51, i64 1
  store i16 %50, ptr %52, align 2, !tbaa !11
  br label %53

53:                                               ; preds = %41, %32
  br label %65

54:                                               ; preds = %22
  %55 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %56 = load i32, ptr %55, align 4, !tbaa !9
  %57 = load i32, ptr %6, align 4, !tbaa !9
  %58 = zext i32 %57 to i64
  %59 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %58
  %60 = load i32, ptr %59, align 4, !tbaa !9
  %61 = add i32 %56, %60
  %62 = load i32, ptr %6, align 4, !tbaa !9
  %63 = zext i32 %62 to i64
  %64 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %63
  store i32 %61, ptr %64, align 4, !tbaa !9
  br label %65

65:                                               ; preds = %54, %53
  %66 = load i32, ptr %6, align 4, !tbaa !9
  %67 = zext i32 %66 to i64
  %68 = add i64 %67, 2
  %69 = trunc i64 %68 to i32
  store i32 %69, ptr %6, align 4, !tbaa !9
  br label %16, !llvm.loop !13

70:                                               ; preds = %16
  %71 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %72 = load i32, ptr %71, align 4, !tbaa !9
  %73 = zext i32 %72 to i64
  %74 = add i64 %73, 943156777
  %75 = sub i64 %74, 1416170301
  %76 = trunc i64 %75 to i32
  %77 = load ptr, ptr %4, align 8, !tbaa !5
  %78 = getelementptr inbounds i32, ptr %77, i64 0
  store i32 %76, ptr %78, 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"}


; 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 = add i32 %3, 326104726
  %.sroa.0.0.extract.trunc = trunc i32 %4 to i16
  %.sroa.9.0.extract.shift = lshr i32 %4, 16
  %.sroa.9.0.extract.trunc = trunc nuw i32 %.sroa.9.0.extract.shift to i16
  %5 = getelementptr inbounds i8, ptr %0, i64 4
  %6 = load i32, ptr %5, align 4, !tbaa !5
  %.not = icmp eq i32 %6, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

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

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

.lr.ph:                                           ; preds = %.lr.ph, %.lr.ph.preheader.new
  %.035 = phi i32 [ 0, %.lr.ph.preheader.new ], [ %16, %.lr.ph ]
  %.sroa.0.034 = phi i16 [ %.sroa.0.0.extract.trunc, %.lr.ph.preheader.new ], [ %.sroa.0.1.1, %.lr.ph ]
  %.sroa.9.033 = phi i16 [ %.sroa.9.0.extract.trunc, %.lr.ph.preheader.new ], [ %.sroa.9.1.1, %.lr.ph ]
  %niter = phi i32 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %.lr.ph ]
  %.sroa.9.0.insert.ext = zext i16 %.sroa.9.033 to i32
  %.sroa.9.0.insert.shift = shl nuw i32 %.sroa.9.0.insert.ext, 16
  %.sroa.0.0.insert.ext = zext i16 %.sroa.0.034 to i32
  %.sroa.0.0.insert.insert = or disjoint i32 %.sroa.9.0.insert.shift, %.sroa.0.0.insert.ext
  %11 = icmp ult i32 %.sroa.0.0.insert.insert, %.035
  %12 = shl i32 %.sroa.0.0.insert.insert, 1
  %.sroa.0.0.extract.trunc20 = trunc i32 %12 to i16
  %.sroa.9.0.extract.shift31 = lshr i32 %12, 16
  %.sroa.9.0.extract.trunc32 = trunc nuw i32 %.sroa.9.0.extract.shift31 to i16
  %.sroa.9.1 = select i1 %11, i16 %.sroa.0.034, i16 %.sroa.9.0.extract.trunc32
  %.sroa.0.1 = select i1 %11, i16 %.sroa.9.033, i16 %.sroa.0.0.extract.trunc20
  %13 = or disjoint i32 %.035, 2
  %.sroa.9.0.insert.ext.1 = zext i16 %.sroa.9.1 to i32
  %.sroa.9.0.insert.shift.1 = shl nuw i32 %.sroa.9.0.insert.ext.1, 16
  %.sroa.0.0.insert.ext.1 = zext i16 %.sroa.0.1 to i32
  %.sroa.0.0.insert.insert.1 = or disjoint i32 %.sroa.9.0.insert.shift.1, %.sroa.0.0.insert.ext.1
  %14 = icmp ult i32 %.sroa.0.0.insert.insert.1, %13
  %15 = shl i32 %.sroa.0.0.insert.insert.1, 1
  %.sroa.0.0.extract.trunc20.1 = trunc i32 %15 to i16
  %.sroa.9.0.extract.shift31.1 = lshr i32 %15, 16
  %.sroa.9.0.extract.trunc32.1 = trunc nuw i32 %.sroa.9.0.extract.shift31.1 to i16
  %.sroa.9.1.1 = select i1 %14, i16 %.sroa.0.1, i16 %.sroa.9.0.extract.trunc32.1
  %.sroa.0.1.1 = select i1 %14, i16 %.sroa.9.1, i16 %.sroa.0.0.extract.trunc20.1
  %16 = add nuw i32 %.035, 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
  %.sroa.9.1.lcssa.ph = phi i16 [ poison, %.lr.ph.preheader ], [ %.sroa.9.1.1, %.lr.ph ]
  %.sroa.0.1.lcssa.ph = phi i16 [ poison, %.lr.ph.preheader ], [ %.sroa.0.1.1, %.lr.ph ]
  %.035.unr = phi i32 [ 0, %.lr.ph.preheader ], [ %16, %.lr.ph ]
  %.sroa.0.034.unr = phi i16 [ %.sroa.0.0.extract.trunc, %.lr.ph.preheader ], [ %.sroa.0.1.1, %.lr.ph ]
  %.sroa.9.033.unr = phi i16 [ %.sroa.9.0.extract.trunc, %.lr.ph.preheader ], [ %.sroa.9.1.1, %.lr.ph ]
  %17 = and i32 %7, 2
  %lcmp.mod.not.not = icmp eq i32 %17, 0
  br i1 %lcmp.mod.not.not, label %.lr.ph.epil, label %._crit_edge

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %.sroa.9.0.insert.ext.epil = zext i16 %.sroa.9.033.unr to i32
  %.sroa.9.0.insert.shift.epil = shl nuw i32 %.sroa.9.0.insert.ext.epil, 16
  %.sroa.0.0.insert.ext.epil = zext i16 %.sroa.0.034.unr to i32
  %.sroa.0.0.insert.insert.epil = or disjoint i32 %.sroa.9.0.insert.shift.epil, %.sroa.0.0.insert.ext.epil
  %18 = icmp ult i32 %.sroa.0.0.insert.insert.epil, %.035.unr
  %19 = shl i32 %.sroa.0.0.insert.insert.epil, 1
  %.sroa.0.0.extract.trunc20.epil = trunc i32 %19 to i16
  %.sroa.9.0.extract.shift31.epil = lshr i32 %19, 16
  %.sroa.9.0.extract.trunc32.epil = trunc nuw i32 %.sroa.9.0.extract.shift31.epil to i16
  %.sroa.9.1.epil = select i1 %18, i16 %.sroa.0.034.unr, i16 %.sroa.9.0.extract.trunc32.epil
  %.sroa.0.1.epil = select i1 %18, i16 %.sroa.9.033.unr, i16 %.sroa.0.0.extract.trunc20.epil
  br label %._crit_edge

._crit_edge:                                      ; preds = %.lr.ph.epil, %._crit_edge.loopexit.unr-lcssa, %2
  %.sroa.9.0.lcssa = phi i16 [ %.sroa.9.0.extract.trunc, %2 ], [ %.sroa.9.1.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.sroa.9.1.epil, %.lr.ph.epil ]
  %.sroa.0.0.lcssa = phi i16 [ %.sroa.0.0.extract.trunc, %2 ], [ %.sroa.0.1.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %.sroa.0.1.epil, %.lr.ph.epil ]
  %.sroa.9.0.insert.ext22 = zext i16 %.sroa.9.0.lcssa to i32
  %.sroa.9.0.insert.shift23 = shl nuw i32 %.sroa.9.0.insert.ext22, 16
  %.sroa.0.0.insert.ext13 = zext i16 %.sroa.0.0.lcssa to i32
  %.sroa.0.0.insert.insert15 = add nuw nsw i32 %.sroa.0.0.insert.ext13, -473013524
  %20 = add i32 %.sroa.0.0.insert.insert15, %.sroa.9.0.insert.shift23
  store i32 %20, 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: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass