; LLVM IR from JessonYue/LeetCodeLearning :: Array/fanbei/0618/c (soloution06_18)

; 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.QueueNode = type { i32, ptr, ptr }
%struct.MaxQueue = type { ptr, ptr, i32, ptr, ptr, i32 }

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 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
define dso_local void @maxQueuePush_back(ptr noundef %0, i32 noundef %1) #2 {
  %3 = alloca ptr, align 8
  %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
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  %11 = call noalias ptr @malloc(i64 noundef 24) #5
  store ptr %11, ptr %5, align 8, !tbaa !5
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = load ptr, ptr %5, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.QueueNode, ptr %13, i32 0, i32 0
  store i32 %12, ptr %14, align 8, !tbaa !11
  %15 = load ptr, ptr %3, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.MaxQueue, ptr %15, i32 0, i32 1
  %17 = load ptr, ptr %16, align 8, !tbaa !13
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds %struct.QueueNode, ptr %18, i32 0, i32 1
  store ptr %17, ptr %19, align 8, !tbaa !15
  %20 = load ptr, ptr %3, align 8, !tbaa !5
  %21 = getelementptr inbounds %struct.MaxQueue, ptr %20, i32 0, i32 1
  %22 = load ptr, ptr %21, align 8, !tbaa !13
  %23 = getelementptr inbounds %struct.QueueNode, ptr %22, i32 0, i32 2
  %24 = load ptr, ptr %23, align 8, !tbaa !16
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.QueueNode, ptr %25, i32 0, i32 2
  store ptr %24, ptr %26, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.MaxQueue, ptr %27, i32 0, i32 1
  %29 = load ptr, ptr %28, align 8, !tbaa !13
  %30 = getelementptr inbounds %struct.QueueNode, ptr %29, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !16
  store ptr %31, ptr %6, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.QueueNode, ptr %33, i32 0, i32 1
  store ptr %32, ptr %34, align 8, !tbaa !15
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.MaxQueue, ptr %36, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !13
  %39 = getelementptr inbounds %struct.QueueNode, ptr %38, i32 0, i32 2
  store ptr %35, ptr %39, align 8, !tbaa !16
  %40 = load ptr, ptr %3, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.MaxQueue, ptr %40, i32 0, i32 2
  %42 = load i32, ptr %41, align 8, !tbaa !17
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %41, align 8, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %44 = load ptr, ptr %3, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.MaxQueue, ptr %44, i32 0, i32 4
  %46 = load ptr, ptr %45, align 8, !tbaa !18
  %47 = getelementptr inbounds %struct.QueueNode, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !16
  store ptr %48, ptr %7, align 8, !tbaa !5
  br label %49

49:                                               ; preds = %62, %2
  %50 = load ptr, ptr %3, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.MaxQueue, ptr %50, i32 0, i32 5
  %52 = load i32, ptr %51, align 8, !tbaa !19
  %53 = icmp sgt i32 %52, 0
  br i1 %53, label %54, label %60

54:                                               ; preds = %49
  %55 = load ptr, ptr %7, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.QueueNode, ptr %55, i32 0, i32 0
  %57 = load i32, ptr %56, align 8, !tbaa !11
  %58 = load i32, ptr %4, align 4, !tbaa !9
  %59 = icmp slt i32 %57, %58
  br label %60

60:                                               ; preds = %54, %49
  %61 = phi i1 [ false, %49 ], [ %59, %54 ]
  br i1 %61, label %62, label %82

62:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %63 = load ptr, ptr %7, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.QueueNode, ptr %63, i32 0, i32 2
  %65 = load ptr, ptr %64, align 8, !tbaa !16
  store ptr %65, ptr %8, align 8, !tbaa !5
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.MaxQueue, ptr %66, i32 0, i32 4
  %68 = load ptr, ptr %67, align 8, !tbaa !18
  %69 = load ptr, ptr %8, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.QueueNode, ptr %69, i32 0, i32 1
  store ptr %68, ptr %70, align 8, !tbaa !15
  %71 = load ptr, ptr %8, align 8, !tbaa !5
  %72 = load ptr, ptr %3, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.MaxQueue, ptr %72, i32 0, i32 4
  %74 = load ptr, ptr %73, align 8, !tbaa !18
  %75 = getelementptr inbounds %struct.QueueNode, ptr %74, i32 0, i32 2
  store ptr %71, ptr %75, align 8, !tbaa !16
  %76 = load ptr, ptr %3, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.MaxQueue, ptr %76, i32 0, i32 5
  %78 = load i32, ptr %77, align 8, !tbaa !19
  %79 = add nsw i32 %78, -1
  store i32 %79, ptr %77, align 8, !tbaa !19
  %80 = load ptr, ptr %7, align 8, !tbaa !5
  call void @free(ptr noundef %80) #4
  %81 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %81, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  br label %49, !llvm.loop !20

82:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %83 = call noalias ptr @malloc(i64 noundef 24) #5
  store ptr %83, ptr %9, align 8, !tbaa !5
  %84 = load i32, ptr %4, align 4, !tbaa !9
  %85 = load ptr, ptr %9, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.QueueNode, ptr %85, i32 0, i32 0
  store i32 %84, ptr %86, align 8, !tbaa !11
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.MaxQueue, ptr %87, i32 0, i32 4
  %89 = load ptr, ptr %88, align 8, !tbaa !18
  %90 = load ptr, ptr %9, align 8, !tbaa !5
  %91 = getelementptr inbounds %struct.QueueNode, ptr %90, i32 0, i32 1
  store ptr %89, ptr %91, align 8, !tbaa !15
  %92 = load ptr, ptr %3, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.MaxQueue, ptr %92, i32 0, i32 4
  %94 = load ptr, ptr %93, align 8, !tbaa !18
  %95 = getelementptr inbounds %struct.QueueNode, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !16
  %97 = load ptr, ptr %9, align 8, !tbaa !5
  %98 = getelementptr inbounds %struct.QueueNode, ptr %97, i32 0, i32 2
  store ptr %96, ptr %98, align 8, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %99 = load ptr, ptr %3, align 8, !tbaa !5
  %100 = getelementptr inbounds %struct.MaxQueue, ptr %99, i32 0, i32 4
  %101 = load ptr, ptr %100, align 8, !tbaa !18
  %102 = getelementptr inbounds %struct.QueueNode, ptr %101, i32 0, i32 2
  %103 = load ptr, ptr %102, align 8, !tbaa !16
  store ptr %103, ptr %10, align 8, !tbaa !5
  %104 = load ptr, ptr %9, align 8, !tbaa !5
  %105 = load ptr, ptr %10, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.QueueNode, ptr %105, i32 0, i32 1
  store ptr %104, ptr %106, align 8, !tbaa !15
  %107 = load ptr, ptr %9, align 8, !tbaa !5
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.MaxQueue, ptr %108, i32 0, i32 4
  %110 = load ptr, ptr %109, align 8, !tbaa !18
  %111 = getelementptr inbounds %struct.QueueNode, ptr %110, i32 0, i32 2
  store ptr %107, ptr %111, align 8, !tbaa !16
  %112 = load ptr, ptr %3, align 8, !tbaa !5
  %113 = getelementptr inbounds %struct.MaxQueue, ptr %112, i32 0, i32 5
  %114 = load i32, ptr %113, align 8, !tbaa !19
  %115 = add nsw i32 %114, 1
  store i32 %115, ptr %113, align 8, !tbaa !19
  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 %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  ret void
}

; Function Attrs: nounwind
declare void @free(ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 "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 = !{!"", !10, i64 0, !6, i64 8, !6, i64 16}
!13 = !{!14, !6, i64 8}
!14 = !{!"", !6, i64 0, !6, i64 8, !10, i64 16, !6, i64 24, !6, i64 32, !10, i64 40}
!15 = !{!12, !6, i64 8}
!16 = !{!12, !6, i64 16}
!17 = !{!14, !10, i64 16}
!18 = !{!14, !6, i64 32}
!19 = !{!14, !10, i64 40}
!20 = distinct !{!20, !21}
!21 = !{!"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 nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @maxQueuePush_back(ptr nocapture noundef %0, i32 noundef %1) local_unnamed_addr #1 {
  %3 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #3
  store i32 %1, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !11
  %6 = getelementptr inbounds i8, ptr %3, i64 8
  store ptr %5, ptr %6, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %5, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  %9 = getelementptr inbounds i8, ptr %3, i64 16
  store ptr %8, ptr %9, align 8, !tbaa !14
  %10 = getelementptr inbounds i8, ptr %8, i64 8
  store ptr %3, ptr %10, align 8, !tbaa !13
  store ptr %3, ptr %7, align 8, !tbaa !14
  %11 = getelementptr inbounds i8, ptr %0, i64 16
  %12 = load i32, ptr %11, align 8, !tbaa !15
  %13 = add nsw i32 %12, 1
  store i32 %13, ptr %11, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  %15 = load ptr, ptr %14, align 8, !tbaa !16
  %16 = getelementptr inbounds i8, ptr %15, i64 16
  %17 = load ptr, ptr %16, align 8, !tbaa !14
  %18 = getelementptr inbounds i8, ptr %0, i64 40
  %19 = load i32, ptr %18, align 8, !tbaa !17
  %20 = icmp sgt i32 %19, 0
  br i1 %20, label %.lr.ph, label %.critedge

.lr.ph:                                           ; preds = %2, %24
  %21 = phi i32 [ %30, %24 ], [ %19, %2 ]
  %.036 = phi ptr [ %26, %24 ], [ %17, %2 ]
  %22 = load i32, ptr %.036, align 8, !tbaa !5
  %23 = icmp slt i32 %22, %1
  %.pre.pre42 = load ptr, ptr %14, align 8, !tbaa !16
  br i1 %23, label %24, label %.critedge.loopexit

24:                                               ; preds = %.lr.ph
  %25 = getelementptr inbounds i8, ptr %.036, i64 16
  %26 = load ptr, ptr %25, align 8, !tbaa !14
  %27 = getelementptr inbounds i8, ptr %26, i64 8
  store ptr %.pre.pre42, ptr %27, align 8, !tbaa !13
  %28 = getelementptr inbounds i8, ptr %.pre.pre42, i64 16
  store ptr %26, ptr %28, align 8, !tbaa !14
  %29 = add nsw i32 %21, -1
  store i32 %29, ptr %18, align 8, !tbaa !17
  tail call void @free(ptr noundef nonnull %.036) #4
  %30 = load i32, ptr %18, align 8, !tbaa !17
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %.lr.ph, label %..critedge.loopexit_crit_edge, !llvm.loop !18

..critedge.loopexit_crit_edge:                    ; preds = %24
  %.pre.pre = load ptr, ptr %14, align 8, !tbaa !16
  br label %.critedge.loopexit

.critedge.loopexit:                               ; preds = %.lr.ph, %..critedge.loopexit_crit_edge
  %.pre = phi ptr [ %.pre.pre, %..critedge.loopexit_crit_edge ], [ %.pre.pre42, %.lr.ph ]
  %.lcssa.ph = phi i32 [ %30, %..critedge.loopexit_crit_edge ], [ %21, %.lr.ph ]
  %.phi.trans.insert = getelementptr inbounds i8, ptr %.pre, i64 16
  %.pre41 = load ptr, ptr %.phi.trans.insert, align 8, !tbaa !14
  br label %.critedge

.critedge:                                        ; preds = %.critedge.loopexit, %2
  %32 = phi ptr [ %17, %2 ], [ %.pre41, %.critedge.loopexit ]
  %33 = phi ptr [ %15, %2 ], [ %.pre, %.critedge.loopexit ]
  %.lcssa = phi i32 [ %19, %2 ], [ %.lcssa.ph, %.critedge.loopexit ]
  %34 = tail call noalias dereferenceable_or_null(24) ptr @malloc(i64 noundef 24) #3
  store i32 %1, ptr %34, align 8, !tbaa !5
  %35 = getelementptr inbounds i8, ptr %34, i64 8
  store ptr %33, ptr %35, align 8, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %33, i64 16
  %37 = getelementptr inbounds i8, ptr %34, i64 16
  store ptr %32, ptr %37, align 8, !tbaa !14
  %38 = getelementptr inbounds i8, ptr %32, i64 8
  store ptr %34, ptr %38, align 8, !tbaa !13
  store ptr %34, ptr %36, align 8, !tbaa !14
  %39 = add nsw i32 %.lcssa, 1
  store i32 %39, ptr %18, align 8, !tbaa !17
  ret void
}

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

attributes #0 = { 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 #1 = { 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 #2 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 = { nounwind allocsize(0) }
attributes #4 = { 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 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !10, i64 8}
!12 = !{!"", !10, i64 0, !10, i64 8, !7, i64 16, !10, i64 24, !10, i64 32, !7, i64 40}
!13 = !{!6, !10, i64 8}
!14 = !{!6, !10, i64 16}
!15 = !{!12, !7, i64 16}
!16 = !{!12, !10, i64 32}
!17 = !{!12, !7, i64 40}
!18 = distinct !{!18, !19}
!19 = !{!"llvm.loop.mustprogress"}


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