; 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

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

27:                                               ; preds = %99, %3
  %28 = load i64, ptr %10, align 8, !tbaa !9
  %29 = load i64, ptr %7, align 8, !tbaa !9
  %30 = icmp ult i64 %28, %29
  br i1 %30, label %32, label %31

31:                                               ; preds = %27
  store i32 2, ptr %11, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  br label %102

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

33:                                               ; preds = %95, %32
  %34 = load i64, ptr %12, align 8, !tbaa !9
  %35 = load i64, ptr %8, align 8, !tbaa !9
  %36 = icmp ult i64 %34, %35
  br i1 %36, label %38, label %37

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

38:                                               ; preds = %33
  call void @llvm.lifetime.start.p0(i64 40, ptr %13) #4
  %39 = load i64, ptr %10, align 8, !tbaa !9
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = getelementptr inbounds i64, ptr %40, i64 0
  %42 = load i64, ptr %41, align 8, !tbaa !9
  %43 = udiv i64 %39, %42
  store i64 %43, ptr %13, align 8, !tbaa !9
  %44 = getelementptr inbounds i64, ptr %13, i64 1
  %45 = load i64, ptr %12, align 8, !tbaa !9
  %46 = load ptr, ptr %6, align 8, !tbaa !5
  %47 = getelementptr inbounds i64, ptr %46, i64 1
  %48 = load i64, ptr %47, align 8, !tbaa !9
  %49 = udiv i64 %45, %48
  store i64 %49, ptr %44, align 8, !tbaa !9
  %50 = getelementptr inbounds i64, ptr %13, i64 2
  store i64 0, ptr %50, align 8, !tbaa !9
  %51 = getelementptr inbounds i64, ptr %13, i64 3
  %52 = getelementptr inbounds i64, ptr %13, i64 5
  br label %53

53:                                               ; preds = %53, %38
  %54 = phi ptr [ %51, %38 ], [ %55, %53 ]
  store i64 0, ptr %54, align 8, !tbaa !9
  %55 = getelementptr inbounds i64, ptr %54, i64 1
  %56 = icmp eq ptr %55, %52
  br i1 %56, label %57, label %53

57:                                               ; preds = %53
  call void @llvm.lifetime.start.p0(i64 40, ptr %14) #4
  %58 = load i64, ptr %10, align 8, !tbaa !9
  store i64 %58, ptr %14, align 8, !tbaa !9
  %59 = getelementptr inbounds i64, ptr %14, i64 1
  %60 = load i64, ptr %12, align 8, !tbaa !9
  store i64 %60, ptr %59, align 8, !tbaa !9
  %61 = getelementptr inbounds i64, ptr %14, i64 2
  store i64 0, ptr %61, align 8, !tbaa !9
  %62 = getelementptr inbounds i64, ptr %14, i64 3
  %63 = getelementptr inbounds i64, ptr %14, i64 5
  br label %64

64:                                               ; preds = %64, %57
  %65 = phi ptr [ %62, %57 ], [ %66, %64 ]
  store i64 0, ptr %65, align 8, !tbaa !9
  %66 = getelementptr inbounds i64, ptr %65, i64 1
  %67 = icmp eq ptr %66, %63
  br i1 %67, label %68, label %64

68:                                               ; preds = %64
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.k2c_tensor, ptr %69, i32 0, i32 0
  %71 = load ptr, ptr %70, align 8, !tbaa !11
  %72 = getelementptr inbounds [5 x i64], ptr %14, i64 0, i64 0
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.k2c_tensor, ptr %73, i32 0, i32 3
  %75 = getelementptr inbounds [5 x i64], ptr %74, i64 0, i64 0
  %76 = load ptr, ptr %4, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.k2c_tensor, ptr %76, i32 0, i32 1
  %78 = load i64, ptr %77, align 8, !tbaa !13
  %79 = call i64 @k2c_sub2idx(ptr noundef %72, ptr noundef %75, i64 noundef %78)
  %80 = getelementptr inbounds float, ptr %71, i64 %79
  %81 = load ptr, ptr %5, align 8, !tbaa !5
  %82 = getelementptr inbounds %struct.k2c_tensor, ptr %81, i32 0, i32 0
  %83 = load ptr, ptr %82, align 8, !tbaa !11
  %84 = getelementptr inbounds [5 x i64], ptr %13, i64 0, i64 0
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.k2c_tensor, ptr %85, i32 0, i32 3
  %87 = getelementptr inbounds [5 x i64], ptr %86, i64 0, i64 0
  %88 = load ptr, ptr %5, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.k2c_tensor, ptr %88, i32 0, i32 1
  %90 = load i64, ptr %89, align 8, !tbaa !13
  %91 = call i64 @k2c_sub2idx(ptr noundef %84, ptr noundef %87, i64 noundef %90)
  %92 = getelementptr inbounds float, ptr %83, i64 %91
  %93 = load i64, ptr %9, align 8, !tbaa !9
  %94 = mul i64 %93, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %80, ptr align 4 %92, i64 %94, i1 false)
  call void @llvm.lifetime.end.p0(i64 40, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 40, ptr %13) #4
  br label %95

95:                                               ; preds = %68
  %96 = load i64, ptr %12, align 8, !tbaa !9
  %97 = add i64 %96, 1
  store i64 %97, ptr %12, align 8, !tbaa !9
  br label %33, !llvm.loop !14

98:                                               ; preds = %37
  br label %99

99:                                               ; preds = %98
  %100 = load i64, ptr %10, align 8, !tbaa !9
  %101 = add i64 %100, 1
  store i64 %101, ptr %10, align 8, !tbaa !9
  br label %27, !llvm.loop !16

102:                                              ; preds = %31
  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
}

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

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


; 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

; Function Attrs: nounwind uwtable
define dso_local void @k2c_upsampling2d(ptr noundef %0, ptr noundef %1, ptr nocapture noundef readonly %2) local_unnamed_addr #2 {
  %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 %1, i64 24
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %._crit_edge31, label %.preheader.lr.ph

.preheader.lr.ph:                                 ; preds = %3
  %11 = getelementptr inbounds i8, ptr %1, i64 40
  %12 = load i64, ptr %11, align 8, !tbaa !5
  %.not32 = icmp eq i64 %9, 0
  %13 = getelementptr inbounds i8, ptr %4, i64 8
  %14 = getelementptr inbounds i8, ptr %2, i64 8
  %15 = getelementptr inbounds i8, ptr %4, i64 16
  %16 = getelementptr inbounds i8, ptr %5, i64 8
  %17 = getelementptr inbounds i8, ptr %5, i64 16
  %18 = getelementptr inbounds i8, ptr %0, i64 8
  %19 = getelementptr inbounds i8, ptr %1, i64 8
  %20 = shl i64 %12, 2
  br i1 %.not32, label %._crit_edge31, label %.preheader.us

.preheader.us:                                    ; preds = %.preheader.lr.ph, %._crit_edge.us
  %.02130.us = phi i64 [ %35, %._crit_edge.us ], [ 0, %.preheader.lr.ph ]
  br label %21

21:                                               ; preds = %.preheader.us, %21
  %.029.us = phi i64 [ 0, %.preheader.us ], [ %34, %21 ]
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %4) #5
  %22 = load i64, ptr %2, align 8, !tbaa !5
  %23 = udiv i64 %.02130.us, %22
  store i64 %23, ptr %4, align 16, !tbaa !5
  %24 = load i64, ptr %14, align 8, !tbaa !5
  %25 = udiv i64 %.029.us, %24
  store i64 %25, ptr %13, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %15, i8 0, i64 24, i1 false)
  call void @llvm.lifetime.start.p0(i64 40, ptr nonnull %5) #5
  store i64 %.02130.us, ptr %5, align 16, !tbaa !5
  store i64 %.029.us, ptr %16, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 16 dereferenceable(24) %17, i8 0, i64 24, i1 false)
  %26 = load ptr, ptr %0, align 8, !tbaa !9
  %27 = load i64, ptr %18, align 8, !tbaa !12
  %28 = call i64 @k2c_sub2idx(ptr noundef nonnull %5, ptr noundef nonnull %6, i64 noundef %27) #5
  %29 = getelementptr inbounds float, ptr %26, i64 %28
  %30 = load ptr, ptr %1, align 8, !tbaa !9
  %31 = load i64, ptr %19, align 8, !tbaa !12
  %32 = call i64 @k2c_sub2idx(ptr noundef nonnull %4, ptr noundef nonnull %10, i64 noundef %31) #5
  %33 = getelementptr inbounds float, ptr %30, i64 %32
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %29, ptr align 4 %33, i64 %20, 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
  %34 = add nuw i64 %.029.us, 1
  %exitcond.not = icmp eq i64 %34, %9
  br i1 %exitcond.not, label %._crit_edge.us, label %21, !llvm.loop !13

._crit_edge.us:                                   ; preds = %21
  %35 = add nuw i64 %.02130.us, 1
  %exitcond35.not = icmp eq i64 %35, %7
  br i1 %exitcond35.not, label %._crit_edge31, label %.preheader.us, !llvm.loop !15

._crit_edge31:                                    ; preds = %._crit_edge.us, %.preheader.lr.ph, %3
  ret void
}

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

; 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 = { 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 = { "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}


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