; LLVM IR from onnx/onnx-mlir :: src/Runtime (OMInstrument)

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

@fout = external hidden global ptr, align 8
@.str.3 = external hidden unnamed_addr constant [77 x i8], align 1
@instrumentReportTimeDisabled = external hidden global i8, align 1
@instrumentReportMemoryDisabled = external hidden global i8, align 1
@instrumentReportDisabled = external hidden global i8, align 1
@.str.8 = external hidden unnamed_addr constant [21 x i8], align 1
@instrumentCounter = external hidden global i32, align 4
@.str.9 = external hidden unnamed_addr constant [81 x i8], align 1
@__PRETTY_FUNCTION__.OMInstrumentPoint = external hidden unnamed_addr constant [60 x i8], align 1
@instrumentReportOpName = external hidden global [64 x i8], align 16
@instrumentReportNodeName = external hidden global [512 x i8], align 16
@psErrorCount = external hidden global i32, align 4
@.str.10 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [6 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @OMInstrumentInit() #2

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

; Function Attrs: nounwind uwtable
define dso_local void @OMInstrumentPoint(ptr noundef %0, i64 noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca i64, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i8, align 1
  %9 = alloca i8, align 1
  %10 = alloca i8, align 1
  %11 = alloca i8, align 1
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  store ptr %0, ptr %4, align 8, !tbaa !5
  store i64 %1, ptr %5, align 8, !tbaa !9
  store ptr %2, ptr %6, align 8, !tbaa !5
  %15 = load i8, ptr @instrumentReportDisabled, align 1, !tbaa !11, !range !13, !noundef !14
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %18

17:                                               ; preds = %3
  br label %107

18:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %19 = load i64, ptr %5, align 8, !tbaa !9
  store i64 %19, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %8) #4
  %20 = load i64, ptr %7, align 8, !tbaa !9
  %21 = and i64 %20, 16
  %22 = icmp ne i64 %21, 0
  %23 = zext i1 %22 to i8
  store i8 %23, ptr %8, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %9) #4
  %24 = load i64, ptr %7, align 8, !tbaa !9
  %25 = and i64 %24, 1
  %26 = icmp ne i64 %25, 0
  %27 = zext i1 %26 to i8
  store i8 %27, ptr %9, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %10) #4
  %28 = load i8, ptr @instrumentReportTimeDisabled, align 1, !tbaa !11, !range !13, !noundef !14
  %29 = trunc i8 %28 to i1
  br i1 %29, label %34, label %30

30:                                               ; preds = %18
  %31 = load i64, ptr %7, align 8, !tbaa !9
  %32 = and i64 %31, 4
  %33 = icmp ne i64 %32, 0
  br label %34

34:                                               ; preds = %30, %18
  %35 = phi i1 [ false, %18 ], [ %33, %30 ]
  %36 = zext i1 %35 to i8
  store i8 %36, ptr %10, align 1, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 1, ptr %11) #4
  %37 = load i8, ptr @instrumentReportMemoryDisabled, align 1, !tbaa !11, !range !13, !noundef !14
  %38 = trunc i8 %37 to i1
  br i1 %38, label %43, label %39

39:                                               ; preds = %34
  %40 = load i64, ptr %7, align 8, !tbaa !9
  %41 = and i64 %40, 8
  %42 = icmp ne i64 %41, 0
  br label %43

43:                                               ; preds = %39, %34
  %44 = phi i1 [ false, %34 ], [ %42, %39 ]
  %45 = zext i1 %44 to i8
  store i8 %45, ptr %11, align 1, !tbaa !11
  %46 = load i8, ptr %8, align 1, !tbaa !11, !range !13, !noundef !14
  %47 = trunc i8 %46 to i1
  br i1 %47, label %48, label %49

48:                                               ; preds = %43
  call void @OMInstrumentInit()
  br label %49

49:                                               ; preds = %48, %43
  %50 = load i8, ptr %10, align 1, !tbaa !11, !range !13, !noundef !14
  %51 = trunc i8 %50 to i1
  br i1 %51, label %60, label %52

52:                                               ; preds = %49
  %53 = load i8, ptr %11, align 1, !tbaa !11, !range !13, !noundef !14
  %54 = trunc i8 %53 to i1
  br i1 %54, label %60, label %55

55:                                               ; preds = %52
  %56 = load ptr, ptr @fout, align 8, !tbaa !5
  %57 = load i32, ptr @instrumentCounter, align 4, !tbaa !15
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr @instrumentCounter, align 4, !tbaa !15
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %56, ptr noundef @.str.8, i32 noundef %57) #4
  store i32 1, ptr %12, align 4
  br label %105

60:                                               ; preds = %52, %49
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  %61 = load i64, ptr %7, align 8, !tbaa !9
  %62 = lshr i64 %61, 8
  %63 = and i64 %62, 63
  store i64 %63, ptr %13, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  %64 = load i64, ptr %7, align 8, !tbaa !9
  %65 = lshr i64 %64, 24
  %66 = and i64 %65, 511
  store i64 %66, ptr %14, align 8, !tbaa !9
  %67 = load i64, ptr %13, align 8, !tbaa !9
  %68 = icmp ule i64 %67, 63
  br i1 %68, label %69, label %73

69:                                               ; preds = %60
  %70 = load i64, ptr %14, align 8, !tbaa !9
  %71 = icmp ule i64 %70, 511
  br i1 %71, label %72, label %73

72:                                               ; preds = %69
  br label %74

73:                                               ; preds = %69, %60
  call void @__assert_fail(ptr noundef @.str.9, ptr noundef @.str.3, i32 noundef 242, ptr noundef @__PRETTY_FUNCTION__.OMInstrumentPoint) #5
  unreachable

74:                                               ; preds = %72
  %75 = load ptr, ptr %4, align 8, !tbaa !5
  %76 = load i64, ptr %13, align 8, !tbaa !9
  %77 = call ptr @strncpy(ptr noundef @instrumentReportOpName, ptr noundef %75, i64 noundef %76) #4
  %78 = load i64, ptr %13, align 8, !tbaa !9
  %79 = getelementptr inbounds [64 x i8], ptr @instrumentReportOpName, i64 0, i64 %78
  store i8 0, ptr %79, align 1, !tbaa !17
  %80 = load ptr, ptr %6, align 8, !tbaa !5
  %81 = load i64, ptr %14, align 8, !tbaa !9
  %82 = call ptr @strncpy(ptr noundef @instrumentReportNodeName, ptr noundef %80, i64 noundef %81) #4
  %83 = load i64, ptr %14, align 8, !tbaa !9
  %84 = getelementptr inbounds [512 x i8], ptr @instrumentReportNodeName, i64 0, i64 %83
  store i8 0, ptr %84, align 1, !tbaa !17
  %85 = load i8, ptr %10, align 1, !tbaa !11, !range !13, !noundef !14
  %86 = trunc i8 %85 to i1
  br i1 %86, label %87, label %91

87:                                               ; preds = %74
  %88 = load i8, ptr %9, align 1, !tbaa !11, !range !13, !noundef !14
  %89 = trunc i8 %88 to i1
  %90 = zext i1 %89 to i32
  call void @ReportTime(ptr noundef @instrumentReportOpName, ptr noundef @instrumentReportNodeName, i32 noundef %90)
  br label %91

91:                                               ; preds = %87, %74
  %92 = load i8, ptr %11, align 1, !tbaa !11, !range !13, !noundef !14
  %93 = trunc i8 %92 to i1
  br i1 %93, label %94, label %104

94:                                               ; preds = %91
  %95 = load i32, ptr @psErrorCount, align 4, !tbaa !15
  %96 = icmp slt i32 %95, 20
  br i1 %96, label %97, label %104

97:                                               ; preds = %94
  %98 = load ptr, ptr @fout, align 8, !tbaa !5
  %99 = load i8, ptr %9, align 1, !tbaa !11, !range !13, !noundef !14
  %100 = trunc i8 %99 to i1
  %101 = zext i1 %100 to i64
  %102 = select i1 %100, ptr @.str.11, ptr @.str.12
  %103 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %98, ptr noundef @.str.10, ptr noundef @instrumentReportOpName, ptr noundef @instrumentReportNodeName, ptr noundef %102) #4
  call void @ReportMemory()
  br label %104

104:                                              ; preds = %97, %94, %91
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  store i32 0, ptr %12, align 4
  br label %105

105:                                              ; preds = %104, %55
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  %106 = load i32, ptr %12, align 4
  switch i32 %106, label %108 [
    i32 0, label %107
    i32 1, label %107
  ]

107:                                              ; preds = %105, %105, %17
  ret void

108:                                              ; preds = %105
  unreachable
}

; Function Attrs: nounwind
declare ptr @strncpy(ptr noundef, ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @ReportTime(ptr noundef, ptr noundef, i32 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @ReportMemory() #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #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 = { 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 }
attributes #5 = { noreturn 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!16, !16, i64 0}
!16 = !{!"int", !7, i64 0}
!17 = !{!7, !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"

@fout = external hidden local_unnamed_addr global ptr, align 8
@instrumentReportTimeDisabled = external hidden local_unnamed_addr global i8, align 1
@instrumentReportMemoryDisabled = external hidden local_unnamed_addr global i8, align 1
@instrumentReportDisabled = external hidden local_unnamed_addr global i8, align 1
@.str.8 = external hidden unnamed_addr constant [21 x i8], align 1
@instrumentCounter = external hidden local_unnamed_addr global i32, align 4
@instrumentReportOpName = external hidden global [64 x i8], align 16
@instrumentReportNodeName = external hidden global [512 x i8], align 16
@psErrorCount = external hidden local_unnamed_addr global i32, align 4
@.str.10 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @OMInstrumentInit() local_unnamed_addr #0

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @OMInstrumentPoint(ptr nocapture noundef readonly %0, i64 noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = load i8, ptr @instrumentReportDisabled, align 1, !tbaa !5, !range !9, !noundef !10
  %5 = trunc nuw i8 %4 to i1
  br i1 %5, label %43, label %6

6:                                                ; preds = %3
  %7 = and i64 %1, 16
  %.not = icmp eq i64 %7, 0
  %8 = and i64 %1, 1
  %.not26 = icmp eq i64 %8, 0
  %9 = load i8, ptr @instrumentReportTimeDisabled, align 1, !tbaa !5, !range !9, !noundef !10
  %10 = trunc nuw i8 %9 to i1
  %11 = and i64 %1, 4
  %12 = icmp eq i64 %11, 0
  %.not25 = or i1 %12, %10
  %13 = load i8, ptr @instrumentReportMemoryDisabled, align 1, !tbaa !5, !range !9, !noundef !10
  %14 = trunc nuw i8 %13 to i1
  %15 = and i64 %1, 8
  %16 = icmp ne i64 %15, 0
  %not. = xor i1 %14, true
  %17 = and i1 %16, %not.
  br i1 %.not, label %19, label %18

18:                                               ; preds = %6
  tail call void @OMInstrumentInit()
  br label %19

19:                                               ; preds = %18, %6
  %.not25.not = xor i1 %.not25, true
  %brmerge = select i1 %.not25.not, i1 true, i1 %17
  br i1 %brmerge, label %25, label %20

20:                                               ; preds = %19
  %21 = load ptr, ptr @fout, align 8, !tbaa !11
  %22 = load i32, ptr @instrumentCounter, align 4, !tbaa !13
  %23 = add nsw i32 %22, 1
  store i32 %23, ptr @instrumentCounter, align 4, !tbaa !13
  %24 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef nonnull @.str.8, i32 noundef %22) #3
  br label %43

25:                                               ; preds = %19
  %26 = lshr i64 %1, 24
  %27 = and i64 %26, 511
  %28 = lshr i64 %1, 8
  %29 = and i64 %28, 63
  %30 = tail call ptr @strncpy(ptr noundef nonnull @instrumentReportOpName, ptr noundef %0, i64 noundef %29) #3
  %31 = getelementptr inbounds [64 x i8], ptr @instrumentReportOpName, i64 0, i64 %29
  store i8 0, ptr %31, align 1, !tbaa !15
  %32 = tail call ptr @strncpy(ptr noundef nonnull @instrumentReportNodeName, ptr noundef %2, i64 noundef %27) #3
  %33 = getelementptr inbounds [512 x i8], ptr @instrumentReportNodeName, i64 0, i64 %27
  store i8 0, ptr %33, align 1, !tbaa !15
  br i1 %.not25, label %36, label %34

34:                                               ; preds = %25
  %35 = trunc nuw nsw i64 %8 to i32
  tail call void @ReportTime(ptr noundef nonnull @instrumentReportOpName, ptr noundef nonnull @instrumentReportNodeName, i32 noundef %35)
  br label %36

36:                                               ; preds = %34, %25
  %37 = load i32, ptr @psErrorCount, align 4
  %38 = icmp slt i32 %37, 20
  %or.cond3 = select i1 %17, i1 %38, i1 false
  br i1 %or.cond3, label %39, label %43

39:                                               ; preds = %36
  %40 = load ptr, ptr @fout, align 8, !tbaa !11
  %41 = select i1 %.not26, ptr @.str.12, ptr @.str.11
  %42 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %40, ptr noundef nonnull @.str.10, ptr noundef nonnull @instrumentReportOpName, ptr noundef nonnull @instrumentReportNodeName, ptr noundef nonnull %41) #3
  tail call void @ReportMemory()
  br label %43

43:                                               ; preds = %20, %39, %36, %3
  ret void
}

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite)
declare ptr @strncpy(ptr noalias noundef returned writeonly, ptr noalias nocapture noundef readonly, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @ReportTime(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden void @ReportMemory() local_unnamed_addr #0

attributes #0 = { 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 = { nofree 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 #2 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite) "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 = !{!"_Bool", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{i8 0, i8 2}
!10 = !{}
!11 = !{!12, !12, i64 0}
!12 = !{!"any pointer", !7, i64 0}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!7, !7, i64 0}


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