; LLVM IR from OpenDiS/OpenDiS :: core/pydis/c/util (Util_subset)

; 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"

%struct._node = type { i32, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, %struct._tag, i32, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, i32, i32, i32, i32, i32, ptr, ptr, i32 }
%struct._tag = type { i32, i32 }

@.str.2 = external hidden unnamed_addr constant [56 x i8], align 1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

declare i32 @printf(ptr noundef, ...) #1

; Function Attrs: nounwind uwtable
define dso_local ptr @GetNeighborNode(ptr noundef %0, ptr noundef %1, i32 noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store i32 %2, ptr %7, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  store i32 -1, ptr %9, align 4, !tbaa !9
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %12

12:                                               ; preds = %47, %3
  %13 = load i32, ptr %8, align 4, !tbaa !9
  %14 = load ptr, ptr %6, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct._node, ptr %14, i32 0, i32 20
  %16 = load i32, ptr %15, align 8, !tbaa !11
  %17 = icmp slt i32 %13, %16
  br i1 %17, label %18, label %50

18:                                               ; preds = %12
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct._node, ptr %19, i32 0, i32 21
  %21 = load ptr, ptr %20, align 8, !tbaa !15
  %22 = load i32, ptr %8, align 4, !tbaa !9
  %23 = sext i32 %22 to i64
  %24 = getelementptr inbounds %struct._tag, ptr %21, i64 %23
  %25 = getelementptr inbounds %struct._tag, ptr %24, i32 0, i32 0
  %26 = load i32, ptr %25, align 4, !tbaa !16
  %27 = icmp sge i32 %26, 0
  br i1 %27, label %28, label %31

28:                                               ; preds = %18
  %29 = load i32, ptr %9, align 4, !tbaa !9
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %9, align 4, !tbaa !9
  br label %31

31:                                               ; preds = %28, %18
  %32 = load i32, ptr %9, align 4, !tbaa !9
  %33 = load i32, ptr %7, align 4, !tbaa !9
  %34 = icmp eq i32 %32, %33
  br i1 %34, label %35, label %46

35:                                               ; preds = %31
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct._node, ptr %37, i32 0, i32 21
  %39 = load ptr, ptr %38, align 8, !tbaa !15
  %40 = load i32, ptr %8, align 4, !tbaa !9
  %41 = sext i32 %40 to i64
  %42 = getelementptr inbounds %struct._tag, ptr %39, i64 %41
  %43 = load i64, ptr %42, align 4
  %44 = call ptr @GetNodeFromTag(ptr noundef %36, i64 %43)
  store ptr %44, ptr %10, align 8, !tbaa !5
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %45, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %62

46:                                               ; preds = %31
  br label %47

47:                                               ; preds = %46
  %48 = load i32, ptr %8, align 4, !tbaa !9
  %49 = add nsw i32 %48, 1
  store i32 %49, ptr %8, align 4, !tbaa !9
  br label %12, !llvm.loop !17

50:                                               ; preds = %12
  %51 = load ptr, ptr %6, align 8, !tbaa !5
  %52 = getelementptr inbounds %struct._node, ptr %51, i32 0, i32 19
  %53 = getelementptr inbounds %struct._tag, ptr %52, i32 0, i32 0
  %54 = load i32, ptr %53, align 8, !tbaa !19
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct._node, ptr %55, i32 0, i32 19
  %57 = getelementptr inbounds %struct._tag, ptr %56, i32 0, i32 1
  %58 = load i32, ptr %57, align 4, !tbaa !20
  %59 = load i32, ptr %7, align 4, !tbaa !9
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %54, i32 noundef %58, i32 noundef %59)
  %61 = load ptr, ptr %6, align 8, !tbaa !5
  call void @PrintNode(ptr noundef %61)
  store ptr null, ptr %4, align 8
  store i32 1, ptr %11, align 4
  br label %62

62:                                               ; preds = %50, %35
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  %63 = load ptr, ptr %4, align 8
  ret ptr %63
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @GetNodeFromTag(ptr noundef, i64) #2

; Function Attrs: nounwind uwtable
declare dso_local void @PrintNode(ptr noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 #2 = { 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 #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 = !{!"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, !10, i64 160}
!12 = !{!"_node", !10, i64 0, !13, i64 8, !13, i64 16, !13, i64 24, !13, i64 32, !13, i64 40, !13, i64 48, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !13, i64 112, !13, i64 120, !13, i64 128, !13, i64 136, !13, i64 144, !14, i64 152, !10, i64 160, !6, i64 168, !6, i64 176, !6, i64 184, !6, i64 192, !6, i64 200, !6, i64 208, !6, i64 216, !6, i64 224, !6, i64 232, !6, i64 240, !6, i64 248, !6, i64 256, !6, i64 264, !10, i64 272, !10, i64 276, !10, i64 280, !10, i64 284, !10, i64 288, !6, i64 296, !6, i64 304, !10, i64 312}
!13 = !{!"double", !7, i64 0}
!14 = !{!"_tag", !10, i64 0, !10, i64 4}
!15 = !{!12, !6, i64 168}
!16 = !{!14, !10, i64 0}
!17 = distinct !{!17, !18}
!18 = !{!"llvm.loop.mustprogress"}
!19 = !{!12, !10, i64 152}
!20 = !{!12, !10, i64 156}


; 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"

%struct._tag = type { i32, i32 }

@.str.2 = external hidden unnamed_addr constant [56 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @GetNeighborNode(ptr noundef %0, ptr noundef %1, i32 noundef %2) local_unnamed_addr #1 {
  %4 = getelementptr inbounds i8, ptr %1, i64 160
  %5 = load i32, ptr %4, align 8, !tbaa !5
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.lr.ph, label %._crit_edge

.lr.ph:                                           ; preds = %3
  %7 = getelementptr inbounds i8, ptr %1, i64 168
  %8 = load ptr, ptr %7, align 8, !tbaa !13
  %wide.trip.count = zext nneg i32 %5 to i64
  br label %10

9:                                                ; preds = %10
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %10, !llvm.loop !14

10:                                               ; preds = %.lr.ph, %9
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %9 ]
  %.01621 = phi i32 [ -1, %.lr.ph ], [ %spec.select, %9 ]
  %11 = getelementptr inbounds %struct._tag, ptr %8, i64 %indvars.iv
  %12 = load i32, ptr %11, align 4, !tbaa !16
  %13 = icmp sgt i32 %12, -1
  %14 = zext i1 %13 to i32
  %spec.select = add nsw i32 %.01621, %14
  %15 = icmp eq i32 %spec.select, %2
  br i1 %15, label %16, label %9

16:                                               ; preds = %10
  %17 = getelementptr inbounds %struct._tag, ptr %8, i64 %indvars.iv
  %18 = load i64, ptr %17, align 4
  %19 = tail call ptr @GetNodeFromTag(ptr noundef %0, i64 %18)
  br label %25

._crit_edge:                                      ; preds = %9, %3
  %20 = getelementptr inbounds i8, ptr %1, i64 152
  %21 = load i32, ptr %20, align 8, !tbaa !17
  %22 = getelementptr inbounds i8, ptr %1, i64 156
  %23 = load i32, ptr %22, align 4, !tbaa !18
  %24 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef %21, i32 noundef %23, i32 noundef %2)
  tail call void @PrintNode(ptr noundef nonnull %1)
  br label %25

25:                                               ; preds = %._crit_edge, %16
  %.0 = phi ptr [ %19, %16 ], [ null, %._crit_edge ]
  ret ptr %.0
}

; Function Attrs: nounwind uwtable
declare dso_local ptr @GetNodeFromTag(ptr noundef, i64) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @PrintNode(ptr noundef) local_unnamed_addr #1

attributes #0 = { nofree nounwind "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 = { 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" }

!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, !7, i64 160}
!6 = !{!"_node", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !10, i64 56, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !11, i64 152, !7, i64 160, !12, i64 168, !12, i64 176, !12, i64 184, !12, i64 192, !12, i64 200, !12, i64 208, !12, i64 216, !12, i64 224, !12, i64 232, !12, i64 240, !12, i64 248, !12, i64 256, !12, i64 264, !7, i64 272, !7, i64 276, !7, i64 280, !7, i64 284, !7, i64 288, !12, i64 296, !12, i64 304, !7, i64 312}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"double", !8, i64 0}
!11 = !{!"_tag", !7, i64 0, !7, i64 4}
!12 = !{!"any pointer", !8, i64 0}
!13 = !{!6, !12, i64 168}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = !{!11, !7, i64 0}
!17 = !{!6, !7, i64 152}
!18 = !{!6, !7, i64 156}


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