; LLVM IR from HarshCasper/NeoAlgo :: C/ds (singly_linked_list)

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

@.str = external hidden unnamed_addr constant [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [4 x i8], align 1

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

5:                                                ; preds = %50, %0
  %6 = load i8, ptr %3, align 1, !tbaa !5
  %7 = sext i8 %6 to i32
  %8 = icmp eq i32 %7, 89
  br i1 %8, label %13, label %9

9:                                                ; preds = %5
  %10 = load i8, ptr %3, align 1, !tbaa !5
  %11 = sext i8 %10 to i32
  %12 = icmp eq i32 %11, 121
  br label %13

13:                                               ; preds = %9, %5
  %14 = phi i1 [ true, %5 ], [ %12, %9 ]
  br i1 %14, label %15, label %53

15:                                               ; preds = %13
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str)
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  %30 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.13, ptr noundef %2)
  %31 = load i32, ptr %2, align 4, !tbaa !8
  switch i32 %31, label %48 [
    i32 1, label %32
    i32 2, label %34
    i32 3, label %36
    i32 4, label %38
    i32 5, label %39
    i32 6, label %40
    i32 7, label %42
    i32 8, label %44
    i32 9, label %46
  ]

32:                                               ; preds = %15
  %33 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  call void @insert_node_first()
  br label %50

34:                                               ; preds = %15
  %35 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  call void @insert_node_last()
  br label %50

36:                                               ; preds = %15
  %37 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  call void @insert_node_pos()
  br label %50

38:                                               ; preds = %15
  call void @count()
  br label %50

39:                                               ; preds = %15
  call void @delete_pos()
  br label %50

40:                                               ; preds = %15
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  call void @empty()
  br label %50

42:                                               ; preds = %15
  %43 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  call void @search()
  br label %50

44:                                               ; preds = %15
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.19)
  call void @display()
  br label %50

46:                                               ; preds = %15
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.20)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %54

48:                                               ; preds = %15
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.21)
  br label %50

50:                                               ; preds = %48, %44, %42, %40, %39, %38, %36, %34, %32
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.22)
  %52 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.23, ptr noundef %3)
  br label %5, !llvm.loop !10

53:                                               ; preds = %13
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %54

54:                                               ; preds = %53, %46
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %55 = load i32, ptr %1, align 4
  ret i32 %55
}

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

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

declare i32 @__isoc99_scanf(ptr noundef, ...) #2

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

; Function Attrs: nounwind uwtable
declare dso_local void @insert_node_first() #0

; Function Attrs: nounwind uwtable
declare dso_local void @insert_node_last() #0

; Function Attrs: nounwind uwtable
declare dso_local void @insert_node_pos() #0

; Function Attrs: nounwind uwtable
declare dso_local void @count() #0

; Function Attrs: nounwind uwtable
declare dso_local void @delete_pos() #0

; Function Attrs: nounwind uwtable
declare dso_local void @empty() #0

; Function Attrs: nounwind uwtable
declare dso_local void @search() #0

; Function Attrs: nounwind uwtable
declare dso_local void @display() #0

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 = { "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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"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 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [33 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.20 = external hidden unnamed_addr constant [12 x i8], align 1
@.str.21 = external hidden unnamed_addr constant [19 x i8], align 1
@.str.22 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [4 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.lr.ph.preheader:
  %0 = alloca i32, align 4
  %1 = alloca i8, align 1
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0) #3
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %1) #3
  store i8 89, ptr %1, align 1, !tbaa !5
  br label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.preheader, %36
  %2 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %3 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %4 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str)
  %5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  %16 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.13, ptr noundef nonnull %0)
  %17 = load i32, ptr %0, align 4, !tbaa !8
  switch i32 %17, label %34 [
    i32 1, label %18
    i32 2, label %20
    i32 3, label %22
    i32 4, label %24
    i32 5, label %25
    i32 6, label %26
    i32 7, label %28
    i32 8, label %30
    i32 9, label %32
  ]

18:                                               ; preds = %.lr.ph
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  call void @insert_node_first()
  br label %36

20:                                               ; preds = %.lr.ph
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.15)
  call void @insert_node_last()
  br label %36

22:                                               ; preds = %.lr.ph
  %23 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  call void @insert_node_pos()
  br label %36

24:                                               ; preds = %.lr.ph
  call void @count()
  br label %36

25:                                               ; preds = %.lr.ph
  call void @delete_pos()
  br label %36

26:                                               ; preds = %.lr.ph
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.17)
  call void @empty()
  br label %36

28:                                               ; preds = %.lr.ph
  %29 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.18)
  call void @search()
  br label %36

30:                                               ; preds = %.lr.ph
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.19)
  call void @display()
  br label %36

32:                                               ; preds = %.lr.ph
  %33 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.20)
  br label %.loopexit

34:                                               ; preds = %.lr.ph
  %35 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.21)
  br label %36

36:                                               ; preds = %34, %30, %28, %26, %25, %24, %22, %20, %18
  %37 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22)
  %38 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.23, ptr noundef nonnull %1)
  %39 = load i8, ptr %1, align 1
  %40 = and i8 %39, -33
  %41 = icmp eq i8 %40, 89
  br i1 %41, label %.lr.ph, label %.loopexit, !llvm.loop !10

.loopexit:                                        ; preds = %36, %32
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %1) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0) #3
  ret i32 0
}

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @insert_node_first() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @insert_node_last() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @insert_node_pos() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @count() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @delete_pos() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @empty() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @search() local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local void @display() local_unnamed_addr #0

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}
!8 = !{!9, !9, i64 0}
!9 = !{!"int", !6, i64 0}
!10 = distinct !{!10, !11}
!11 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass