; 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 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 2, ptr %7) #2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds i64, ptr %8, i64 0
  %10 = load i64, ptr %9, align 8, !tbaa !9
  %11 = sub i64 %10, 51238316
  %12 = sub i64 %11, 339126204
  %13 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  store i64 %12, ptr %13, align 8, !tbaa !9
  store i64 0, ptr %6, align 8, !tbaa !9
  br label %14

14:                                               ; preds = %82, %2
  %15 = load i64, ptr %6, align 8, !tbaa !9
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = getelementptr inbounds i64, ptr %16, i64 1
  %18 = load i64, ptr %17, align 8, !tbaa !9
  %19 = icmp ult i64 %15, %18
  br i1 %19, label %20, label %85

20:                                               ; preds = %14
  %21 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %22 = load i64, ptr %21, align 8, !tbaa !9
  %23 = load i64, ptr %6, align 8, !tbaa !9
  %24 = icmp ugt i64 %22, %23
  br i1 %24, label %25, label %51

25:                                               ; preds = %20
  %26 = load i64, ptr %6, align 8, !tbaa !9
  %27 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %26
  %28 = load i64, ptr %27, align 8, !tbaa !9
  %29 = load i64, ptr %6, align 8, !tbaa !9
  %30 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %29
  %31 = load i64, ptr %30, align 8, !tbaa !9
  %32 = and i64 %31, 15
  %33 = or i64 %32, 1
  %34 = lshr i64 %28, %33
  %35 = load i64, ptr %6, align 8, !tbaa !9
  %36 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %35
  %37 = load i64, ptr %36, align 8, !tbaa !9
  %38 = load i64, ptr %6, align 8, !tbaa !9
  %39 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %38
  %40 = load i64, ptr %39, align 8, !tbaa !9
  %41 = and i64 %40, 15
  %42 = or i64 %41, 1
  %43 = sub i64 64, %42
  %44 = shl i64 %37, %43
  %45 = or i64 %34, %44
  %46 = and i64 %45, 63
  %47 = shl i64 %46, 4
  %48 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %49 = load i64, ptr %48, align 8, !tbaa !9
  %50 = or i64 %49, %47
  store i64 %50, ptr %48, align 8, !tbaa !9
  br label %82

51:                                               ; preds = %20
  %52 = load i64, ptr %6, align 8, !tbaa !9
  %53 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %52
  %54 = getelementptr inbounds i16, ptr %53, i64 1
  %55 = load i16, ptr %54, align 2, !tbaa !11
  store i16 %55, ptr %7, align 2, !tbaa !11
  %56 = load i64, ptr %6, align 8, !tbaa !9
  %57 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %56
  %58 = getelementptr inbounds i16, ptr %57, i64 0
  %59 = load i16, ptr %58, align 2, !tbaa !11
  %60 = load i64, ptr %6, align 8, !tbaa !9
  %61 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %60
  %62 = getelementptr inbounds i16, ptr %61, i64 1
  store i16 %59, ptr %62, align 2, !tbaa !11
  %63 = load i16, ptr %7, align 2, !tbaa !11
  %64 = load i64, ptr %6, align 8, !tbaa !9
  %65 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %64
  %66 = getelementptr inbounds i16, ptr %65, i64 0
  store i16 %63, ptr %66, align 2, !tbaa !11
  %67 = load i64, ptr %6, align 8, !tbaa !9
  %68 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %67
  %69 = getelementptr inbounds i16, ptr %68, i64 0
  %70 = load i16, ptr %69, align 2, !tbaa !11
  store i16 %70, ptr %7, align 2, !tbaa !11
  %71 = load i64, ptr %6, align 8, !tbaa !9
  %72 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %71
  %73 = getelementptr inbounds i16, ptr %72, i64 2
  %74 = load i16, ptr %73, align 2, !tbaa !11
  %75 = load i64, ptr %6, align 8, !tbaa !9
  %76 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %75
  %77 = getelementptr inbounds i16, ptr %76, i64 0
  store i16 %74, ptr %77, align 2, !tbaa !11
  %78 = load i16, ptr %7, align 2, !tbaa !11
  %79 = load i64, ptr %6, align 8, !tbaa !9
  %80 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 %79
  %81 = getelementptr inbounds i16, ptr %80, i64 2
  store i16 %78, ptr %81, align 2, !tbaa !11
  br label %82

82:                                               ; preds = %51, %25
  %83 = load i64, ptr %6, align 8, !tbaa !9
  %84 = add i64 %83, 1
  store i64 %84, ptr %6, align 8, !tbaa !9
  br label %14, !llvm.loop !13

85:                                               ; preds = %14
  %86 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %87 = load i64, ptr %86, align 8, !tbaa !9
  %88 = shl i64 %87, 9
  %89 = getelementptr inbounds [1 x i64], ptr %5, i64 0, i64 0
  %90 = load i64, ptr %89, align 8, !tbaa !9
  %91 = lshr i64 %90, 55
  %92 = or i64 %88, %91
  %93 = xor i64 %92, 942792860
  %94 = load ptr, ptr %4, align 8, !tbaa !5
  %95 = getelementptr inbounds i64, ptr %94, i64 0
  store i64 %93, ptr %95, align 8, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 2, 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"}


; 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 i64], align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #3
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %5 = add i64 %4, -390364520
  store i64 %5, ptr %3, align 8, !tbaa !5
  %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 %.lr.ph

.lr.ph:                                           ; preds = %2, %24
  %.020 = phi i64 [ %25, %24 ], [ 0, %2 ]
  %8 = load i64, ptr %3, align 8
  %9 = icmp ugt i64 %8, %.020
  br i1 %9, label %10, label %17

10:                                               ; preds = %.lr.ph
  %11 = and i64 %8, 14
  %12 = or disjoint i64 %11, 1
  %13 = tail call i64 @llvm.fshr.i64(i64 %8, i64 %8, i64 %12)
  %14 = shl i64 %13, 4
  %15 = and i64 %14, 1008
  %16 = or i64 %15, %8
  store i64 %16, ptr %3, align 8, !tbaa !5
  br label %24

17:                                               ; preds = %.lr.ph
  %18 = trunc i64 %8 to i16
  %19 = getelementptr inbounds [1 x i64], ptr %3, i64 0, i64 %.020
  %20 = getelementptr inbounds i8, ptr %19, i64 2
  %21 = load i16, ptr %20, align 2, !tbaa !9
  store i16 %18, ptr %20, align 2, !tbaa !9
  %22 = getelementptr inbounds i8, ptr %19, i64 4
  %23 = load i16, ptr %22, align 4, !tbaa !9
  store i16 %23, ptr %3, align 8, !tbaa !9
  store i16 %21, ptr %22, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %17, %10
  %25 = add nuw i64 %.020, 1
  %exitcond.not = icmp eq i64 %25, %7
  br i1 %exitcond.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !11

._crit_edge.loopexit:                             ; preds = %24
  %.pre = load i64, ptr %3, align 8, !tbaa !5
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %2
  %26 = phi i64 [ %.pre, %._crit_edge.loopexit ], [ %5, %2 ]
  %27 = tail call i64 @llvm.fshl.i64(i64 %26, i64 %26, i64 9)
  %28 = xor i64 %27, 942792860
  store i64 %28, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #3
  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

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.fshl.i64(i64, i64, i64) #2

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.fshr.i64(i64, i64, i64) #2

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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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 = !{!"long", !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,DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass