; LLVM IR from HarshCasper/NeoAlgo :: C/ds (doubly_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 [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [14 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 [12 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.17 = 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 = %44, %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 %47

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.2)
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %22 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %24 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %26 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  %29 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.13, ptr noundef %2)
  %30 = load i32, ptr %2, align 4, !tbaa !8
  switch i32 %30, label %42 [
    i32 1, label %31
    i32 2, label %32
    i32 3, label %33
    i32 4, label %34
    i32 5, label %36
    i32 6, label %37
    i32 7, label %38
    i32 8, label %39
    i32 9, label %40
  ]

31:                                               ; preds = %15
  call void @viewlist()
  br label %44

32:                                               ; preds = %15
  call void @insertstart()
  br label %44

33:                                               ; preds = %15
  call void @insertlast()
  br label %44

34:                                               ; preds = %15
  %35 = call ptr @find()
  call void @insertafter(ptr noundef %35)
  br label %44

36:                                               ; preds = %15
  call void @insertat()
  br label %44

37:                                               ; preds = %15
  call void @deletefirst()
  br label %44

38:                                               ; preds = %15
  call void @deletelast()
  br label %44

39:                                               ; preds = %15
  call void @deleteafter()
  br label %44

40:                                               ; preds = %15
  %41 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %4, align 4
  br label %48

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

44:                                               ; preds = %42, %39, %38, %37, %36, %34, %33, %32, %31
  %45 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  %46 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.17, ptr noundef %3)
  br label %5, !llvm.loop !10

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

48:                                               ; preds = %47, %40
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  %49 = load i32, ptr %1, align 4
  ret i32 %49
}

; 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: nounwind uwtable
declare dso_local void @insertafter(ptr noundef) #0

; 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 @insertstart() #0

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @find() #0

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @viewlist() #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 [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [34 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [73 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [62 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [14 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 [12 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.17 = 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, %30
  %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.2)
  %5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  %7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  %8 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  %9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  %10 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  %11 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %12 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  %15 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.13, ptr noundef nonnull %0)
  %16 = load i32, ptr %0, align 4, !tbaa !8
  switch i32 %16, label %28 [
    i32 1, label %17
    i32 2, label %18
    i32 3, label %19
    i32 4, label %20
    i32 5, label %22
    i32 6, label %23
    i32 7, label %24
    i32 8, label %25
    i32 9, label %26
  ]

17:                                               ; preds = %.lr.ph
  call void @viewlist()
  br label %30

18:                                               ; preds = %.lr.ph
  call void @insertstart()
  br label %30

19:                                               ; preds = %.lr.ph
  call void @insertlast()
  br label %30

20:                                               ; preds = %.lr.ph
  %21 = call ptr @find()
  call void @insertafter(ptr noundef %21)
  br label %30

22:                                               ; preds = %.lr.ph
  call void @insertat()
  br label %30

23:                                               ; preds = %.lr.ph
  call void @deletefirst()
  br label %30

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

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

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

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

30:                                               ; preds = %28, %25, %24, %23, %22, %20, %19, %18, %17
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.16)
  %32 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.17, ptr noundef nonnull %1)
  %33 = load i8, ptr %1, align 1
  %34 = and i8 %33, -33
  %35 = icmp eq i8 %34, 89
  br i1 %35, label %.lr.ph, label %.loopexit, !llvm.loop !10

.loopexit:                                        ; preds = %30, %26
  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: nounwind uwtable
declare dso_local void @insertafter(ptr noundef) local_unnamed_addr #0

; 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 @insertstart() local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @find() local_unnamed_addr #0

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

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

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @viewlist() 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