; LLVM IR from interpretml/interpret :: shared/libebm (DetermineLinkFunction)

; 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.ObjectiveWrapper = type { ptr, ptr, ptr, ptr, i32, i32, i32, double, double, double, double, double, double, double, double, i32, i64, i64, i64, i32, ptr }
%struct.Config = type { i64, i32 }

@g_traceLevel = external global i32, align 4
@_ZZ13DetermineTaskE13LOG__sMessage = external hidden constant [48 x i8], align 16
@_ZZ13DetermineTaskE13LOG__sMessage_0 = external hidden constant [40 x i8], align 16
@_ZZ13DetermineTaskE13LOG__sMessage_1 = external hidden constant [21 x i8], align 16

; Function Attrs: mustprogress uwtable
define dso_local i32 @DetermineTask(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %7 = alloca %struct.ObjectiveWrapper, align 8
  %8 = alloca %struct.Config, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  br label %13

13:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #6
  store i32 3, ptr %6, align 4, !tbaa !9
  %14 = load i32, ptr @g_traceLevel, align 4, !tbaa !9
  %15 = icmp sle i32 3, %14
  br i1 %15, label %16, label %19

16:                                               ; preds = %13
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  call void (i32, ptr, ...) @InteralLogWithArguments(i32 noundef 3, ptr noundef @_ZZ13DetermineTaskE13LOG__sMessage, ptr noundef %17, ptr noundef %18)
  br label %19

19:                                               ; preds = %16, %13
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #6
  br label %20

20:                                               ; preds = %19
  call void @llvm.lifetime.start.p0(i64 160, ptr %7) #6
  call void @_ZL35InitializeObjectiveWrapperUnfailingP16ObjectiveWrapper(ptr noundef %7)
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #6
  %21 = getelementptr inbounds %struct.Config, ptr %8, i32 0, i32 0
  store i64 1, ptr %21, align 8, !tbaa !11
  %22 = getelementptr inbounds %struct.Config, ptr %8, i32 0, i32 1
  store i32 0, ptr %22, align 8, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #6
  %23 = load ptr, ptr %4, align 8, !tbaa !5
  %24 = call noundef i32 @_ZN14NAMESPACE_MAIN12GetObjectiveEPK6ConfigPKciP16ObjectiveWrapperS6_(ptr noundef %8, ptr noundef %23, i32 noundef 0, ptr noundef %7, ptr noundef null) #6
  store i32 %24, ptr %9, align 4, !tbaa !9
  %25 = load i32, ptr %9, align 4, !tbaa !9
  %26 = icmp ne i32 0, %25
  br i1 %26, label %27, label %41

27:                                               ; preds = %20
  br label %28

28:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  store i32 1, ptr %10, align 4, !tbaa !9
  %29 = load i32, ptr @g_traceLevel, align 4, !tbaa !9
  %30 = icmp sle i32 1, %29
  br i1 %30, label %31, label %32

31:                                               ; preds = %28
  call void @InteralLogWithoutArguments(i32 noundef 1, ptr noundef @_ZZ13DetermineTaskE13LOG__sMessage_0)
  br label %32

32:                                               ; preds = %31, %28
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  br label %33

33:                                               ; preds = %32
  br label %34

34:                                               ; preds = %33
  %35 = load ptr, ptr %5, align 8, !tbaa !5
  %36 = icmp ne ptr null, %35
  br i1 %36, label %37, label %39

37:                                               ; preds = %34
  %38 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 -1, ptr %38, align 8, !tbaa !15
  br label %39

39:                                               ; preds = %37, %34
  %40 = load i32, ptr %9, align 4, !tbaa !9
  store i32 %40, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %57

41:                                               ; preds = %20
  call void @_ZL29FreeObjectiveWrapperInternalsP16ObjectiveWrapper(ptr noundef %7)
  %42 = load ptr, ptr %5, align 8, !tbaa !5
  %43 = icmp ne ptr null, %42
  br i1 %43, label %44, label %49

44:                                               ; preds = %41
  %45 = getelementptr inbounds %struct.ObjectiveWrapper, ptr %7, i32 0, i32 6
  %46 = load i32, ptr %45, align 8, !tbaa !16
  %47 = call noundef i64 @_ZN14NAMESPACE_MAINL12IdentifyTaskEi(i32 noundef %46) #6
  %48 = load ptr, ptr %5, align 8, !tbaa !5
  store i64 %47, ptr %48, align 8, !tbaa !15
  br label %49

49:                                               ; preds = %44, %41
  br label %50

50:                                               ; preds = %49
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 3, ptr %12, align 4, !tbaa !9
  %51 = load i32, ptr @g_traceLevel, align 4, !tbaa !9
  %52 = icmp sle i32 3, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef @_ZZ13DetermineTaskE13LOG__sMessage_1)
  br label %54

54:                                               ; preds = %53, %50
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  br label %55

55:                                               ; preds = %54
  br label %56

56:                                               ; preds = %55
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %57

57:                                               ; preds = %56, %39
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #6
  call void @llvm.lifetime.end.p0(i64 160, ptr %7) #6
  %58 = load i32, ptr %3, align 4
  ret i32 %58
}

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

declare void @InteralLogWithArguments(i32 noundef, ptr noundef, ...) #2

; 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 void @_ZL35InitializeObjectiveWrapperUnfailingP16ObjectiveWrapper(ptr noundef) #3

; Function Attrs: nounwind
declare noundef i32 @_ZN14NAMESPACE_MAIN12GetObjectiveEPK6ConfigPKciP16ObjectiveWrapperS6_(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) #4

declare void @InteralLogWithoutArguments(i32 noundef, ptr noundef) #2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @_ZL29FreeObjectiveWrapperInternalsP16ObjectiveWrapper(ptr noundef) #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN14NAMESPACE_MAINL12IdentifyTaskEi(i32 noundef) #3

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 = { 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 #4 = { 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 #5 = { inlinehint 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 #6 = { 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, !13, i64 0}
!12 = !{!"_ZTS6Config", !13, i64 0, !10, i64 8}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!13, !13, i64 0}
!16 = !{!17, !10, i64 40}
!17 = !{!"_ZTS16ObjectiveWrapper", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !10, i64 32, !10, i64 36, !10, i64 40, !18, i64 48, !18, i64 56, !18, i64 64, !18, i64 72, !18, i64 80, !18, i64 88, !18, i64 96, !18, i64 104, !10, i64 112, !13, i64 120, !13, i64 128, !13, i64 136, !10, i64 144, !6, i64 152}
!18 = !{!"double", !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"

%struct.ObjectiveWrapper = type { ptr, ptr, ptr, ptr, i32, i32, i32, double, double, double, double, double, double, double, double, i32, i64, i64, i64, i32, ptr }
%struct.Config = type { i64, i32 }

@g_traceLevel = external local_unnamed_addr global i32, align 4
@_ZZ13DetermineTaskE13LOG__sMessage = external hidden constant [48 x i8], align 16
@_ZZ13DetermineTaskE13LOG__sMessage_0 = external hidden constant [40 x i8], align 16
@_ZZ13DetermineTaskE13LOG__sMessage_1 = external hidden constant [21 x i8], align 16

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @DetermineTask(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca %struct.ObjectiveWrapper, align 8
  %4 = alloca %struct.Config, align 8
  %5 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %6 = icmp sgt i32 %5, 2
  br i1 %6, label %7, label %8

7:                                                ; preds = %2
  tail call void (i32, ptr, ...) @InteralLogWithArguments(i32 noundef 3, ptr noundef nonnull @_ZZ13DetermineTaskE13LOG__sMessage, ptr noundef %0, ptr noundef %1)
  br label %8

8:                                                ; preds = %7, %2
  call void @llvm.lifetime.start.p0(i64 160, ptr nonnull %3) #6
  call void @_ZL35InitializeObjectiveWrapperUnfailingP16ObjectiveWrapper(ptr noundef nonnull %3)
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #6
  store i64 1, ptr %4, align 8, !tbaa !9
  %9 = getelementptr inbounds i8, ptr %4, i64 8
  store i32 0, ptr %9, align 8, !tbaa !12
  %10 = call noundef i32 @_ZN14NAMESPACE_MAIN12GetObjectiveEPK6ConfigPKciP16ObjectiveWrapperS6_(ptr noundef nonnull %4, ptr noundef %0, i32 noundef 0, ptr noundef nonnull %3, ptr noundef null) #6
  %.not = icmp eq i32 %10, 0
  br i1 %.not, label %17, label %11

11:                                               ; preds = %8
  %12 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %13 = icmp sgt i32 %12, 0
  br i1 %13, label %14, label %15

14:                                               ; preds = %11
  call void @InteralLogWithoutArguments(i32 noundef 1, ptr noundef nonnull @_ZZ13DetermineTaskE13LOG__sMessage_0)
  br label %15

15:                                               ; preds = %14, %11
  %.not12 = icmp eq ptr %1, null
  br i1 %.not12, label %26, label %16

16:                                               ; preds = %15
  store i64 -1, ptr %1, align 8, !tbaa !13
  br label %26

17:                                               ; preds = %8
  call void @_ZL29FreeObjectiveWrapperInternalsP16ObjectiveWrapper(ptr noundef nonnull %3)
  %.not11 = icmp eq ptr %1, null
  br i1 %.not11, label %22, label %18

18:                                               ; preds = %17
  %19 = getelementptr inbounds i8, ptr %3, i64 40
  %20 = load i32, ptr %19, align 8, !tbaa !14
  %21 = call noundef i64 @_ZN14NAMESPACE_MAINL12IdentifyTaskEi(i32 noundef %20) #6
  store i64 %21, ptr %1, align 8, !tbaa !13
  br label %22

22:                                               ; preds = %17, %18
  %23 = load i32, ptr @g_traceLevel, align 4, !tbaa !5
  %24 = icmp sgt i32 %23, 2
  br i1 %24, label %25, label %26

25:                                               ; preds = %22
  call void @InteralLogWithoutArguments(i32 noundef 3, ptr noundef nonnull @_ZZ13DetermineTaskE13LOG__sMessage_1)
  br label %26

26:                                               ; preds = %22, %25, %15, %16
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #6
  call void @llvm.lifetime.end.p0(i64 160, ptr nonnull %3) #6
  ret i32 %10
}

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

declare void @InteralLogWithArguments(i32 noundef, ptr noundef, ...) local_unnamed_addr #2

; 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 void @_ZL35InitializeObjectiveWrapperUnfailingP16ObjectiveWrapper(ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind
declare noundef i32 @_ZN14NAMESPACE_MAIN12GetObjectiveEPK6ConfigPKciP16ObjectiveWrapperS6_(ptr noundef, ptr noundef, i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #4

declare void @InteralLogWithoutArguments(i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress uwtable
declare hidden void @_ZL29FreeObjectiveWrapperInternalsP16ObjectiveWrapper(ptr noundef) local_unnamed_addr #5

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare hidden noundef i64 @_ZN14NAMESPACE_MAINL12IdentifyTaskEi(i32 noundef) local_unnamed_addr #3

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 = { mustprogress 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 = { 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 #4 = { 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 #5 = { inlinehint 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 #6 = { 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, !11, i64 0}
!10 = !{!"_ZTS6Config", !11, i64 0, !6, i64 8}
!11 = !{!"long", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{!11, !11, i64 0}
!14 = !{!15, !6, i64 40}
!15 = !{!"_ZTS16ObjectiveWrapper", !16, i64 0, !16, i64 8, !16, i64 16, !16, i64 24, !6, i64 32, !6, i64 36, !6, i64 40, !17, i64 48, !17, i64 56, !17, i64 64, !17, i64 72, !17, i64 80, !17, i64 88, !17, i64 96, !17, i64 104, !6, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !6, i64 144, !16, i64 152}
!16 = !{!"any pointer", !7, i64 0}
!17 = !{!"double", !7, i64 0}


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