; LLVM IR from div-bargali/Data-Structures-and-Algorithms :: C/Data-Structures/LinkedList (SwapNodesWithoutSwappingData)

; 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.node = type { i32, ptr }

@.str.1 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @createList(i32 noundef) #0

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

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

; 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
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #4
  %13 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %14 = call noalias ptr @malloc(i64 noundef 16) #5
  store ptr %14, ptr %5, align 8, !tbaa !5
  %15 = load i32, ptr %2, align 4, !tbaa !9
  %16 = call ptr @createList(i32 noundef %15)
  store ptr %16, ptr %5, align 8, !tbaa !5
  %17 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %3)
  %18 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef @.str.1, ptr noundef %4)
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %19 = call noalias ptr @malloc(i64 noundef 16) #5
  store ptr %19, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %20 = call noalias ptr @malloc(i64 noundef 16) #5
  store ptr %20, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %21, ptr %6, align 8, !tbaa !5
  br label %22

22:                                               ; preds = %33, %0
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = icmp ne ptr %23, null
  br i1 %24, label %25, label %31

25:                                               ; preds = %22
  %26 = load ptr, ptr %6, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.node, ptr %26, i32 0, i32 0
  %28 = load i32, ptr %27, align 8, !tbaa !11
  %29 = load i32, ptr %3, align 4, !tbaa !9
  %30 = icmp ne i32 %28, %29
  br label %31

31:                                               ; preds = %25, %22
  %32 = phi i1 [ false, %22 ], [ %30, %25 ]
  br i1 %32, label %33, label %38

33:                                               ; preds = %31
  %34 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %34, ptr %7, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.node, ptr %35, i32 0, i32 1
  %37 = load ptr, ptr %36, align 8, !tbaa !13
  store ptr %37, ptr %6, align 8, !tbaa !5
  br label %22, !llvm.loop !14

38:                                               ; preds = %31
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %39 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %39, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %40 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %40, ptr %9, align 8, !tbaa !5
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %41, ptr %6, align 8, !tbaa !5
  store ptr null, ptr %7, align 8, !tbaa !5
  br label %42

42:                                               ; preds = %53, %38
  %43 = load ptr, ptr %6, align 8, !tbaa !5
  %44 = icmp ne ptr %43, null
  br i1 %44, label %45, label %51

45:                                               ; preds = %42
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.node, ptr %46, i32 0, i32 0
  %48 = load i32, ptr %47, align 8, !tbaa !11
  %49 = load i32, ptr %4, align 4, !tbaa !9
  %50 = icmp ne i32 %48, %49
  br label %51

51:                                               ; preds = %45, %42
  %52 = phi i1 [ false, %42 ], [ %50, %45 ]
  br i1 %52, label %53, label %58

53:                                               ; preds = %51
  %54 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %54, ptr %7, align 8, !tbaa !5
  %55 = load ptr, ptr %6, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.node, ptr %55, i32 0, i32 1
  %57 = load ptr, ptr %56, align 8, !tbaa !13
  store ptr %57, ptr %6, align 8, !tbaa !5
  br label %42, !llvm.loop !16

58:                                               ; preds = %51
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %59 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %59, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  %60 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %60, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #4
  %61 = call noalias ptr @malloc(i64 noundef 16) #5
  store ptr %61, ptr %12, align 8, !tbaa !5
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.node, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !13
  store ptr %64, ptr %12, align 8, !tbaa !5
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.node, ptr %65, i32 0, i32 1
  %67 = load ptr, ptr %66, align 8, !tbaa !13
  %68 = load ptr, ptr %10, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.node, ptr %68, i32 0, i32 1
  store ptr %67, ptr %69, align 8, !tbaa !13
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.node, ptr %71, i32 0, i32 1
  store ptr %70, ptr %72, align 8, !tbaa !13
  %73 = load ptr, ptr %9, align 8, !tbaa !5
  %74 = icmp eq ptr %73, null
  br i1 %74, label %75, label %80

75:                                               ; preds = %58
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  store ptr %76, ptr %5, align 8, !tbaa !5
  %77 = load ptr, ptr %9, align 8, !tbaa !5
  %78 = load ptr, ptr %11, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.node, ptr %78, i32 0, i32 1
  store ptr %77, ptr %79, align 8, !tbaa !13
  br label %80

80:                                               ; preds = %75, %58
  %81 = load ptr, ptr %11, align 8, !tbaa !5
  %82 = icmp eq ptr %81, null
  br i1 %82, label %83, label %88

83:                                               ; preds = %80
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %84, ptr %5, align 8, !tbaa !5
  %85 = load ptr, ptr %11, align 8, !tbaa !5
  %86 = load ptr, ptr %9, align 8, !tbaa !5
  %87 = getelementptr inbounds %struct.node, ptr %86, i32 0, i32 1
  store ptr %85, ptr %87, align 8, !tbaa !13
  br label %88

88:                                               ; preds = %83, %80
  %89 = load ptr, ptr %9, align 8, !tbaa !5
  %90 = icmp ne ptr %89, null
  br i1 %90, label %91, label %101

91:                                               ; preds = %88
  %92 = load ptr, ptr %11, align 8, !tbaa !5
  %93 = icmp ne ptr %92, null
  br i1 %93, label %94, label %101

94:                                               ; preds = %91
  %95 = load ptr, ptr %10, align 8, !tbaa !5
  %96 = load ptr, ptr %9, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.node, ptr %96, i32 0, i32 1
  store ptr %95, ptr %97, align 8, !tbaa !13
  %98 = load ptr, ptr %8, align 8, !tbaa !5
  %99 = load ptr, ptr %11, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.node, ptr %99, i32 0, i32 1
  store ptr %98, ptr %100, align 8, !tbaa !13
  br label %101

101:                                              ; preds = %94, %91, %88
  %102 = load ptr, ptr %5, align 8, !tbaa !5
  call void @display(ptr noundef %102)
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %2) #4
  ret i32 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 = { nounwind allocsize(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 = { "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 = { nounwind allocsize(0) }

!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, !10, i64 0}
!12 = !{!"node", !10, i64 0, !6, i64 8}
!13 = !{!12, !6, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


; 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.1 = external hidden unnamed_addr constant [3 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare dso_local ptr @createList(i32 noundef) local_unnamed_addr #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: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #2

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

; 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
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  %4 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %1)
  %5 = load i32, ptr %1, align 4, !tbaa !5
  %6 = call ptr @createList(i32 noundef %5)
  %7 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %2)
  %8 = call i32 (ptr, ...) @__isoc99_scanf(ptr noundef nonnull @.str.1, ptr noundef nonnull %3)
  %9 = call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #5
  %.not49 = icmp eq ptr %6, null
  br i1 %.not49, label %.critedge2, label %.lr.ph

.lr.ph:                                           ; preds = %0
  %10 = load i32, ptr %2, align 4, !tbaa !5
  %11 = load i32, ptr %6, align 8, !tbaa !9
  %.not4169 = icmp eq i32 %11, %10
  br i1 %.not4169, label %.critedge, label %.lr.ph71

12:                                               ; preds = %.lr.ph71
  %13 = load i32, ptr %15, align 8, !tbaa !9
  %.not41 = icmp eq i32 %13, %10
  br i1 %.not41, label %.critedge, label %.lr.ph71, !llvm.loop !12

.lr.ph71:                                         ; preds = %.lr.ph, %12
  %.0375170 = phi ptr [ %15, %12 ], [ %6, %.lr.ph ]
  %14 = getelementptr inbounds i8, ptr %.0375170, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !14
  %.not = icmp eq ptr %15, null
  br i1 %.not, label %.critedge, label %12, !llvm.loop !12

.critedge:                                        ; preds = %.lr.ph71, %12, %.lr.ph
  %.039.lcssa = phi ptr [ %9, %.lr.ph ], [ %.0375170, %12 ], [ %.0375170, %.lr.ph71 ]
  %.037.lcssa = phi ptr [ %6, %.lr.ph ], [ null, %.lr.ph71 ], [ %15, %12 ]
  br i1 %.not49, label %.critedge2, label %.lr.ph59

.lr.ph59:                                         ; preds = %.critedge
  %16 = load i32, ptr %3, align 4, !tbaa !5
  %17 = load i32, ptr %6, align 8, !tbaa !9
  %.not4376 = icmp eq i32 %17, %16
  br i1 %.not4376, label %.critedge2, label %.lr.ph78

18:                                               ; preds = %.lr.ph78
  %19 = load i32, ptr %21, align 8, !tbaa !9
  %.not43 = icmp eq i32 %19, %16
  br i1 %.not43, label %.critedge2, label %.lr.ph78, !llvm.loop !15

.lr.ph78:                                         ; preds = %.lr.ph59, %18
  %.1385877 = phi ptr [ %21, %18 ], [ %6, %.lr.ph59 ]
  %20 = getelementptr inbounds i8, ptr %.1385877, i64 8
  %21 = load ptr, ptr %20, align 8, !tbaa !14
  %.not42 = icmp eq ptr %21, null
  br i1 %.not42, label %.critedge2, label %18, !llvm.loop !15

.critedge2:                                       ; preds = %.lr.ph78, %18, %.lr.ph59, %0, %.critedge
  %.037.lcssa68 = phi ptr [ %.037.lcssa, %.critedge ], [ null, %0 ], [ %.037.lcssa, %.lr.ph59 ], [ %.037.lcssa, %18 ], [ %.037.lcssa, %.lr.ph78 ]
  %.039.lcssa67 = phi ptr [ %.039.lcssa, %.critedge ], [ %9, %0 ], [ %.039.lcssa, %.lr.ph59 ], [ %.039.lcssa, %18 ], [ %.039.lcssa, %.lr.ph78 ]
  %.140.lcssa = phi ptr [ null, %.critedge ], [ null, %0 ], [ null, %.lr.ph59 ], [ %.1385877, %18 ], [ %.1385877, %.lr.ph78 ]
  %.138.lcssa = phi ptr [ null, %.critedge ], [ null, %0 ], [ %6, %.lr.ph59 ], [ null, %.lr.ph78 ], [ %21, %18 ]
  %22 = getelementptr inbounds i8, ptr %.138.lcssa, i64 8
  %23 = load ptr, ptr %22, align 8, !tbaa !14
  %24 = getelementptr inbounds i8, ptr %.037.lcssa68, i64 8
  %25 = load ptr, ptr %24, align 8, !tbaa !14
  store ptr %25, ptr %22, align 8, !tbaa !14
  store ptr %23, ptr %24, align 8, !tbaa !14
  %26 = icmp eq ptr %.039.lcssa67, null
  br i1 %26, label %.thread, label %28

.thread:                                          ; preds = %.critedge2
  %27 = getelementptr inbounds i8, ptr %.140.lcssa, i64 8
  store ptr null, ptr %27, align 8, !tbaa !14
  br label %.thread45

28:                                               ; preds = %.critedge2
  %29 = icmp eq ptr %.140.lcssa, null
  %30 = getelementptr inbounds i8, ptr %.039.lcssa67, i64 8
  br i1 %29, label %31, label %32

31:                                               ; preds = %28
  store ptr null, ptr %30, align 8, !tbaa !14
  br label %.thread45

32:                                               ; preds = %28
  store ptr %.138.lcssa, ptr %30, align 8, !tbaa !14
  %33 = getelementptr inbounds i8, ptr %.140.lcssa, i64 8
  store ptr %.037.lcssa68, ptr %33, align 8, !tbaa !14
  br label %.thread45

.thread45:                                        ; preds = %31, %.thread, %32
  %.148 = phi ptr [ %6, %32 ], [ %.138.lcssa, %.thread ], [ %.037.lcssa68, %31 ]
  call void @display(ptr noundef %.148)
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  ret i32 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 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"node", !6, i64 0, !11, i64 8}
!11 = !{!"any pointer", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!10, !11, i64 8}
!15 = distinct !{!15, !13}


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