; LLVM IR from mrbid/CSGO_TENSOR_TRIGGER :: GOBOT15/KERAS2C/include (k2c_convolution_layers)

; 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.k2c_tensor = type { ptr, i64, i64, [5 x i64] }

; 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: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #1

declare i64 @k2c_sub2idx(ptr noundef, ptr noundef, i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @k2c_upsampling3d(ptr noundef %0, ptr noundef %1, ptr noundef %2) #3 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i64, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca i64, align 8
  %11 = alloca i64, align 8
  %12 = alloca i32, align 4
  %13 = alloca i64, align 8
  %14 = alloca i64, align 8
  %15 = alloca [5 x i64], align 16
  %16 = alloca [5 x i64], align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.k2c_tensor, ptr %17, i32 0, i32 3
  %19 = getelementptr inbounds [5 x i64], ptr %18, i64 0, i64 0
  %20 = load i64, ptr %19, align 8, !tbaa !9
  store i64 %20, ptr %7, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.k2c_tensor, ptr %21, i32 0, i32 3
  %23 = getelementptr inbounds [5 x i64], ptr %22, i64 0, i64 1
  %24 = load i64, ptr %23, align 8, !tbaa !9
  store i64 %24, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  %26 = getelementptr inbounds %struct.k2c_tensor, ptr %25, i32 0, i32 3
  %27 = getelementptr inbounds [5 x i64], ptr %26, i64 0, i64 2
  %28 = load i64, ptr %27, align 8, !tbaa !9
  store i64 %28, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %29 = load ptr, ptr %5, align 8, !tbaa !5
  %30 = getelementptr inbounds %struct.k2c_tensor, ptr %29, i32 0, i32 3
  %31 = getelementptr inbounds [5 x i64], ptr %30, i64 0, i64 3
  %32 = load i64, ptr %31, align 8, !tbaa !9
  store i64 %32, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #4
  store i64 0, ptr %11, align 8, !tbaa !9
  br label %33

33:                                               ; preds = %123, %3
  %34 = load i64, ptr %11, align 8, !tbaa !9
  %35 = load i64, ptr %7, align 8, !tbaa !9
  %36 = icmp ult i64 %34, %35
  br i1 %36, label %38, label %37

37:                                               ; preds = %33
  store i32 2, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #4
  br label %126

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #4
  store i64 0, ptr %13, align 8, !tbaa !9
  br label %39

39:                                               ; preds = %119, %38
  %40 = load i64, ptr %13, align 8, !tbaa !9
  %41 = load i64, ptr %8, align 8, !tbaa !9
  %42 = icmp ult i64 %40, %41
  br i1 %42, label %44, label %43

43:                                               ; preds = %39
  store i32 5, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #4
  br label %122

44:                                               ; preds = %39
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #4
  store i64 0, ptr %14, align 8, !tbaa !9
  br label %45

45:                                               ; preds = %115, %44
  %46 = load i64, ptr %14, align 8, !tbaa !9
  %47 = load i64, ptr %9, align 8, !tbaa !9
  %48 = icmp ult i64 %46, %47
  br i1 %48, label %50, label %49

49:                                               ; preds = %45
  store i32 8, ptr %12, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #4
  br label %118

50:                                               ; preds = %45
  call void @llvm.lifetime.start.p0(i64 40, ptr %15) #4
  %51 = load i64, ptr %11, align 8, !tbaa !9
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  %53 = getelementptr inbounds i64, ptr %52, i64 0
  %54 = load i64, ptr %53, align 8, !tbaa !9
  %55 = udiv i64 %51, %54
  store i64 %55, ptr %15, align 8, !tbaa !9
  %56 = getelementptr inbounds i64, ptr %15, i64 1
  %57 = load i64, ptr %13, align 8, !tbaa !9
  %58 = load ptr, ptr %6, align 8, !tbaa !5
  %59 = getelementptr inbounds i64, ptr %58, i64 1
  %60 = load i64, ptr %59, align 8, !tbaa !9
  %61 = udiv i64 %57, %60
  store i64 %61, ptr %56, align 8, !tbaa !9
  %62 = getelementptr inbounds i64, ptr %15, i64 2
  %63 = load i64, ptr %14, align 8, !tbaa !9
  %64 = load ptr, ptr %6, align 8, !tbaa !5
  %65 = getelementptr inbounds i64, ptr %64, i64 2
  %66 = load i64, ptr %65, align 8, !tbaa !9
  %67 = udiv i64 %63, %66
  store i64 %67, ptr %62, align 8, !tbaa !9
  %68 = getelementptr inbounds i64, ptr %15, i64 3
  store i64 0, ptr %68, align 8, !tbaa !9
  %69 = getelementptr inbounds i64, ptr %15, i64 4
  %70 = getelementptr inbounds i64, ptr %15, i64 5
  br label %71

71:                                               ; preds = %71, %50
  %72 = phi ptr [ %69, %50 ], [ %73, %71 ]
  store i64 0, ptr %72, align 8, !tbaa !9
  %73 = getelementptr inbounds i64, ptr %72, i64 1
  %74 = icmp eq ptr %73, %70
  br i1 %74, label %75, label %71

75:                                               ; preds = %71
  call void @llvm.lifetime.start.p0(i64 40, ptr %16) #4
  %76 = load i64, ptr %11, align 8, !tbaa !9
  store i64 %76, ptr %16, align 8, !tbaa !9
  %77 = getelementptr inbounds i64, ptr %16, i64 1
  %78 = load i64, ptr %13, align 8, !tbaa !9
  store i64 %78, ptr %77, align 8, !tbaa !9
  %79 = getelementptr inbounds i64, ptr %16, i64 2
  %80 = load i64, ptr %14, align 8, !tbaa !9
  store i64 %80, ptr %79, align 8, !tbaa !9
  %81 = getelementptr inbounds i64, ptr %16, i64 3
  store i64 0, ptr %81, align 8, !tbaa !9
  %82 = getelementptr inbounds i64, ptr %16, i64 4
  %83 = getelementptr inbounds i64, ptr %16, i64 5
  br label %84

84:                                               ; preds = %84, %75
  %85 = phi ptr [ %82, %75 ], [ %86, %84 ]
  store i64 0, ptr %85, align 8, !tbaa !9
  %86 = getelementptr inbounds i64, ptr %85, i64 1
  %87 = icmp eq ptr %86, %83
  br i1 %87, label %88, label %84

88:                                               ; preds = %84
  %89 = load ptr, ptr %4, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.k2c_tensor, ptr %89, i32 0, i32 0
  %91 = load ptr, ptr %90, align 8, !tbaa !11
  %92 = getelementptr inbounds [5 x i64], ptr %16, i64 0, i64 0
  %93 = load ptr, ptr %4, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.k2c_tensor, ptr %93, i32 0, i32 3
  %95 = getelementptr inbounds [5 x i64], ptr %94, i64 0, i64 0
  %96 = load ptr, ptr %4, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.k2c_tensor, ptr %96, i32 0, i32 1
  %98 = load i64, ptr %97, align 8, !tbaa !13
  %99 = call i64 @k2c_sub2idx(ptr noundef %92, ptr noundef %95, i64 noundef %98)
  %100 = getelementptr inbounds float, ptr %91, i64 %99
  %101 = load ptr, ptr %5, align 8, !tbaa !5
  %102 = getelementptr inbounds %struct.k2c_tensor, ptr %101, i32 0, i32 0
  %103 = load ptr, ptr %102, align 8, !tbaa !11
  %104 = getelementptr inbounds [5 x i64], ptr %15, i64 0, i64 0
  %105 = load ptr, ptr %5, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.k2c_tensor, ptr %105, i32 0, i32 3
  %107 = getelementptr inbounds [5 x i64], ptr %106, i64 0, i64 0
  %108 = load ptr, ptr %5, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.k2c_tensor, ptr %108, i32 0, i32 1
  %110 = load i64, ptr %109, align 8, !tbaa !13
  %111 = call i64 @k2c_sub2idx(ptr noundef %104, ptr noundef %107, i64 noundef %110)
  %112 = getelementptr inbounds float, ptr %103, i64 %111
  %113 = load i64, ptr %10, align 8, !tbaa !9
  %114 = mul i64 %113, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %100, ptr align 4 %112, i64 %114, i1 false)
  call void @llvm.lifetime.end.p0(i64 40, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %15) #4
  br label %115

115:                                              ; preds = %88
  %116 = load i64, ptr %14, align 8, !tbaa !9
  %117 = add i64 %116, 1
  store i64 %117, ptr %14, align 8, !tbaa !9
  br label %45, !llvm.loop !14

118:                                              ; preds = %49
  br label %119

119:                                              ; preds = %118
  %120 = load i64, ptr %13, align 8, !tbaa !9
  %121 = add i64 %120, 1
  store i64 %121, ptr %13, align 8, !tbaa !9
  br label %39, !llvm.loop !16

122:                                              ; preds = %43
  br label %123

123:                                              ; preds = %122
  %124 = load i64, ptr %11, align 8, !tbaa !9
  %125 = add i64 %124, 1
  store i64 %125, ptr %11, align 8, !tbaa !9
  br label %33, !llvm.loop !17

126:                                              ; preds = %37
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree 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 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 = !{!"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, !6, i64 0}
!12 = !{!"k2c_tensor", !6, i64 0, !10, i64 8, !10, i64 16, !7, i64 24}
!13 = !{!12, !10, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}
!17 = distinct !{!17, !15}


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

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

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

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

declare i64 @k2c_sub2idx(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
define dso_local void @k2c_upsampling3d(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #3 {
  %4 = alloca [5 x i64], align 16
  %5 = alloca [5 x i64], align 16
  %6 = getelementptr inbounds i8, ptr %0, i64 24
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %8 = getelementptr inbounds i8, ptr %0, i64 32
  %9 = load i64, ptr %8, align 8, !tbaa !5
  %10 = getelementptr inbounds i8, ptr %0, i64 40
  %11 = load i64, ptr %10, align 8, !tbaa !5
  %12 = getelementptr inbounds i8, ptr %1, i64 24
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %._crit_edge, label %.preheader37.lr.ph

.preheader37.lr.ph:                               ; preds = %3
  %13 = getelementptr inbounds i8, ptr %1, i64 48
  %14 = load i64, ptr %13, align 8, !tbaa !5
  %.not47 = icmp eq i64 %9, 0
  %15 = getelementptr inbounds i8, ptr %4, i64 8
  %16 = getelementptr inbounds i8, ptr %2, i64 8
  %17 = getelementptr inbounds i8, ptr %4, i64 16
  %18 = getelementptr inbounds i8, ptr %2, i64 16
  %19 = getelementptr inbounds i8, ptr %4, i64 24
  %20 = getelementptr inbounds i8, ptr %5, i64 8
  %21 = getelementptr inbounds i8, ptr %5, i64 16
  %22 = getelementptr inbounds i8, ptr %5, i64 24
  %23 = getelementptr inbounds i8, ptr %0, i64 8
  %24 = getelementptr inbounds i8, ptr %1, i64 8
  %25 = shl i64 %14, 2
  %.not48 = icmp eq i64 %11, 0
  %or.cond = select i1 %.not47, i1 true, i1 %.not48
  br i1 %or.cond, label %._crit_edge, label %.preheader37.us.us

.preheader37.us.us:                               ; preds = %.preheader37.lr.ph, %._crit_edge40.split.us.us.us
  %.02941.us.us = phi i64 [ %43, %._crit_edge40.split.us.us.us ], [ 0, %.preheader37.lr.ph ]
  br label %.preheader.us.us.us

.preheader.us.us.us:                              ; preds = %._crit_edge.us.us.us, %.preheader37.us.us
  %.02839.us.us.us = phi i64 [ 0, %.preheader37.us.us ], [ %42, %._crit_edge.us.us.us ]
  br label %26

26:                                               ; preds = %26, %.preheader.us.us.us
  %.038.us.us.us = phi i64 [ 0, %.preheader.us.us.us ], [ %41, %26 ]
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #5
  %27 = load i64, ptr %2, align 8, !tbaa !5
  %28 = udiv i64 %.02941.us.us, %27
  store i64 %28, ptr %4, align 16, !tbaa !5
  %29 = load i64, ptr %16, align 8, !tbaa !5
  %30 = udiv i64 %.02839.us.us.us, %29
  store i64 %30, ptr %15, align 8, !tbaa !5
  %31 = load i64, ptr %18, align 8, !tbaa !5
  %32 = udiv i64 %.038.us.us.us, %31
  store i64 %32, ptr %17, align 16, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %19, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #5
  store i64 %.02941.us.us, ptr %5, align 16, !tbaa !5
  store i64 %.02839.us.us.us, ptr %20, align 8, !tbaa !5
  store i64 %.038.us.us.us, ptr %21, align 16, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %22, i8 0, i64 16, i1 false)
  %33 = load ptr, ptr %0, align 8, !tbaa !9
  %34 = load i64, ptr %23, align 8, !tbaa !12
  %35 = call i64 @k2c_sub2idx(ptr noundef nonnull %5, ptr noundef nonnull %6, i64 noundef %34) #5
  %36 = getelementptr inbounds float, ptr %33, i64 %35
  %37 = load ptr, ptr %1, align 8, !tbaa !9
  %38 = load i64, ptr %24, align 8, !tbaa !12
  %39 = call i64 @k2c_sub2idx(ptr noundef nonnull %4, ptr noundef nonnull %12, i64 noundef %38) #5
  %40 = getelementptr inbounds float, ptr %37, i64 %39
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %36, ptr align 4 %40, i64 %25, i1 false)
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 40, ptr nonnull %4) #5
  %41 = add nuw i64 %.038.us.us.us, 1
  %exitcond.not = icmp eq i64 %41, %11
  br i1 %exitcond.not, label %._crit_edge.us.us.us, label %26, !llvm.loop !13

._crit_edge.us.us.us:                             ; preds = %26
  %42 = add nuw i64 %.02839.us.us.us, 1
  %exitcond51.not = icmp eq i64 %42, %9
  br i1 %exitcond51.not, label %._crit_edge40.split.us.us.us, label %.preheader.us.us.us, !llvm.loop !15

._crit_edge40.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %43 = add nuw i64 %.02941.us.us, 1
  %exitcond52.not = icmp eq i64 %43, %7
  br i1 %exitcond52.not, label %._crit_edge, label %.preheader37.us.us, !llvm.loop !16

._crit_edge:                                      ; preds = %._crit_edge40.split.us.us.us, %.preheader37.lr.ph, %3
  ret void
}

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree 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 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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"k2c_tensor", !11, i64 0, !6, i64 8, !6, i64 16, !7, i64 24}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!10, !6, i64 8}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}
!16 = distinct !{!16, !14}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopInstSimplifyPass,LoopRotatePass,LoopSimplifyCFGPass,LoopSimplifyPass,LoopUnrollPass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass