; 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 = sub i64 %12, 981234615
  %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 = %64, %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 %67

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 %53

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 ne i32 %29, %30
  br i1 %31, label %32, label %52

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 = getelementptr inbounds i16, ptr %35, i64 0
  %37 = load i16, ptr %36, align 2, !tbaa !11
  store i16 %37, 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 1
  %42 = load i16, ptr %41, align 2, !tbaa !11
  %43 = load i32, ptr %6, align 4, !tbaa !9
  %44 = zext i32 %43 to i64
  %45 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %44
  %46 = getelementptr inbounds i16, ptr %45, i64 0
  store i16 %42, ptr %46, align 2, !tbaa !11
  %47 = load i16, ptr %7, align 2, !tbaa !11
  %48 = load i32, ptr %6, align 4, !tbaa !9
  %49 = zext i32 %48 to i64
  %50 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 %49
  %51 = getelementptr inbounds i16, ptr %50, i64 1
  store i16 %47, ptr %51, align 2, !tbaa !11
  br label %52

52:                                               ; preds = %32, %27
  br label %64

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

64:                                               ; preds = %53, %52
  %65 = load i32, ptr %6, align 4, !tbaa !9
  %66 = add i32 %65, 1
  store i32 %66, ptr %6, align 4, !tbaa !9
  br label %16, !llvm.loop !13

67:                                               ; preds = %16
  %68 = getelementptr inbounds [1 x i32], ptr %5, i64 0, i64 0
  %69 = load i32, ptr %68, align 4, !tbaa !9
  %70 = zext i32 %69 to i64
  %71 = add i64 %70, 973391845
  %72 = add i64 %71, 40566171
  %73 = trunc i64 %72 to i32
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds i32, ptr %74, i64 0
  store i32 %73, ptr %75, 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 = 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 = add i32 %4, -66456141
  store i32 %5, ptr %3, align 4, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 4
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %invariant.gep = getelementptr inbounds i8, ptr %3, i64 2
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %2
  %wide.trip.count = zext i32 %7 to i64
  %xtraiter = and i64 %wide.trip.count, 1
  %8 = icmp eq i32 %7, 1
  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, 4294967294
  br label %.lr.ph

.lr.ph:                                           ; preds = %24, %.lr.ph.preheader.new
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader.new ], [ %indvars.iv.next.1, %24 ]
  %niter = phi i64 [ 0, %.lr.ph.preheader.new ], [ %niter.next.1, %24 ]
  %9 = load i32, ptr %3, align 4
  %10 = zext i32 %9 to i64
  %11 = icmp ugt i64 %indvars.iv, %10
  br i1 %11, label %12, label %15

12:                                               ; preds = %.lr.ph
  %13 = trunc i32 %9 to i16
  %gep = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv
  %14 = load i16, ptr %gep, align 2, !tbaa !9
  store i16 %14, ptr %3, align 4, !tbaa !9
  store i16 %13, ptr %gep, align 2, !tbaa !9
  br label %.lr.ph.1

15:                                               ; preds = %.lr.ph
  %16 = shl i32 %9, 1
  store i32 %16, ptr %3, align 4, !tbaa !5
  br label %.lr.ph.1

.lr.ph.1:                                         ; preds = %12, %15
  %17 = load i32, ptr %3, align 4
  %18 = zext i32 %17 to i64
  %.not15 = icmp ult i64 %indvars.iv, %18
  br i1 %.not15, label %19, label %21

19:                                               ; preds = %.lr.ph.1
  %20 = shl i32 %17, 1
  store i32 %20, ptr %3, align 4, !tbaa !5
  br label %24

21:                                               ; preds = %.lr.ph.1
  %indvars.iv.next = or disjoint i64 %indvars.iv, 1
  %22 = trunc i32 %17 to i16
  %gep.1 = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv.next
  %23 = load i16, ptr %gep.1, align 2, !tbaa !9
  store i16 %23, ptr %3, align 4, !tbaa !9
  store i16 %22, ptr %gep.1, align 2, !tbaa !9
  br label %24

24:                                               ; preds = %21, %19
  %indvars.iv.next.1 = add nuw nsw i64 %indvars.iv, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph, !llvm.loop !11

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

.lr.ph.epil:                                      ; preds = %._crit_edge.loopexit.unr-lcssa
  %25 = load i32, ptr %3, align 4
  %26 = zext i32 %25 to i64
  %27 = icmp ugt i64 %indvars.iv.unr, %26
  br i1 %27, label %30, label %28

28:                                               ; preds = %.lr.ph.epil
  %29 = shl i32 %25, 1
  store i32 %29, ptr %3, align 4, !tbaa !5
  br label %._crit_edge.loopexit

30:                                               ; preds = %.lr.ph.epil
  %31 = trunc i32 %25 to i16
  %gep.epil = getelementptr inbounds [1 x i32], ptr %invariant.gep, i64 0, i64 %indvars.iv.unr
  %32 = load i16, ptr %gep.epil, align 2, !tbaa !9
  store i16 %32, ptr %3, align 4, !tbaa !9
  store i16 %31, ptr %gep.epil, align 2, !tbaa !9
  br label %._crit_edge.loopexit

._crit_edge.loopexit:                             ; preds = %28, %30, %._crit_edge.loopexit.unr-lcssa
  %.pre = load i32, ptr %3, align 4, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %2
  %33 = phi i32 [ %.pre, %._crit_edge.loopexit ], [ %5, %2 ]
  %34 = add i32 %33, 1013958016
  store i32 %34, 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.mustprogress"}


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