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

@.str.2 = external hidden unnamed_addr constant [58 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [31 x i8], align 1
@stderr = external global ptr, align 8
@.str.202 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.203 = external hidden unnamed_addr constant [29 x i8], align 1
@__PRETTY_FUNCTION__.nid_type_desc = external hidden unnamed_addr constant [40 x i8], align 1
@.str.204 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.205 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.206 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.207 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.208 = external hidden unnamed_addr constant [14 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
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

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

6:                                                ; preds = %1
  %7 = load ptr, ptr %3, align 8, !tbaa !5
  %8 = icmp ne ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %6
  br label %11

10:                                               ; preds = %6
  call void @__assert_fail(ptr noundef @.str.202, ptr noundef @.str.2, i32 noundef 2917, ptr noundef @__PRETTY_FUNCTION__.nid_type_desc) #5
  unreachable

11:                                               ; preds = %9
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.nid, ptr %12, i32 0, i32 0
  %14 = load i64, ptr %13, align 8, !tbaa !9
  %15 = icmp eq i64 %14, 1805988336
  br i1 %15, label %16, label %17

16:                                               ; preds = %11
  br label %18

17:                                               ; preds = %11
  call void @__assert_fail(ptr noundef @.str.203, ptr noundef @.str.2, i32 noundef 2917, ptr noundef @__PRETTY_FUNCTION__.nid_type_desc) #5
  unreachable

18:                                               ; preds = %16
  br label %19

19:                                               ; preds = %18
  br label %20

20:                                               ; preds = %19
  %21 = load ptr, ptr %3, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.nid, ptr %21, i32 0, i32 3
  %23 = load i32, ptr %22, align 4, !tbaa !14
  switch i32 %23, label %43 [
    i32 1, label %24
    i32 3, label %25
    i32 2, label %42
  ]

24:                                               ; preds = %20
  store ptr @.str.204, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %46

25:                                               ; preds = %20
  %26 = load ptr, ptr %3, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.nid, ptr %26, i32 0, i32 4
  %28 = load ptr, ptr %27, align 8, !tbaa !15
  store ptr %28, ptr %4, align 8, !tbaa !5
  %29 = load ptr, ptr %4, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.hub, ptr %29, i32 0, i32 0
  %31 = load i64, ptr %30, align 8, !tbaa !16
  %32 = icmp eq i64 %31, 891901535
  br i1 %32, label %33, label %34

33:                                               ; preds = %25
  br label %35

34:                                               ; preds = %25
  call void @__assert_fail(ptr noundef @.str.8, ptr noundef @.str.2, i32 noundef 2924, ptr noundef @__PRETTY_FUNCTION__.nid_type_desc) #5
  unreachable

35:                                               ; preds = %33
  %36 = load ptr, ptr %4, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.hub, ptr %36, i32 0, i32 4
  %38 = load i32, ptr %37, align 4, !tbaa !18
  %39 = icmp eq i32 %38, 0
  br i1 %39, label %40, label %41

40:                                               ; preds = %35
  store ptr @.str.205, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %46

41:                                               ; preds = %35
  store ptr @.str.206, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %46

42:                                               ; preds = %20
  store ptr @.str.207, ptr %2, align 8
  store i32 1, ptr %5, align 4
  br label %46

43:                                               ; preds = %20
  %44 = load ptr, ptr @stderr, align 8, !tbaa !5
  %45 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %44, ptr noundef @.str.208) #4
  call void @abort() #5
  unreachable

46:                                               ; preds = %42, %41, %40, %24
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %47 = load ptr, ptr %2, align 8
  ret ptr %47
}

; Function Attrs: noreturn nounwind
declare void @abort() #1

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 "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 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 #4 = { nounwind }
attributes #5 = { 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, !11, i64 0}
!10 = !{!"nid", !11, i64 0, !7, i64 8, !12, i64 72, !12, i64 76, !6, i64 80, !13, i64 88}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!"", !6, i64 0, !6, i64 8}
!14 = !{!10, !12, i64 76}
!15 = !{!10, !6, i64 80}
!16 = !{!17, !11, i64 0}
!17 = !{!"hub", !11, i64 0, !6, i64 8, !7, i64 16, !12, i64 80, !12, i64 84, !13, i64 88}
!18 = !{!17, !12, i64 84}


; 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.8 = external hidden unnamed_addr constant [31 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.202 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.203 = external hidden unnamed_addr constant [29 x i8], align 1
@__PRETTY_FUNCTION__.nid_type_desc = external hidden unnamed_addr constant [40 x i8], align 1
@.str.204 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.205 = external hidden unnamed_addr constant [4 x i8], align 1
@.str.206 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.207 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.208 = external hidden unnamed_addr constant [14 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: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local nonnull ptr @nid_type_desc(ptr noundef readonly %0) local_unnamed_addr #2 {
  %.not = icmp eq ptr %0, null
  br i1 %.not, label %2, label %3

2:                                                ; preds = %1
  tail call void @__assert_fail(ptr noundef nonnull @.str.202, ptr noundef nonnull @.str.2, i32 noundef 2917, ptr noundef nonnull @__PRETTY_FUNCTION__.nid_type_desc) #3
  unreachable

3:                                                ; preds = %1
  %4 = load i64, ptr %0, align 8, !tbaa !5
  %5 = icmp eq i64 %4, 1805988336
  br i1 %5, label %7, label %6

6:                                                ; preds = %3
  tail call void @__assert_fail(ptr noundef nonnull @.str.203, ptr noundef nonnull @.str.2, i32 noundef 2917, ptr noundef nonnull @__PRETTY_FUNCTION__.nid_type_desc) #3
  unreachable

7:                                                ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 76
  %9 = load i32, ptr %8, align 4, !tbaa !13
  switch i32 %9, label %21 [
    i32 1, label %24
    i32 3, label %10
    i32 2, label %20
  ]

10:                                               ; preds = %7
  %11 = getelementptr inbounds i8, ptr %0, i64 80
  %12 = load ptr, ptr %11, align 8, !tbaa !14
  %13 = load i64, ptr %12, align 8, !tbaa !15
  %14 = icmp eq i64 %13, 891901535
  br i1 %14, label %16, label %15

15:                                               ; preds = %10
  tail call void @__assert_fail(ptr noundef nonnull @.str.8, ptr noundef nonnull @.str.2, i32 noundef 2924, ptr noundef nonnull @__PRETTY_FUNCTION__.nid_type_desc) #3
  unreachable

16:                                               ; preds = %10
  %17 = getelementptr inbounds i8, ptr %12, i64 84
  %18 = load i32, ptr %17, align 4, !tbaa !17
  %19 = icmp eq i32 %18, 0
  %.str.205..str.206 = select i1 %19, ptr @.str.205, ptr @.str.206
  br label %24

20:                                               ; preds = %7
  br label %24

21:                                               ; preds = %7
  %22 = load ptr, ptr @stderr, align 8, !tbaa !18
  %23 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %22, ptr noundef nonnull @.str.208) #4
  tail call void @abort() #3
  unreachable

24:                                               ; preds = %16, %7, %20
  %.0 = phi ptr [ @.str.207, %20 ], [ @.str.204, %7 ], [ %.str.205..str.206, %16 ]
  ret ptr %.0
}

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #0

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 = { 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 #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 = { noreturn nounwind }
attributes #4 = { cold 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, !7, i64 0}
!6 = !{!"nid", !7, i64 0, !8, i64 8, !10, i64 72, !10, i64 76, !11, i64 80, !12, i64 88}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!"", !11, i64 0, !11, i64 8}
!13 = !{!6, !10, i64 76}
!14 = !{!6, !11, i64 80}
!15 = !{!16, !7, i64 0}
!16 = !{!"hub", !7, i64 0, !11, i64 8, !8, i64 16, !10, i64 80, !10, i64 84, !12, i64 88}
!17 = !{!16, !10, i64 84}
!18 = !{!11, !11, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass