; LLVM IR from pupnp/pupnp :: ixml/src (node)

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

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

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

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

; Function Attrs: nounwind uwtable
define dso_local ptr @ixmlNode_getAttributes(ptr noundef %0) #2 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store ptr null, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = icmp eq ptr %8, null
  br i1 %9, label %10, label %11

10:                                               ; preds = %1
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %42

11:                                               ; preds = %1
  %12 = load ptr, ptr %3, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct._IXML_Node, ptr %12, i32 0, i32 2
  %14 = load i32, ptr %13, align 8, !tbaa !9
  switch i32 %14, label %41 [
    i32 1, label %15
  ]

15:                                               ; preds = %11
  %16 = call noalias ptr @malloc(i64 noundef 16) #5
  store ptr %16, ptr %4, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %15
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %42

20:                                               ; preds = %15
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  call void @ixmlNamedNodeMap_init(ptr noundef %21)
  %22 = load ptr, ptr %3, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct._IXML_Node, ptr %22, i32 0, i32 11
  %24 = load ptr, ptr %23, align 8, !tbaa !12
  store ptr %24, ptr %5, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %35, %20
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = icmp ne ptr %26, null
  br i1 %27, label %28, label %39

28:                                               ; preds = %25
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = call i32 @ixmlNamedNodeMap_addToNamedNodeMap(ptr noundef %4, ptr noundef %29)
  store i32 %30, ptr %6, align 4, !tbaa !13
  %31 = load i32, ptr %6, align 4, !tbaa !13
  %32 = icmp ne i32 %31, 0
  br i1 %32, label %33, label %35

33:                                               ; preds = %28
  %34 = load ptr, ptr %4, align 8, !tbaa !5
  call void @ixmlNamedNodeMap_free(ptr noundef %34)
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %42

35:                                               ; preds = %28
  %36 = load ptr, ptr %5, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct._IXML_Node, ptr %36, i32 0, i32 10
  %38 = load ptr, ptr %37, align 8, !tbaa !14
  store ptr %38, ptr %5, align 8, !tbaa !5
  br label %25, !llvm.loop !15

39:                                               ; preds = %25
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  store ptr %40, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %42

41:                                               ; preds = %11
  store ptr null, ptr %2, align 8
  store i32 1, ptr %7, align 4
  br label %42

42:                                               ; preds = %41, %39, %33, %19, %10
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  %43 = load ptr, ptr %2, align 8
  ret ptr %43
}

declare void @ixmlNamedNodeMap_init(ptr noundef) #3

declare i32 @ixmlNamedNodeMap_addToNamedNodeMap(ptr noundef, ptr noundef) #3

declare void @ixmlNamedNodeMap_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 = { "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, !11, i64 16}
!10 = !{!"_IXML_Node", !6, i64 0, !6, i64 8, !11, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !11, i64 48, !6, i64 56, !6, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !6, i64 88}
!13 = !{!11, !11, i64 0}
!14 = !{!10, !6, i64 80}
!15 = distinct !{!15, !16}
!16 = !{!"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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local ptr @ixmlNode_getAttributes(ptr noundef readonly %0) local_unnamed_addr #2 {
  %2 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #4
  %3 = icmp eq ptr %0, null
  br i1 %3, label %._crit_edge, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load i32, ptr %5, align 8, !tbaa !5
  %cond = icmp eq i32 %6, 1
  br i1 %cond, label %7, label %._crit_edge

7:                                                ; preds = %4
  %8 = tail call noalias dereferenceable_or_null(16) ptr @malloc(i64 noundef 16) #5
  store ptr %8, ptr %2, align 8, !tbaa !11
  %9 = icmp eq ptr %8, null
  br i1 %9, label %._crit_edge, label %10

10:                                               ; preds = %7
  tail call void @ixmlNamedNodeMap_init(ptr noundef nonnull %8) #4
  %11 = getelementptr inbounds i8, ptr %0, i64 88
  %.0711 = load ptr, ptr %11, align 8, !tbaa !11
  %.not12 = icmp eq ptr %.0711, null
  br i1 %.not12, label %._crit_edge, label %.lr.ph

12:                                               ; preds = %.lr.ph
  %13 = getelementptr inbounds i8, ptr %.0713, i64 80
  %.07 = load ptr, ptr %13, align 8, !tbaa !11
  %.not = icmp eq ptr %.07, null
  br i1 %.not, label %._crit_edge.loopexit, label %.lr.ph, !llvm.loop !12

.lr.ph:                                           ; preds = %10, %12
  %.0713 = phi ptr [ %.07, %12 ], [ %.0711, %10 ]
  %14 = call i32 @ixmlNamedNodeMap_addToNamedNodeMap(ptr noundef nonnull %2, ptr noundef nonnull %.0713) #4
  %.not10 = icmp eq i32 %14, 0
  br i1 %.not10, label %12, label %15

15:                                               ; preds = %.lr.ph
  %16 = load ptr, ptr %2, align 8, !tbaa !11
  call void @ixmlNamedNodeMap_free(ptr noundef %16) #4
  br label %._crit_edge

._crit_edge.loopexit:                             ; preds = %12
  %.pre = load ptr, ptr %2, align 8, !tbaa !11
  br label %._crit_edge

._crit_edge:                                      ; preds = %10, %._crit_edge.loopexit, %4, %7, %1, %15
  %.0 = phi ptr [ null, %15 ], [ null, %1 ], [ null, %7 ], [ null, %4 ], [ %.pre, %._crit_edge.loopexit ], [ %8, %10 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #4
  ret ptr %.0
}

declare void @ixmlNamedNodeMap_init(ptr noundef) local_unnamed_addr #3

declare i32 @ixmlNamedNodeMap_addToNamedNodeMap(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @ixmlNamedNodeMap_free(ptr noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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, !10, i64 16}
!6 = !{!"_IXML_Node", !7, i64 0, !7, i64 8, !10, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !10, i64 48, !7, i64 56, !7, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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