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

15:                                               ; preds = %62, %2
  %16 = load i64, ptr %7, align 8, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds i64, ptr %17, i64 1
  %19 = load i64, ptr %18, align 8, !tbaa !9
  %20 = icmp ult i64 %16, %19
  br i1 %20, label %21, label %65

21:                                               ; preds = %15
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %59, %21
  %23 = load i64, ptr %6, align 8, !tbaa !9
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds i64, ptr %24, i64 1
  %26 = load i64, ptr %25, align 8, !tbaa !9
  %27 = icmp ult i64 %23, %26
  br i1 %27, label %28, label %62

28:                                               ; preds = %22
  %29 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %30 = load i64, ptr %29, align 8, !tbaa !9
  %31 = load i64, ptr %6, align 8, !tbaa !9
  %32 = load i64, ptr %7, align 8, !tbaa !9
  %33 = and i64 %31, %32
  %34 = icmp ugt i64 %30, %33
  br i1 %34, label %35, label %47

35:                                               ; preds = %28
  %36 = load i64, ptr %6, align 8, !tbaa !9
  %37 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %36
  %38 = load i64, ptr %37, align 8, !tbaa !9
  %39 = load i64, ptr %6, align 8, !tbaa !9
  %40 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %39
  %41 = load i64, ptr %40, align 8, !tbaa !9
  %42 = and i64 %41, 7
  %43 = or i64 %42, 1
  %44 = lshr i64 %38, %43
  %45 = load i64, ptr %7, align 8, !tbaa !9
  %46 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %45
  store i64 %44, ptr %46, align 8, !tbaa !9
  br label %59

47:                                               ; preds = %28
  %48 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %49 = getelementptr inbounds i16, ptr %48, i64 3
  %50 = load i16, ptr %49, align 2, !tbaa !11
  store i16 %50, ptr %8, align 2, !tbaa !11
  %51 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %52 = getelementptr inbounds i16, ptr %51, i64 1
  %53 = load i16, ptr %52, align 2, !tbaa !11
  %54 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %55 = getelementptr inbounds i16, ptr %54, i64 3
  store i16 %53, ptr %55, align 2, !tbaa !11
  %56 = load i16, ptr %8, align 2, !tbaa !11
  %57 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %58 = getelementptr inbounds i16, ptr %57, i64 1
  store i16 %56, ptr %58, align 2, !tbaa !11
  br label %59

59:                                               ; preds = %47, %35
  %60 = load i64, ptr %6, align 8, !tbaa !9
  %61 = add i64 %60, 2
  store i64 %61, ptr %6, align 8, !tbaa !9
  br label %22, !llvm.loop !13

62:                                               ; preds = %22
  %63 = load i64, ptr %7, align 8, !tbaa !9
  %64 = add i64 %63, 2
  store i64 %64, ptr %7, align 8, !tbaa !9
  br label %15, !llvm.loop !15

65:                                               ; preds = %15
  %66 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %67 = load i64, ptr %66, align 8, !tbaa !9
  %68 = shl i64 %67, 1
  %69 = xor i64 %68, 7701025
  %70 = load ptr, ptr %4, align 8, !tbaa !5
  %71 = getelementptr inbounds i64, ptr %70, i64 0
  store i64 %69, ptr %71, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, 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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"short", !7, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 i64, ptr %0, align 8, !tbaa !5
  %4 = lshr i64 %3, 3
  %5 = or i64 %4, 6404789
  %.sroa.0.0.extract.trunc = trunc i64 %5 to i16
  %.sroa.7.0.extract.shift = lshr i64 %5, 16
  %.sroa.7.0.extract.trunc = trunc i64 %.sroa.7.0.extract.shift to i16
  %.sroa.9.0.extract.shift = lshr i64 %3, 35
  %.sroa.9.0.extract.trunc = trunc i64 %.sroa.9.0.extract.shift to i16
  %.sroa.947.0.extract.shift = lshr i64 %3, 51
  %.sroa.947.0.extract.trunc = trunc nuw nsw i64 %.sroa.947.0.extract.shift to i16
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %._crit_edge, label %.preheader

.preheader:                                       ; preds = %2, %18
  %.01369 = phi i64 [ %19, %18 ], [ 0, %2 ]
  %.sroa.0.068 = phi i16 [ %.sroa.0.2, %18 ], [ %.sroa.0.0.extract.trunc, %2 ]
  %.sroa.7.067 = phi i16 [ %.sroa.7.2, %18 ], [ %.sroa.7.0.extract.trunc, %2 ]
  %.sroa.9.066 = phi i16 [ %.sroa.9.2, %18 ], [ %.sroa.9.0.extract.trunc, %2 ]
  %.sroa.947.065 = phi i16 [ %.sroa.947.2, %18 ], [ %.sroa.947.0.extract.trunc, %2 ]
  br label %8

8:                                                ; preds = %.preheader, %15
  %.064 = phi i64 [ 0, %.preheader ], [ %16, %15 ]
  %.sroa.0.163 = phi i16 [ %.sroa.0.068, %.preheader ], [ %.sroa.0.2, %15 ]
  %.sroa.7.162 = phi i16 [ %.sroa.7.067, %.preheader ], [ %.sroa.7.2, %15 ]
  %.sroa.9.161 = phi i16 [ %.sroa.9.066, %.preheader ], [ %.sroa.9.2, %15 ]
  %.sroa.947.160 = phi i16 [ %.sroa.947.065, %.preheader ], [ %.sroa.947.2, %15 ]
  %.sroa.947.0.insert.ext = zext i16 %.sroa.947.160 to i64
  %.sroa.947.0.insert.shift = shl nuw i64 %.sroa.947.0.insert.ext, 48
  %.sroa.9.0.insert.ext = zext i16 %.sroa.9.161 to i64
  %.sroa.9.0.insert.shift = shl nuw nsw i64 %.sroa.9.0.insert.ext, 32
  %.sroa.9.0.insert.insert = or disjoint i64 %.sroa.9.0.insert.shift, %.sroa.947.0.insert.shift
  %.sroa.7.0.insert.ext = zext i16 %.sroa.7.162 to i64
  %.sroa.7.0.insert.shift = shl nuw nsw i64 %.sroa.7.0.insert.ext, 16
  %.sroa.7.0.insert.insert = or disjoint i64 %.sroa.9.0.insert.insert, %.sroa.7.0.insert.shift
  %.sroa.0.0.insert.ext = zext i16 %.sroa.0.163 to i64
  %.sroa.0.0.insert.insert = or disjoint i64 %.sroa.7.0.insert.insert, %.sroa.0.0.insert.ext
  %9 = and i64 %.064, %.01369
  %10 = icmp ugt i64 %.sroa.0.0.insert.insert, %9
  br i1 %10, label %11, label %15

11:                                               ; preds = %8
  %12 = and i64 %.sroa.0.0.insert.ext, 6
  %13 = or disjoint i64 %12, 1
  %14 = lshr i64 %.sroa.0.0.insert.insert, %13
  %.sroa.0.0.extract.trunc22 = trunc i64 %14 to i16
  %.sroa.7.0.extract.shift33 = lshr i64 %14, 16
  %.sroa.7.0.extract.trunc34 = trunc i64 %.sroa.7.0.extract.shift33 to i16
  %.sroa.9.0.extract.shift45 = lshr i64 %14, 32
  %.sroa.9.0.extract.trunc46 = trunc i64 %.sroa.9.0.extract.shift45 to i16
  %.sroa.947.0.extract.shift58 = lshr i64 %14, 48
  %.sroa.947.0.extract.trunc59 = trunc nuw nsw i64 %.sroa.947.0.extract.shift58 to i16
  br label %15

15:                                               ; preds = %8, %11
  %.sroa.947.2 = phi i16 [ %.sroa.947.0.extract.trunc59, %11 ], [ %.sroa.7.162, %8 ]
  %.sroa.9.2 = phi i16 [ %.sroa.9.0.extract.trunc46, %11 ], [ %.sroa.9.161, %8 ]
  %.sroa.7.2 = phi i16 [ %.sroa.7.0.extract.trunc34, %11 ], [ %.sroa.947.160, %8 ]
  %.sroa.0.2 = phi i16 [ %.sroa.0.0.extract.trunc22, %11 ], [ %.sroa.0.163, %8 ]
  %16 = add nuw i64 %.064, 2
  %17 = icmp ult i64 %16, %7
  br i1 %17, label %8, label %18, !llvm.loop !9

18:                                               ; preds = %15
  %19 = add nuw i64 %.01369, 2
  %20 = icmp ult i64 %19, %7
  br i1 %20, label %.preheader, label %._crit_edge, !llvm.loop !11

._crit_edge:                                      ; preds = %18, %2
  %.sroa.947.0.lcssa = phi i16 [ %.sroa.947.0.extract.trunc, %2 ], [ %.sroa.947.2, %18 ]
  %.sroa.9.0.lcssa = phi i16 [ %.sroa.9.0.extract.trunc, %2 ], [ %.sroa.9.2, %18 ]
  %.sroa.7.0.lcssa = phi i16 [ %.sroa.7.0.extract.trunc, %2 ], [ %.sroa.7.2, %18 ]
  %.sroa.0.0.lcssa = phi i16 [ %.sroa.0.0.extract.trunc, %2 ], [ %.sroa.0.2, %18 ]
  %.sroa.947.0.insert.ext49 = zext i16 %.sroa.947.0.lcssa to i64
  %.sroa.947.0.insert.shift50 = shl nuw i64 %.sroa.947.0.insert.ext49, 48
  %.sroa.9.0.insert.ext36 = zext i16 %.sroa.9.0.lcssa to i64
  %.sroa.9.0.insert.shift37 = shl nuw nsw i64 %.sroa.9.0.insert.ext36, 32
  %.sroa.9.0.insert.insert39 = or disjoint i64 %.sroa.9.0.insert.shift37, %.sroa.947.0.insert.shift50
  %.sroa.7.0.insert.ext24 = zext i16 %.sroa.7.0.lcssa to i64
  %.sroa.7.0.insert.shift25 = shl nuw nsw i64 %.sroa.7.0.insert.ext24, 16
  %.sroa.7.0.insert.insert27 = or disjoint i64 %.sroa.9.0.insert.insert39, %.sroa.7.0.insert.shift25
  %.sroa.0.0.insert.ext15 = zext i16 %.sroa.0.0.lcssa to i64
  %.sroa.0.0.insert.insert17 = or disjoint i64 %.sroa.7.0.insert.insert27, %.sroa.0.0.insert.ext15
  %21 = shl i64 %.sroa.0.0.insert.insert17, 1
  %22 = xor i64 %21, 7701025
  store i64 %22, ptr %1, align 8, !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 = !{!"long", !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,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass