; LLVM IR from RemHero/ReUp-DateBase-Raft :: layer3/ossSocket.ll (ZN10_ossSocketC2EPii)

; 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"

%class._ossSocket = type { i32, i32, i32, %struct.sockaddr_in, %struct.sockaddr_in, i8, i32 }
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }

@_curPDLevel = external dso_local global i32, align 4
@__func__._ZN10_ossSocketC2EPii = external hidden unnamed_addr constant [11 x i8], align 1
@.str = external hidden unnamed_addr constant [80 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [36 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5pdLog7PDLEVELPKcS1_jS1_z(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) #0

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

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

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

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10_ossSocketC2EPii(ptr noundef nonnull align 4 dereferenceable(52) %0, ptr noundef %1, i32 noundef %2) unnamed_addr #0 align 2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store i32 %2, ptr %6, align 4, !tbaa !9
  %8 = load ptr, ptr %4, align 8
  %9 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 3
  %10 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  store i32 0, ptr %7, align 4, !tbaa !9
  %11 = load ptr, ptr %5, align 8, !tbaa !5
  %12 = load i32, ptr %11, align 4, !tbaa !9
  %13 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 0
  store i32 %12, ptr %13, align 4, !tbaa !11
  %14 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 5
  store i8 1, ptr %14, align 4, !tbaa !17
  %15 = load i32, ptr %6, align 4, !tbaa !9
  %16 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 6
  store i32 %15, ptr %16, align 4, !tbaa !18
  %17 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 1
  store i32 16, ptr %17, align 4, !tbaa !19
  %18 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 4
  call void @llvm.memset.p0.i64(ptr align 4 %18, i8 0, i64 16, i1 false)
  %19 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 2
  store i32 16, ptr %19, align 4, !tbaa !20
  %20 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 0
  %21 = load i32, ptr %20, align 4, !tbaa !11
  %22 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 3
  %23 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 1
  %24 = call i32 @getsockname(i32 noundef %21, ptr noundef %22, ptr noundef %23) #5
  store i32 %24, ptr %7, align 4, !tbaa !9
  %25 = load i32, ptr %7, align 4, !tbaa !9
  %26 = icmp ne i32 %25, 0
  br i1 %26, label %27, label %38

27:                                               ; preds = %3
  br label %28

28:                                               ; preds = %27
  %29 = load i32, ptr @_curPDLevel, align 4, !tbaa !21
  %30 = icmp sge i32 %29, 1
  br i1 %30, label %31, label %34

31:                                               ; preds = %28
  %32 = call ptr @__errno_location() #6
  %33 = load i32, ptr %32, align 4, !tbaa !9
  call void (i32, ptr, ptr, i32, ptr, ...) @_Z5pdLog7PDLEVELPKcS1_jS1_z(i32 noundef 1, ptr noundef @__func__._ZN10_ossSocketC2EPii, ptr noundef @.str, i32 noundef 76, ptr noundef @.str.1, i32 noundef %33)
  br label %34

34:                                               ; preds = %31, %28
  br label %35

35:                                               ; preds = %34
  br label %36

36:                                               ; preds = %35
  %37 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 5
  store i8 0, ptr %37, align 4, !tbaa !17
  br label %64

38:                                               ; preds = %3
  %39 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 0
  %40 = load i32, ptr %39, align 4, !tbaa !11
  %41 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 4
  %42 = getelementptr inbounds %class._ossSocket, ptr %8, i32 0, i32 2
  %43 = call i32 @getpeername(i32 noundef %40, ptr noundef %41, ptr noundef %42) #5
  store i32 %43, ptr %7, align 4, !tbaa !9
  br label %44

44:                                               ; preds = %38
  br label %45

45:                                               ; preds = %44
  %46 = load i32, ptr %7, align 4, !tbaa !9
  %47 = icmp eq i32 0, %46
  br i1 %47, label %59, label %48

48:                                               ; preds = %45
  %49 = load i32, ptr %7, align 4, !tbaa !9
  store i32 %49, ptr %7, align 4, !tbaa !9
  br label %50

50:                                               ; preds = %48
  %51 = load i32, ptr @_curPDLevel, align 4, !tbaa !21
  %52 = icmp sge i32 %51, 1
  br i1 %52, label %53, label %56

53:                                               ; preds = %50
  %54 = call ptr @__errno_location() #6
  %55 = load i32, ptr %54, align 4, !tbaa !9
  call void (i32, ptr, ptr, i32, ptr, ...) @_Z5pdLog7PDLEVELPKcS1_jS1_z(i32 noundef 1, ptr noundef @__func__._ZN10_ossSocketC2EPii, ptr noundef @.str, i32 noundef 83, ptr noundef @.str.2, i32 noundef %55)
  br label %56

56:                                               ; preds = %53, %50
  br label %57

57:                                               ; preds = %56
  br label %58

58:                                               ; preds = %57
  br label %66

59:                                               ; preds = %45
  br label %60

60:                                               ; preds = %59
  br label %61

61:                                               ; preds = %60
  br label %62

62:                                               ; preds = %61
  br label %63

63:                                               ; preds = %62
  br label %64

64:                                               ; preds = %63, %36
  br label %65

65:                                               ; preds = %66, %64
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  ret void

66:                                               ; preds = %58
  br label %65
}

; Function Attrs: nounwind
declare i32 @getsockname(i32 noundef, ptr noundef, ptr noundef) #3

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #4

; Function Attrs: nounwind
declare i32 @getpeername(i32 noundef, ptr noundef, ptr noundef) #3

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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 willreturn memory(none) "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 }
attributes #6 = { nounwind willreturn memory(none) }

!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, !10, i64 0}
!12 = !{!"_ZTS10_ossSocket", !10, i64 0, !10, i64 4, !10, i64 8, !13, i64 12, !13, i64 28, !16, i64 44, !10, i64 48}
!13 = !{!"_ZTS11sockaddr_in", !14, i64 0, !14, i64 2, !15, i64 4, !7, i64 8}
!14 = !{!"short", !7, i64 0}
!15 = !{!"_ZTS7in_addr", !10, i64 0}
!16 = !{!"bool", !7, i64 0}
!17 = !{!12, !16, i64 44}
!18 = !{!12, !10, i64 48}
!19 = !{!12, !10, i64 4}
!20 = !{!12, !10, i64 8}
!21 = !{!22, !22, i64 0}
!22 = !{!"_ZTS7PDLEVEL", !7, i64 0}


; 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"

@_curPDLevel = external dso_local local_unnamed_addr global i32, align 4
@__func__._ZN10_ossSocketC2EPii = external hidden unnamed_addr constant [11 x i8], align 1
@.str = external hidden unnamed_addr constant [80 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [36 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [36 x i8], align 1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5pdLog7PDLEVELPKcS1_jS1_z(i32 noundef, ptr noundef, ptr noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN10_ossSocketC2EPii(ptr noundef nonnull align 4 dereferenceable(52) %0, ptr nocapture noundef readonly %1, i32 noundef %2) unnamed_addr #0 align 2 {
  %4 = load i32, ptr %1, align 4, !tbaa !5
  store i32 %4, ptr %0, align 4, !tbaa !9
  %5 = getelementptr inbounds i8, ptr %0, i64 44
  store i8 1, ptr %5, align 4, !tbaa !15
  %6 = getelementptr inbounds i8, ptr %0, i64 48
  store i32 %2, ptr %6, align 4, !tbaa !16
  %7 = getelementptr inbounds i8, ptr %0, i64 4
  store i32 16, ptr %7, align 4, !tbaa !17
  %8 = getelementptr inbounds i8, ptr %0, i64 28
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 4 dereferenceable(16) %8, i8 0, i64 16, i1 false)
  %9 = getelementptr inbounds i8, ptr %0, i64 8
  store i32 16, ptr %9, align 4, !tbaa !18
  %10 = getelementptr inbounds i8, ptr %0, i64 12
  %11 = tail call i32 @getsockname(i32 noundef %4, ptr noundef nonnull %10, ptr noundef nonnull %7) #4
  %.not = icmp eq i32 %11, 0
  br i1 %.not, label %19, label %12

12:                                               ; preds = %3
  %13 = load i32, ptr @_curPDLevel, align 4, !tbaa !19
  %14 = icmp sgt i32 %13, 0
  br i1 %14, label %15, label %18

15:                                               ; preds = %12
  %16 = tail call ptr @__errno_location() #5
  %17 = load i32, ptr %16, align 4, !tbaa !5
  tail call void (i32, ptr, ptr, i32, ptr, ...) @_Z5pdLog7PDLEVELPKcS1_jS1_z(i32 noundef 1, ptr noundef nonnull @__func__._ZN10_ossSocketC2EPii, ptr noundef nonnull @.str, i32 noundef 76, ptr noundef nonnull @.str.1, i32 noundef %17)
  br label %18

18:                                               ; preds = %15, %12
  store i8 0, ptr %5, align 4, !tbaa !15
  br label %28

19:                                               ; preds = %3
  %20 = load i32, ptr %0, align 4, !tbaa !9
  %21 = tail call i32 @getpeername(i32 noundef %20, ptr noundef nonnull %8, ptr noundef nonnull %9) #4
  %22 = icmp ne i32 %21, 0
  %23 = load i32, ptr @_curPDLevel, align 4
  %24 = icmp sgt i32 %23, 0
  %or.cond = select i1 %22, i1 %24, i1 false
  br i1 %or.cond, label %25, label %28

25:                                               ; preds = %19
  %26 = tail call ptr @__errno_location() #5
  %27 = load i32, ptr %26, align 4, !tbaa !5
  tail call void (i32, ptr, ptr, i32, ptr, ...) @_Z5pdLog7PDLEVELPKcS1_jS1_z(i32 noundef 1, ptr noundef nonnull @__func__._ZN10_ossSocketC2EPii, ptr noundef nonnull @.str, i32 noundef 83, ptr noundef nonnull @.str.2, i32 noundef %27)
  br label %28

28:                                               ; preds = %25, %18, %19
  ret void
}

; Function Attrs: nounwind
declare i32 @getsockname(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

; Function Attrs: nounwind
declare i32 @getpeername(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #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 nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { 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 = { mustprogress nofree nosync nounwind willreturn memory(none) "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 willreturn memory(none) }

!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, !6, i64 0}
!10 = !{!"_ZTS10_ossSocket", !6, i64 0, !6, i64 4, !6, i64 8, !11, i64 12, !11, i64 28, !14, i64 44, !6, i64 48}
!11 = !{!"_ZTS11sockaddr_in", !12, i64 0, !12, i64 2, !13, i64 4, !7, i64 8}
!12 = !{!"short", !7, i64 0}
!13 = !{!"_ZTS7in_addr", !6, i64 0}
!14 = !{!"bool", !7, i64 0}
!15 = !{!10, !14, i64 44}
!16 = !{!10, !6, i64 48}
!17 = !{!10, !6, i64 4}
!18 = !{!10, !6, i64 8}
!19 = !{!20, !20, i64 0}
!20 = !{!"_ZTS7PDLEVEL", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass