; LLVM IR from gargarchit/Data_Structure_n_Algorithms :: Linked_List (6_Append)

; 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.1 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [37 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [35 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.15 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.16 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.17 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.18 = external hidden unnamed_addr constant [26 x i8], align 1
@.str.19 = external hidden unnamed_addr constant [22 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

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

declare i32 @__isoc99_scanf(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
declare dso_local void @Insert_front(ptr noundef) #2

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

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

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

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

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

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

6:                                                ; preds = %71, %0
  %7 = load i32, ptr %1, align 4, !tbaa !9
  %8 = icmp ne i32 %7, 0
  br i1 %8, label %9, label %72

9:                                                ; preds = %6
  %10 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %11 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %12 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %2)
  %13 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %15 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %16 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  %18 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  %20 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  %21 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %1)
  %22 = load i32, ptr %1, align 4, !tbaa !9
  switch i32 %22, label %69 [
    i32 1, label %23
    i32 2, label %33
    i32 3, label %43
    i32 4, label %53
    i32 5, label %63
    i32 6, label %66
  ]

23:                                               ; preds = %9
  %24 = load i32, ptr %2, align 4, !tbaa !9
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %27

26:                                               ; preds = %23
  call void @Insert_front(ptr noundef %3)
  call void @Display_LL(ptr noundef %3)
  br label %71

27:                                               ; preds = %23
  %28 = load i32, ptr %2, align 4, !tbaa !9
  %29 = icmp eq i32 %28, 2
  br i1 %29, label %30, label %31

30:                                               ; preds = %27
  call void @Insert_front(ptr noundef %4)
  call void @Display_LL(ptr noundef %4)
  br label %71

31:                                               ; preds = %27
  br label %32

32:                                               ; preds = %31
  br label %33

33:                                               ; preds = %32, %9
  %34 = load i32, ptr %2, align 4, !tbaa !9
  %35 = icmp eq i32 %34, 1
  br i1 %35, label %36, label %37

36:                                               ; preds = %33
  call void @Delete_front(ptr noundef %3)
  call void @Display_LL(ptr noundef %3)
  br label %71

37:                                               ; preds = %33
  %38 = load i32, ptr %2, align 4, !tbaa !9
  %39 = icmp eq i32 %38, 2
  br i1 %39, label %40, label %41

40:                                               ; preds = %37
  call void @Delete_front(ptr noundef %4)
  call void @Display_LL(ptr noundef %4)
  br label %71

41:                                               ; preds = %37
  br label %42

42:                                               ; preds = %41
  br label %43

43:                                               ; preds = %42, %9
  %44 = load i32, ptr %2, align 4, !tbaa !9
  %45 = icmp eq i32 %44, 1
  br i1 %45, label %46, label %47

46:                                               ; preds = %43
  call void @Insert_end(ptr noundef %3)
  call void @Display_LL(ptr noundef %3)
  br label %71

47:                                               ; preds = %43
  %48 = load i32, ptr %2, align 4, !tbaa !9
  %49 = icmp eq i32 %48, 2
  br i1 %49, label %50, label %51

50:                                               ; preds = %47
  call void @Insert_end(ptr noundef %4)
  call void @Display_LL(ptr noundef %4)
  br label %71

51:                                               ; preds = %47
  br label %52

52:                                               ; preds = %51
  br label %53

53:                                               ; preds = %52, %9
  %54 = load i32, ptr %2, align 4, !tbaa !9
  %55 = icmp eq i32 %54, 1
  br i1 %55, label %56, label %57

56:                                               ; preds = %53
  call void @Delete_end(ptr noundef %3)
  call void @Display_LL(ptr noundef %3)
  br label %71

57:                                               ; preds = %53
  %58 = load i32, ptr %2, align 4, !tbaa !9
  %59 = icmp eq i32 %58, 2
  br i1 %59, label %60, label %61

60:                                               ; preds = %57
  call void @Delete_end(ptr noundef %4)
  call void @Display_LL(ptr noundef %4)
  br label %71

61:                                               ; preds = %57
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62, %9
  %64 = call i32 (ptr, ...) @printf(ptr noundef @.str.15)
  call void @Display_LL(ptr noundef %3)
  %65 = call i32 (ptr, ...) @printf(ptr noundef @.str.16)
  call void @Display_LL(ptr noundef %4)
  br label %71

66:                                               ; preds = %9
  call void @Append(ptr noundef %3, ptr noundef %4)
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.17)
  call void @Display_LL(ptr noundef %3)
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.18)
  call void @Display_LL(ptr noundef %4)
  store i32 1, ptr %5, align 4
  br label %73

69:                                               ; preds = %9
  %70 = call i32 (ptr, ...) @printf(ptr noundef @.str.19)
  br label %71

71:                                               ; preds = %69, %63, %60, %56, %50, %46, %40, %36, %30, %26
  br label %6, !llvm.loop !11

72:                                               ; preds = %6
  store i32 0, ptr %5, align 4
  br label %73

73:                                               ; preds = %72, %66
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %1) #3
  %74 = load i32, ptr %5, align 4
  switch i32 %74, label %76 [
    i32 0, label %75
    i32 1, label %75
  ]

75:                                               ; preds = %73, %73
  ret void

76:                                               ; preds = %73
  unreachable
}

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 = distinct !{!11, !12}
!12 = !{!"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"

; Function Attrs: mustprogress nofree norecurse noreturn nosync nounwind willreturn memory(none) uwtable
define dso_local void @main() local_unnamed_addr #0 {
  unreachable
}

attributes #0 = { mustprogress nofree norecurse noreturn nosync nounwind willreturn memory(none) 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)"}


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