; LLVM IR from zchrissirhcz/pixel :: legacy/NaiveCNN/examples/nc_lenet.ll (Z14nc_infer_trialv)

; 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.LenetDataConfig = type { i32, ptr, ptr, [256 x i8], [256 x i8] }

@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #0

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

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

; Function Attrs: nounwind
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: mustprogress uwtable
declare dso_local void @nc_cls_data_loader(ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z21nc_lenet5_infer_setupP5NcNet(ptr noundef) #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8nc_inferP5NcNetP10px_image_t(ptr noundef, ptr noundef) #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14nc_infer_trialv() #3 {
  %1 = alloca ptr, align 8
  %2 = alloca %struct.LenetDataConfig, align 8
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %5 = call noalias ptr @malloc(i64 noundef 48) #5
  store ptr %5, ptr %1, align 8, !tbaa !5
  %6 = load ptr, ptr %1, align 8, !tbaa !5
  call void @_Z21nc_lenet5_infer_setupP5NcNet(ptr noundef %6)
  call void @llvm.lifetime.start.p0(i64 536, ptr %2) #4
  %7 = getelementptr inbounds %struct.LenetDataConfig, ptr %2, i32 0, i32 3
  %8 = getelementptr inbounds [256 x i8], ptr %7, i64 0, i64 0
  %9 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %8, ptr noundef @.str.7, ptr noundef @.str.8) #4
  %10 = getelementptr inbounds %struct.LenetDataConfig, ptr %2, i32 0, i32 4
  %11 = getelementptr inbounds [256 x i8], ptr %10, i64 0, i64 0
  %12 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %11, ptr noundef @.str.7, ptr noundef @.str.9) #4
  call void @nc_cls_data_loader(ptr noundef %2)
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %13

13:                                               ; preds = %26, %0
  %14 = load i32, ptr %3, align 4, !tbaa !9
  %15 = icmp slt i32 %14, 1
  br i1 %15, label %17, label %16

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

17:                                               ; preds = %13
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  %18 = getelementptr inbounds %struct.LenetDataConfig, ptr %2, i32 0, i32 1
  %19 = load ptr, ptr %18, align 8, !tbaa !11
  %20 = load i32, ptr %3, align 4, !tbaa !9
  %21 = sext i32 %20 to i64
  %22 = getelementptr inbounds ptr, ptr %19, i64 %21
  %23 = load ptr, ptr %22, align 8, !tbaa !5
  store ptr %23, ptr %4, align 8, !tbaa !5
  %24 = load ptr, ptr %1, align 8, !tbaa !5
  %25 = load ptr, ptr %4, align 8, !tbaa !5
  call void @_Z8nc_inferP5NcNetP10px_image_t(ptr noundef %24, ptr noundef %25)
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %26

26:                                               ; preds = %17
  %27 = load i32, ptr %3, align 4, !tbaa !9
  %28 = add nsw i32 %27, 1
  store i32 %28, ptr %3, align 4, !tbaa !9
  br label %13, !llvm.loop !13

29:                                               ; preds = %16
  call void @llvm.lifetime.end.p0(i64 536, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret void
}

attributes #0 = { nounwind allocsize(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 = { 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 #3 = { 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 #4 = { nounwind }
attributes #5 = { nounwind allocsize(0) }

!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, !6, i64 8}
!12 = !{!"_ZTS15LenetDataConfig", !10, i64 0, !6, i64 8, !6, i64 16, !7, i64 24, !7, i64 280}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


; 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.LenetDataConfig = type { i32, ptr, ptr, [256 x i8], [256 x i8] }

@.str.7 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [6 x i8], align 1

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #0

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare dso_local void @nc_cls_data_loader(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z21nc_lenet5_infer_setupP5NcNet(ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
declare dso_local void @_Z8nc_inferP5NcNetP10px_image_t(ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress uwtable
define dso_local void @_Z14nc_infer_trialv() local_unnamed_addr #3 {
.critedge:
  %0 = alloca %struct.LenetDataConfig, align 8
  %1 = tail call noalias dereferenceable_or_null(48) ptr @malloc(i64 noundef 48) #4
  tail call void @_Z21nc_lenet5_infer_setupP5NcNet(ptr noundef %1)
  call void @llvm.lifetime.start.p0(i64 536, ptr nonnull %0) #5
  %2 = getelementptr inbounds i8, ptr %0, i64 24
  %3 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %2, ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef nonnull @.str.8) #5
  %4 = getelementptr inbounds i8, ptr %0, i64 280
  %5 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %4, ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef nonnull @.str.9) #5
  call void @nc_cls_data_loader(ptr noundef nonnull %0)
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = load ptr, ptr %7, align 8, !tbaa !11
  call void @_Z8nc_inferP5NcNetP10px_image_t(ptr noundef %1, ptr noundef %8)
  call void @llvm.lifetime.end.p0(i64 536, ptr nonnull %0) #5
  ret void
}

attributes #0 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 = { 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 #3 = { 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 #4 = { nounwind allocsize(0) }
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, !10, i64 8}
!6 = !{!"_ZTS15LenetDataConfig", !7, i64 0, !10, i64 8, !10, i64 16, !8, i64 24, !8, i64 280}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!10, !10, i64 0}


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