; LLVM IR from kevin2431/Traj-LO :: thirdparty/ros/ros_comm/utilities/xmlrpcpp/src (XmlRpcSocket)

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

declare void @_ZN6XmlRpc10XmlRpcUtil3logEiPKcz(i32 noundef, ptr 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: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZL13nonFatalErrorv() #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6XmlRpc12XmlRpcSocket6nbReadEiRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef %2) #3 align 2 {
  %4 = alloca i1, align 1
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca [4096 x i8], align 16
  %10 = alloca i8, align 1
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store i32 %0, ptr %5, align 4, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !9
  store ptr %2, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 4096, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4096, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  store i8 0, ptr %10, align 1, !tbaa !11
  %13 = load ptr, ptr %7, align 8, !tbaa !9
  store i8 0, ptr %13, align 1, !tbaa !11
  br label %14

14:                                               ; preds = %55, %3
  %15 = load i8, ptr %10, align 1, !tbaa !11, !range !13, !noundef !14
  %16 = trunc i8 %15 to i1
  br i1 %16, label %22, label %17

17:                                               ; preds = %14
  %18 = load ptr, ptr %7, align 8, !tbaa !9
  %19 = load i8, ptr %18, align 1, !tbaa !11, !range !13, !noundef !14
  %20 = trunc i8 %19 to i1
  %21 = xor i1 %20, true
  br label %22

22:                                               ; preds = %17, %14
  %23 = phi i1 [ false, %14 ], [ %21, %17 ]
  br i1 %23, label %24, label %56

24:                                               ; preds = %22
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %25 = load i32, ptr %5, align 4, !tbaa !5
  %26 = getelementptr inbounds [4096 x i8], ptr %9, i64 0, i64 0
  %27 = call i64 @read(i32 noundef %25, ptr noundef %26, i64 noundef 4095)
  %28 = trunc i64 %27 to i32
  store i32 %28, ptr %11, align 4, !tbaa !5
  %29 = load i32, ptr %11, align 4, !tbaa !5
  call void (i32, ptr, ...) @_ZN6XmlRpc10XmlRpcUtil3logEiPKcz(i32 noundef 5, ptr noundef @.str.7, i32 noundef %29)
  %30 = load i32, ptr %11, align 4, !tbaa !5
  %31 = icmp sgt i32 %30, 0
  br i1 %31, label %32, label %41

32:                                               ; preds = %24
  %33 = load i32, ptr %11, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds [4096 x i8], ptr %9, i64 0, i64 %34
  store i8 0, ptr %35, align 1, !tbaa !15
  %36 = load ptr, ptr %6, align 8, !tbaa !9
  %37 = getelementptr inbounds [4096 x i8], ptr %9, i64 0, i64 0
  %38 = load i32, ptr %11, align 4, !tbaa !5
  %39 = sext i32 %38 to i64
  %40 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm(ptr noundef nonnull align 8 dereferenceable(32) %36, ptr noundef %37, i64 noundef %39)
  br label %52

41:                                               ; preds = %24
  %42 = load i32, ptr %11, align 4, !tbaa !5
  %43 = icmp eq i32 %42, 0
  br i1 %43, label %44, label %46

44:                                               ; preds = %41
  %45 = load ptr, ptr %7, align 8, !tbaa !9
  store i8 1, ptr %45, align 1, !tbaa !11
  br label %51

46:                                               ; preds = %41
  %47 = call noundef zeroext i1 @_ZL13nonFatalErrorv()
  br i1 %47, label %48, label %49

48:                                               ; preds = %46
  store i8 1, ptr %10, align 1, !tbaa !11
  br label %50

49:                                               ; preds = %46
  store i1 false, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %53

50:                                               ; preds = %48
  br label %51

51:                                               ; preds = %50, %44
  br label %52

52:                                               ; preds = %51, %32
  store i32 0, ptr %12, align 4
  br label %53

53:                                               ; preds = %52, %49
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  %54 = load i32, ptr %12, align 4
  switch i32 %54, label %57 [
    i32 0, label %55
  ]

55:                                               ; preds = %53
  br label %14, !llvm.loop !16

56:                                               ; preds = %22
  store i1 true, ptr %4, align 1
  store i32 1, ptr %12, align 4
  br label %57

57:                                               ; preds = %56, %53
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4096, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  %58 = load i1, ptr %4, align 1
  ret i1 %58
}

declare i64 @read(i32 noundef, ptr noundef, i64 noundef) #0

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i64 noundef) #3 align 2

attributes #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 = { inlinehint 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 #3 = { 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 #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, !6, i64 0}
!6 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

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

declare void @_ZN6XmlRpc10XmlRpcUtil3logEiPKcz(i32 noundef, ptr 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef zeroext i1 @_ZL13nonFatalErrorv() local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
define dso_local noundef zeroext i1 @_ZN6XmlRpc12XmlRpcSocket6nbReadEiRNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEPb(i32 noundef %0, ptr noundef nonnull align 8 dereferenceable(32) %1, ptr nocapture noundef %2) local_unnamed_addr #3 align 2 {
.lr.ph22.preheader:
  %3 = alloca [4096 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4096, ptr nonnull %3) #5
  store i8 0, ptr %2, align 1, !tbaa !5
  br label %.lr.ph22

.lr.ph22:                                         ; preds = %.lr.ph22.preheader, %.backedge
  %4 = call i64 @read(i32 noundef %0, ptr noundef nonnull %3, i64 noundef 4095)
  %5 = trunc i64 %4 to i32
  call void (i32, ptr, ...) @_ZN6XmlRpc10XmlRpcUtil3logEiPKcz(i32 noundef 5, ptr noundef nonnull @.str.7, i32 noundef %5)
  %6 = icmp sgt i32 %5, 0
  br i1 %6, label %.backedge, label %11

.backedge:                                        ; preds = %.lr.ph22
  %7 = and i64 %4, 2147483647
  %8 = getelementptr inbounds [4096 x i8], ptr %3, i64 0, i64 %7
  store i8 0, ptr %8, align 1, !tbaa !9
  %9 = call noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm(ptr noundef nonnull align 8 dereferenceable(32) %1, ptr noundef nonnull %3, i64 noundef %7)
  %.pre = load i8, ptr %2, align 1, !tbaa !5, !range !10
  %10 = trunc nuw i8 %.pre to i1
  br i1 %10, label %.critedge, label %.lr.ph22

11:                                               ; preds = %.lr.ph22
  %12 = icmp eq i32 %5, 0
  br i1 %12, label %.backedge.thread, label %.split

.backedge.thread:                                 ; preds = %11
  store i8 1, ptr %2, align 1, !tbaa !5
  br label %.critedge

.split:                                           ; preds = %11
  %13 = call noundef zeroext i1 @_ZL13nonFatalErrorv()
  br label %.critedge, !llvm.loop !11

.critedge:                                        ; preds = %.backedge, %.backedge.thread, %.split
  %.2 = phi i1 [ %13, %.split ], [ true, %.backedge.thread ], [ true, %.backedge ]
  call void @llvm.lifetime.end.p0(i64 4096, ptr nonnull %3) #5
  ret i1 %.2
}

; Function Attrs: nofree
declare noundef i64 @read(i32 noundef, ptr nocapture noundef, i64 noundef) local_unnamed_addr #4

; Function Attrs: mustprogress uwtable
declare noundef nonnull align 8 dereferenceable(32) ptr @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6appendEPKcm(ptr noundef nonnull align 8 dereferenceable(32), ptr noundef, i64 noundef) local_unnamed_addr #3 align 2

attributes #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 = { inlinehint 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 #3 = { 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 #4 = { nofree "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 #5 = { 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 = !{!"bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{i8 0, i8 2}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


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