; LLVM IR from wkoszek/kmnsim :: src (all)

; 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.nids = type { ptr, ptr }
%struct.nid = type { i64, [64 x i8], i32, i32, ptr, %struct.anon.0 }
%struct.anon.0 = type { ptr, ptr }

@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.166 = external hidden unnamed_addr constant [13 x i8], align 1
@__PRETTY_FUNCTION__.nid_lookup = external hidden unnamed_addr constant [62 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

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

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

14:                                               ; preds = %4
  br label %16

15:                                               ; preds = %4
  call void @__assert_fail(ptr noundef @.str.166, ptr noundef @.str.2, i32 noundef 2895, ptr noundef @__PRETTY_FUNCTION__.nid_lookup) #4
  unreachable

16:                                               ; preds = %14
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.nids, ptr %17, i32 0, i32 0
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  store ptr %19, ptr %10, align 8, !tbaa !5
  br label %20

20:                                               ; preds = %53, %16
  %21 = load ptr, ptr %10, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %23, label %58

23:                                               ; preds = %20
  %24 = load ptr, ptr %10, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.nid, ptr %24, i32 0, i32 1
  %26 = getelementptr inbounds [64 x i8], ptr %25, i64 0, i64 0
  %27 = load ptr, ptr %7, align 8, !tbaa !5
  %28 = call i32 @streq(ptr noundef %26, ptr noundef %27)
  %29 = icmp ne i32 %28, 0
  br i1 %29, label %31, label %30

30:                                               ; preds = %23
  br label %53

31:                                               ; preds = %23
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = icmp ne i32 %32, -1
  br i1 %33, label %34, label %41

34:                                               ; preds = %31
  %35 = load ptr, ptr %10, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.nid, ptr %35, i32 0, i32 2
  %37 = load i32, ptr %36, align 8, !tbaa !13
  %38 = load i32, ptr %8, align 4, !tbaa !9
  %39 = icmp ne i32 %37, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %34
  br label %53

41:                                               ; preds = %34, %31
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = icmp ne i32 %42, -1
  br i1 %43, label %44, label %51

44:                                               ; preds = %41
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.nid, ptr %45, i32 0, i32 3
  %47 = load i32, ptr %46, align 4, !tbaa !17
  %48 = load i32, ptr %9, align 4, !tbaa !9
  %49 = icmp ne i32 %47, %48
  br i1 %49, label %50, label %51

50:                                               ; preds = %44
  br label %53

51:                                               ; preds = %44, %41
  %52 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %52, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %59

53:                                               ; preds = %50, %40, %30
  %54 = load ptr, ptr %10, align 8, !tbaa !5
  %55 = getelementptr inbounds %struct.nid, ptr %54, i32 0, i32 5
  %56 = getelementptr inbounds %struct.anon.0, ptr %55, i32 0, i32 0
  %57 = load ptr, ptr %56, align 8, !tbaa !18
  store ptr %57, ptr %10, align 8, !tbaa !5
  br label %20, !llvm.loop !19

58:                                               ; preds = %20
  store ptr null, ptr %5, align 8
  store i32 1, ptr %11, align 4
  br label %59

59:                                               ; preds = %58, %51
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %60 = load ptr, ptr %5, align 8
  ret ptr %60
}

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 }
attributes #4 = { noreturn 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, !6, i64 0}
!12 = !{!"nids", !6, i64 0, !6, i64 8}
!13 = !{!14, !10, i64 72}
!14 = !{!"nid", !15, i64 0, !7, i64 8, !10, i64 72, !10, i64 76, !6, i64 80, !16, i64 88}
!15 = !{!"long", !7, i64 0}
!16 = !{!"", !6, i64 0, !6, i64 8}
!17 = !{!14, !10, i64 76}
!18 = !{!14, !6, i64 88}
!19 = distinct !{!19, !20}
!20 = !{!"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"

@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.166 = external hidden unnamed_addr constant [13 x i8], align 1
@__PRETTY_FUNCTION__.nid_lookup = external hidden unnamed_addr constant [62 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local ptr @nid_lookup(ptr nocapture noundef readonly %0, ptr noundef %1, i32 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %23, label %.preheader

.preheader:                                       ; preds = %4
  %.023 = load ptr, ptr %0, align 8, !tbaa !5
  %.not1724 = icmp eq ptr %.023, null
  br i1 %.not1724, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %.not19 = icmp eq i32 %2, -1
  %.not21 = icmp eq i32 %3, -1
  br i1 %.not19, label %.lr.ph.split.us, label %.lr.ph.split

.lr.ph.split.us:                                  ; preds = %.lr.ph
  br i1 %.not21, label %.lr.ph.split.us.split.us, label %.lr.ph.split.us.split

.lr.ph.split.us.split.us:                         ; preds = %.lr.ph.split.us, %7
  %.025.us.us = phi ptr [ %.0.us.us, %7 ], [ %.023, %.lr.ph.split.us ]
  %5 = getelementptr inbounds i8, ptr %.025.us.us, i64 8
  %6 = tail call i32 @streq(ptr noundef nonnull %5, ptr noundef nonnull %1)
  %.not18.us.us = icmp eq i32 %6, 0
  br i1 %.not18.us.us, label %7, label %._crit_edge

7:                                                ; preds = %.lr.ph.split.us.split.us
  %8 = getelementptr inbounds i8, ptr %.025.us.us, i64 88
  %.0.us.us = load ptr, ptr %8, align 8, !tbaa !5
  %.not17.us.us = icmp eq ptr %.0.us.us, null
  br i1 %.not17.us.us, label %._crit_edge, label %.lr.ph.split.us.split.us, !llvm.loop !9

.lr.ph.split.us.split:                            ; preds = %.lr.ph.split.us, %14
  %.025.us = phi ptr [ %.0.us, %14 ], [ %.023, %.lr.ph.split.us ]
  %9 = getelementptr inbounds i8, ptr %.025.us, i64 8
  %10 = tail call i32 @streq(ptr noundef nonnull %9, ptr noundef nonnull %1)
  %.not18.us = icmp eq i32 %10, 0
  br i1 %.not18.us, label %14, label %11

11:                                               ; preds = %.lr.ph.split.us.split
  %12 = getelementptr inbounds i8, ptr %.025.us, i64 76
  %13 = load i32, ptr %12, align 4, !tbaa !11
  %.not22.us = icmp eq i32 %13, %3
  br i1 %.not22.us, label %._crit_edge, label %14

14:                                               ; preds = %11, %.lr.ph.split.us.split
  %15 = getelementptr inbounds i8, ptr %.025.us, i64 88
  %.0.us = load ptr, ptr %15, align 8, !tbaa !5
  %.not17.us = icmp eq ptr %.0.us, null
  br i1 %.not17.us, label %._crit_edge, label %.lr.ph.split.us.split, !llvm.loop !9

.lr.ph.split:                                     ; preds = %.lr.ph
  br i1 %.not21, label %.lr.ph.split.split.us, label %.lr.ph.split.split

.lr.ph.split.split.us:                            ; preds = %.lr.ph.split, %21
  %.025.us32 = phi ptr [ %.0.us34, %21 ], [ %.023, %.lr.ph.split ]
  %16 = getelementptr inbounds i8, ptr %.025.us32, i64 8
  %17 = tail call i32 @streq(ptr noundef nonnull %16, ptr noundef nonnull %1)
  %.not18.us33 = icmp eq i32 %17, 0
  br i1 %.not18.us33, label %21, label %18

18:                                               ; preds = %.lr.ph.split.split.us
  %19 = getelementptr inbounds i8, ptr %.025.us32, i64 72
  %20 = load i32, ptr %19, align 8, !tbaa !16
  %.not20.us = icmp eq i32 %20, %2
  br i1 %.not20.us, label %._crit_edge, label %21

21:                                               ; preds = %18, %.lr.ph.split.split.us
  %22 = getelementptr inbounds i8, ptr %.025.us32, i64 88
  %.0.us34 = load ptr, ptr %22, align 8, !tbaa !5
  %.not17.us35 = icmp eq ptr %.0.us34, null
  br i1 %.not17.us35, label %._crit_edge, label %.lr.ph.split.split.us, !llvm.loop !9

23:                                               ; preds = %4
  tail call void @__assert_fail(ptr noundef nonnull @.str.166, ptr noundef nonnull @.str.2, i32 noundef 2895, ptr noundef nonnull @__PRETTY_FUNCTION__.nid_lookup) #2
  unreachable

.lr.ph.split.split:                               ; preds = %.lr.ph.split, %32
  %.025 = phi ptr [ %.0, %32 ], [ %.023, %.lr.ph.split ]
  %24 = getelementptr inbounds i8, ptr %.025, i64 8
  %25 = tail call i32 @streq(ptr noundef nonnull %24, ptr noundef nonnull %1)
  %.not18 = icmp eq i32 %25, 0
  br i1 %.not18, label %32, label %26

26:                                               ; preds = %.lr.ph.split.split
  %27 = getelementptr inbounds i8, ptr %.025, i64 72
  %28 = load i32, ptr %27, align 8, !tbaa !16
  %.not20 = icmp eq i32 %28, %2
  br i1 %.not20, label %29, label %32

29:                                               ; preds = %26
  %30 = getelementptr inbounds i8, ptr %.025, i64 76
  %31 = load i32, ptr %30, align 4, !tbaa !11
  %.not22 = icmp eq i32 %31, %3
  br i1 %.not22, label %._crit_edge, label %32

32:                                               ; preds = %29, %26, %.lr.ph.split.split
  %33 = getelementptr inbounds i8, ptr %.025, i64 88
  %.0 = load ptr, ptr %33, align 8, !tbaa !5
  %.not17 = icmp eq ptr %.0, null
  br i1 %.not17, label %._crit_edge, label %.lr.ph.split.split, !llvm.loop !9

._crit_edge:                                      ; preds = %29, %32, %18, %21, %11, %14, %.lr.ph.split.us.split.us, %7, %.preheader
  %.0.lcssa = phi ptr [ null, %.preheader ], [ null, %7 ], [ %.025.us.us, %.lr.ph.split.us.split.us ], [ null, %14 ], [ %.025.us, %11 ], [ null, %21 ], [ %.025.us32, %18 ], [ null, %32 ], [ %.025, %29 ]
  ret ptr %.0.lcssa
}

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

attributes #0 = { noreturn 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" }
attributes #2 = { noreturn 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = !{!12, !14, i64 76}
!12 = !{!"nid", !13, i64 0, !7, i64 8, !14, i64 72, !14, i64 76, !6, i64 80, !15, i64 88}
!13 = !{!"long", !7, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !6, i64 0, !6, i64 8}
!16 = !{!12, !14, i64 72}


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