; LLVM IR from vmartinv/eldiego :: estructuras/treaparr.ll (Z2atP4nodei)

; 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 { %"struct.std::pair", %"struct.std::pair", i32, i32, i32, ptr, ptr, ptr }
%"struct.std::pair" = type { i32, i32 }

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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL4sizeP4node(ptr noundef) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef ptr @_Z2atP4nodei(ptr noundef %0, i32 noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i32 %1, ptr %5, align 4, !tbaa !9
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = icmp ne ptr %6, null
  br i1 %7, label %9, label %8

8:                                                ; preds = %2
  call void @exit(i32 noundef 1) #3
  unreachable

9:                                                ; preds = %2
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z4pushP4node(ptr noundef %10)
  %11 = load i32, ptr %5, align 4, !tbaa !9
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.node, ptr %12, i32 0, i32 5
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  %15 = call noundef i32 @_ZL4sizeP4node(ptr noundef %14)
  %16 = icmp eq i32 %11, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %9
  %18 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %18, ptr %3, align 8
  br label %44

19:                                               ; preds = %9
  %20 = load i32, ptr %5, align 4, !tbaa !9
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.node, ptr %21, i32 0, i32 5
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = call noundef i32 @_ZL4sizeP4node(ptr noundef %23)
  %25 = icmp slt i32 %20, %24
  br i1 %25, label %26, label %32

26:                                               ; preds = %19
  %27 = load ptr, ptr %4, align 8, !tbaa !5
  %28 = getelementptr inbounds %struct.node, ptr %27, i32 0, i32 5
  %29 = load ptr, ptr %28, align 8, !tbaa !11
  %30 = load i32, ptr %5, align 4, !tbaa !9
  %31 = call noundef ptr @_Z2atP4nodei(ptr noundef %29, i32 noundef %30)
  store ptr %31, ptr %3, align 8
  br label %44

32:                                               ; preds = %19
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.node, ptr %33, i32 0, i32 6
  %35 = load ptr, ptr %34, align 8, !tbaa !14
  %36 = load i32, ptr %5, align 4, !tbaa !9
  %37 = sub nsw i32 %36, 1
  %38 = load ptr, ptr %4, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.node, ptr %38, i32 0, i32 5
  %40 = load ptr, ptr %39, align 8, !tbaa !11
  %41 = call noundef i32 @_ZL4sizeP4node(ptr noundef %40)
  %42 = sub nsw i32 %37, %41
  %43 = call noundef ptr @_Z2atP4nodei(ptr noundef %35, i32 noundef %42)
  store ptr %43, ptr %3, align 8
  br label %44

44:                                               ; preds = %32, %26, %17
  %45 = load ptr, ptr %3, align 8
  ret ptr %45
}

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #2

attributes #0 = { mustprogress 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 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 = { noreturn 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 = { noreturn 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 32}
!12 = !{!"_ZTS4node", !13, i64 0, !13, i64 8, !10, i64 16, !10, i64 20, !10, i64 24, !6, i64 32, !6, i64 40, !6, i64 48}
!13 = !{!"_ZTSSt4pairIiiE", !10, i64 0, !10, i64 4}
!14 = !{!12, !6, i64 40}


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

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef i32 @_ZL4sizeP4node(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef nonnull ptr @_Z2atP4nodei(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
  %.not1820 = icmp eq ptr %0, null
  br i1 %.not1820, label %tailrecurse.outer._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %tailrecurse.outer
  %.tr14.ph22 = phi i32 [ %18, %tailrecurse.outer ], [ %1, %2 ]
  %.tr.ph21 = phi ptr [ %14, %tailrecurse.outer ], [ %0, %2 ]
  br label %3

tailrecurse.outer._crit_edge:                     ; preds = %tailrecurse.outer, %tailrecurse, %2
  tail call void @exit(i32 noundef 1) #2
  unreachable

3:                                                ; preds = %.lr.ph, %tailrecurse
  %.tr19 = phi ptr [ %.tr.ph21, %.lr.ph ], [ %12, %tailrecurse ]
  tail call void @_Z4pushP4node(ptr noundef nonnull %.tr19)
  %4 = getelementptr inbounds i8, ptr %.tr19, i64 32
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %6 = tail call noundef i32 @_ZL4sizeP4node(ptr noundef %5)
  %7 = icmp eq i32 %6, %.tr14.ph22
  br i1 %7, label %19, label %8

8:                                                ; preds = %3
  %9 = load ptr, ptr %4, align 8, !tbaa !5
  %10 = tail call noundef i32 @_ZL4sizeP4node(ptr noundef %9)
  %11 = icmp sgt i32 %10, %.tr14.ph22
  br i1 %11, label %tailrecurse, label %tailrecurse.outer

tailrecurse:                                      ; preds = %8
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %12, null
  br i1 %.not, label %tailrecurse.outer._crit_edge, label %3

tailrecurse.outer:                                ; preds = %8
  %13 = getelementptr inbounds i8, ptr %.tr19, i64 40
  %14 = load ptr, ptr %13, align 8, !tbaa !12
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = tail call noundef i32 @_ZL4sizeP4node(ptr noundef %15)
  %17 = xor i32 %16, -1
  %18 = add i32 %.tr14.ph22, %17
  %.not18 = icmp eq ptr %14, null
  br i1 %.not18, label %tailrecurse.outer._crit_edge, label %.lr.ph

19:                                               ; preds = %3
  ret ptr %.tr19
}

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

attributes #0 = { mustprogress 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 = { noreturn 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 #2 = { noreturn 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, !11, i64 32}
!6 = !{!"_ZTS4node", !7, i64 0, !7, i64 8, !8, i64 16, !8, i64 20, !8, i64 24, !11, i64 32, !11, i64 40, !11, i64 48}
!7 = !{!"_ZTSSt4pairIiiE", !8, i64 0, !8, i64 4}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"any pointer", !9, i64 0}
!12 = !{!6, !11, i64 40}


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