; LLVM IR from CerebusOSS/CereLink :: Central/Instrument.ll (ZN10Instrument4OpenE15STARTUP_OPTIONSbbbi)

; 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.Instrument = type <{ ptr, %class.UDPSocket, [6 x %"class.Instrument::CachedPacket"], i32, i32, i32, [4 x i8], ptr, ptr, i32, [4 x i8] }>
%class.UDPSocket = type <{ ptr, i32, %struct.sockaddr_in, i32, i32, i8, i8, [2 x i8] }>
%struct.sockaddr_in = type { i16, i16, %struct.in_addr, [8 x i8] }
%struct.in_addr = type { i32 }
%"class.Instrument::CachedPacket" = type { i32, i32, i32, i32, i32, [2048 x i8], i32 }

@.str.2 = external hidden unnamed_addr constant [10 x i8], align 1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN10Instrument4OpenE15STARTUP_OPTIONSbbbi(ptr noundef nonnull align 8 dereferenceable(12516) %0, i32 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3, i1 noundef zeroext %4, i32 noundef %5) #0 align 2 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca i8, align 1
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca ptr, align 8
  %18 = alloca ptr, align 8
  %19 = alloca i8, align 1
  %20 = alloca i32, align 4
  store ptr %0, ptr %8, align 8, !tbaa !5
  store i32 %1, ptr %9, align 4, !tbaa !9
  %21 = zext i1 %2 to i8
  store i8 %21, ptr %10, align 1, !tbaa !11
  %22 = zext i1 %3 to i8
  store i8 %22, ptr %11, align 1, !tbaa !11
  %23 = zext i1 %4 to i8
  store i8 %23, ptr %12, align 1, !tbaa !11
  store i32 %5, ptr %13, align 4, !tbaa !13
  %24 = load ptr, ptr %8, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #3
  %25 = getelementptr inbounds %class.Instrument, ptr %24, i32 0, i32 9
  %26 = load i32, ptr %25, align 8, !tbaa !15
  store i32 %26, ptr %14, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #3
  %27 = getelementptr inbounds %class.Instrument, ptr %24, i32 0, i32 4
  %28 = load i32, ptr %27, align 4, !tbaa !21
  store i32 %28, ptr %15, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #3
  %29 = getelementptr inbounds %class.Instrument, ptr %24, i32 0, i32 5
  %30 = load i32, ptr %29, align 8, !tbaa !22
  store i32 %30, ptr %16, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #3
  %31 = getelementptr inbounds %class.Instrument, ptr %24, i32 0, i32 7
  %32 = load ptr, ptr %31, align 8, !tbaa !23
  store ptr %32, ptr %17, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #3
  %33 = getelementptr inbounds %class.Instrument, ptr %24, i32 0, i32 8
  %34 = load ptr, ptr %33, align 8, !tbaa !24
  store ptr %34, ptr %18, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %19) #3
  store i8 0, ptr %19, align 1, !tbaa !11
  %35 = load i32, ptr %9, align 4, !tbaa !9
  %36 = icmp eq i32 1, %35
  br i1 %36, label %40, label %37

37:                                               ; preds = %6
  %38 = load i32, ptr %9, align 4, !tbaa !9
  %39 = icmp eq i32 2, %38
  br i1 %39, label %40, label %41

40:                                               ; preds = %37, %6
  store i8 1, ptr %19, align 1, !tbaa !11
  store i32 130, ptr %14, align 4, !tbaa !13
  br label %41

41:                                               ; preds = %40, %37
  %42 = load i32, ptr %9, align 4, !tbaa !9
  %43 = icmp eq i32 3, %42
  br i1 %43, label %47, label %44

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

47:                                               ; preds = %44, %41
  store ptr @.str.2, ptr %17, align 8, !tbaa !5
  store ptr @.str.2, ptr %18, align 8, !tbaa !5
  store i32 51002, ptr %15, align 4, !tbaa !13
  store i32 51001, ptr %16, align 4, !tbaa !13
  br label %48

48:                                               ; preds = %47, %44
  %49 = getelementptr inbounds %class.Instrument, ptr %24, i32 0, i32 3
  %50 = load i32, ptr %49, align 8, !tbaa !25
  %51 = icmp eq i32 0, %50
  br i1 %51, label %52, label %71

52:                                               ; preds = %48
  %53 = getelementptr inbounds %class.Instrument, ptr %24, i32 0, i32 1
  %54 = load i32, ptr %9, align 4, !tbaa !9
  %55 = getelementptr inbounds %class.Instrument, ptr %24, i32 0, i32 9
  %56 = load i32, ptr %55, align 8, !tbaa !15
  %57 = load i8, ptr %19, align 1, !tbaa !11, !range !26, !noundef !27
  %58 = trunc i8 %57 to i1
  %59 = load ptr, ptr %17, align 8, !tbaa !5
  %60 = load ptr, ptr %18, align 8, !tbaa !5
  %61 = load i8, ptr %10, align 1, !tbaa !11, !range !26, !noundef !27
  %62 = trunc i8 %61 to i1
  %63 = load i8, ptr %11, align 1, !tbaa !11, !range !26, !noundef !27
  %64 = trunc i8 %63 to i1
  %65 = load i8, ptr %12, align 1, !tbaa !11, !range !26, !noundef !27
  %66 = trunc i8 %65 to i1
  %67 = load i32, ptr %13, align 4, !tbaa !13
  %68 = load i32, ptr %15, align 4, !tbaa !13
  %69 = load i32, ptr %16, align 4, !tbaa !13
  %70 = call noundef i32 @_ZN9UDPSocket7OpenUDPE15STARTUP_OPTIONSibPKcS2_bbbiiii(ptr noundef nonnull align 8 dereferenceable(38) %53, i32 noundef %54, i32 noundef %56, i1 noundef zeroext %58, ptr noundef %59, ptr noundef %60, i1 noundef zeroext %62, i1 noundef zeroext %64, i1 noundef zeroext %66, i32 noundef %67, i32 noundef %68, i32 noundef %69, i32 noundef 58080)
  store i32 %70, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %90

71:                                               ; preds = %48
  %72 = getelementptr inbounds %class.Instrument, ptr %24, i32 0, i32 1
  %73 = load i32, ptr %9, align 4, !tbaa !9
  %74 = getelementptr inbounds %class.Instrument, ptr %24, i32 0, i32 9
  %75 = load i32, ptr %74, align 8, !tbaa !15
  %76 = load i8, ptr %19, align 1, !tbaa !11, !range !26, !noundef !27
  %77 = trunc i8 %76 to i1
  %78 = load ptr, ptr %17, align 8, !tbaa !5
  %79 = load ptr, ptr %18, align 8, !tbaa !5
  %80 = load i8, ptr %10, align 1, !tbaa !11, !range !26, !noundef !27
  %81 = trunc i8 %80 to i1
  %82 = load i8, ptr %11, align 1, !tbaa !11, !range !26, !noundef !27
  %83 = trunc i8 %82 to i1
  %84 = load i8, ptr %12, align 1, !tbaa !11, !range !26, !noundef !27
  %85 = trunc i8 %84 to i1
  %86 = load i32, ptr %13, align 4, !tbaa !13
  %87 = load i32, ptr %15, align 4, !tbaa !13
  %88 = load i32, ptr %16, align 4, !tbaa !13
  %89 = call noundef i32 @_ZN9UDPSocket7OpenTCPE15STARTUP_OPTIONSibPKcS2_bbbiiii(ptr noundef nonnull align 8 dereferenceable(38) %72, i32 noundef %73, i32 noundef %75, i1 noundef zeroext %77, ptr noundef %78, ptr noundef %79, i1 noundef zeroext %81, i1 noundef zeroext %83, i1 noundef zeroext %85, i32 noundef %86, i32 noundef %87, i32 noundef %88, i32 noundef 58080)
  store i32 %89, ptr %7, align 4
  store i32 1, ptr %20, align 4
  br label %90

90:                                               ; preds = %71, %52
  call void @llvm.lifetime.end.p0(i64 1, ptr %19) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #3
  %91 = load i32, ptr %7, align 4
  ret i32 %91
}

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

declare noundef i32 @_ZN9UDPSocket7OpenUDPE15STARTUP_OPTIONSibPKcS2_bbbiiii(ptr noundef nonnull align 8 dereferenceable(38), i32 noundef, i32 noundef, i1 noundef zeroext, ptr noundef, ptr noundef, i1 noundef zeroext, i1 noundef zeroext, i1 noundef zeroext, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

declare noundef i32 @_ZN9UDPSocket7OpenTCPE15STARTUP_OPTIONSibPKcS2_bbbiiii(ptr noundef nonnull align 8 dereferenceable(38), i32 noundef, i32 noundef, i1 noundef zeroext, ptr noundef, ptr noundef, i1 noundef zeroext, i1 noundef zeroext, i1 noundef zeroext, i32 noundef, i32 noundef, i32 noundef, i32 noundef) #2

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

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

!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 = !{!"_ZTS15STARTUP_OPTIONS", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"bool", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !14, i64 12512}
!16 = !{!"_ZTS10Instrument", !17, i64 8, !7, i64 48, !14, i64 12480, !14, i64 12484, !14, i64 12488, !6, i64 12496, !6, i64 12504, !14, i64 12512}
!17 = !{!"_ZTS9UDPSocket", !14, i64 8, !18, i64 12, !10, i64 28, !14, i64 32, !12, i64 36, !12, i64 37}
!18 = !{!"_ZTS11sockaddr_in", !19, i64 0, !19, i64 2, !20, i64 4, !7, i64 8}
!19 = !{!"short", !7, i64 0}
!20 = !{!"_ZTS7in_addr", !14, i64 0}
!21 = !{!16, !14, i64 12484}
!22 = !{!16, !14, i64 12488}
!23 = !{!16, !6, i64 12496}
!24 = !{!16, !6, i64 12504}
!25 = !{!16, !14, i64 12480}
!26 = !{i8 0, i8 2}
!27 = !{}


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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN10Instrument4OpenE15STARTUP_OPTIONSbbbi(ptr noundef nonnull align 8 dereferenceable(12516) %0, i32 noundef %1, i1 noundef zeroext %2, i1 noundef zeroext %3, i1 noundef zeroext %4, i32 noundef %5) local_unnamed_addr #0 align 2 {
  %7 = getelementptr inbounds i8, ptr %0, i64 12512
  %8 = getelementptr inbounds i8, ptr %0, i64 12484
  %9 = load i32, ptr %8, align 4, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 12488
  %11 = load i32, ptr %10, align 8, !tbaa !17
  %12 = getelementptr inbounds i8, ptr %0, i64 12496
  %13 = load ptr, ptr %12, align 8, !tbaa !18
  %14 = getelementptr inbounds i8, ptr %0, i64 12504
  %15 = load ptr, ptr %14, align 8, !tbaa !19
  %16 = add i32 %1, -1
  %or.cond = icmp ult i32 %16, 2
  %17 = and i32 %1, -2
  %or.cond3 = icmp eq i32 %17, 2
  br i1 %or.cond3, label %18, label %19

18:                                               ; preds = %6
  br label %19

19:                                               ; preds = %6, %18
  %.031 = phi i32 [ 51002, %18 ], [ %9, %6 ]
  %.030 = phi i32 [ 51001, %18 ], [ %11, %6 ]
  %.029 = phi ptr [ @.str.2, %18 ], [ %13, %6 ]
  %.028 = phi ptr [ @.str.2, %18 ], [ %15, %6 ]
  %20 = getelementptr inbounds i8, ptr %0, i64 12480
  %21 = load i32, ptr %20, align 8, !tbaa !20
  %22 = icmp eq i32 %21, 0
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  %24 = load i32, ptr %7, align 8, !tbaa !21
  br i1 %22, label %25, label %27

25:                                               ; preds = %19
  %26 = tail call noundef i32 @_ZN9UDPSocket7OpenUDPE15STARTUP_OPTIONSibPKcS2_bbbiiii(ptr noundef nonnull align 8 dereferenceable(38) %23, i32 noundef %1, i32 noundef %24, i1 noundef zeroext %or.cond, ptr noundef %.029, ptr noundef %.028, i1 noundef zeroext %2, i1 noundef zeroext %3, i1 noundef zeroext %4, i32 noundef %5, i32 noundef %.031, i32 noundef %.030, i32 noundef 58080)
  br label %29

27:                                               ; preds = %19
  %28 = tail call noundef i32 @_ZN9UDPSocket7OpenTCPE15STARTUP_OPTIONSibPKcS2_bbbiiii(ptr noundef nonnull align 8 dereferenceable(38) %23, i32 noundef %1, i32 noundef %24, i1 noundef zeroext %or.cond, ptr noundef %.029, ptr noundef %.028, i1 noundef zeroext %2, i1 noundef zeroext %3, i1 noundef zeroext %4, i32 noundef %5, i32 noundef %.031, i32 noundef %.030, i32 noundef 58080)
  br label %29

29:                                               ; preds = %27, %25
  %.032 = phi i32 [ %26, %25 ], [ %28, %27 ]
  ret i32 %.032
}

declare noundef i32 @_ZN9UDPSocket7OpenUDPE15STARTUP_OPTIONSibPKcS2_bbbiiii(ptr noundef nonnull align 8 dereferenceable(38), i32 noundef, i32 noundef, i1 noundef zeroext, ptr noundef, ptr noundef, i1 noundef zeroext, i1 noundef zeroext, i1 noundef zeroext, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

declare noundef i32 @_ZN9UDPSocket7OpenTCPE15STARTUP_OPTIONSibPKcS2_bbbiiii(ptr noundef nonnull align 8 dereferenceable(38), i32 noundef, i32 noundef, i1 noundef zeroext, ptr noundef, ptr noundef, i1 noundef zeroext, i1 noundef zeroext, i1 noundef zeroext, i32 noundef, i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { 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 #1 = { "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" }

!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, !8, i64 12484}
!6 = !{!"_ZTS10Instrument", !7, i64 8, !9, i64 48, !8, i64 12480, !8, i64 12484, !8, i64 12488, !16, i64 12496, !16, i64 12504, !8, i64 12512}
!7 = !{!"_ZTS9UDPSocket", !8, i64 8, !11, i64 12, !14, i64 28, !8, i64 32, !15, i64 36, !15, i64 37}
!8 = !{!"int", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS11sockaddr_in", !12, i64 0, !12, i64 2, !13, i64 4, !9, i64 8}
!12 = !{!"short", !9, i64 0}
!13 = !{!"_ZTS7in_addr", !8, i64 0}
!14 = !{!"_ZTS15STARTUP_OPTIONS", !9, i64 0}
!15 = !{!"bool", !9, i64 0}
!16 = !{!"any pointer", !9, i64 0}
!17 = !{!6, !8, i64 12488}
!18 = !{!6, !16, i64 12496}
!19 = !{!6, !16, i64 12504}
!20 = !{!6, !8, i64 12480}
!21 = !{!6, !8, i64 12512}


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