; LLVM IR from istoony/winograd-convolutional-nn :: main (readKernels)

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

@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 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: nounwind uwtable
define dso_local ptr @readKernels(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) #1 {
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  %16 = alloca i32, align 4
  %17 = alloca i32, align 4
  %18 = alloca i32, align 4
  store i32 %0, ptr %6, align 4, !tbaa !5
  store i32 %1, ptr %7, align 4, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !5
  store ptr %4, ptr %10, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #6
  %19 = load ptr, ptr %10, align 8, !tbaa !9
  %20 = call noalias ptr @fopen(ptr noundef %19, ptr noundef @.str.9)
  store ptr %20, ptr %11, align 8, !tbaa !9
  %21 = load ptr, ptr %11, align 8, !tbaa !9
  %22 = icmp eq ptr %21, null
  br i1 %22, label %23, label %26

23:                                               ; preds = %5
  %24 = load ptr, ptr %10, align 8, !tbaa !9
  %25 = call i32 (ptr, ...) @printf(ptr noundef @.str.10, ptr noundef %24)
  call void @exit(i32 noundef 0) #7
  unreachable

26:                                               ; preds = %5
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  store i32 0, ptr %12, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #6
  %27 = load i32, ptr %6, align 4, !tbaa !5
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = mul nsw i32 %27, %28
  store i32 %29, ptr %13, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #6
  %30 = load i32, ptr %13, align 4, !tbaa !5
  %31 = load i32, ptr %8, align 4, !tbaa !5
  %32 = mul nsw i32 %30, %31
  store i32 %32, ptr %14, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %33 = load i32, ptr %9, align 4, !tbaa !5
  %34 = sext i32 %33 to i64
  %35 = mul i64 %34, 8
  %36 = call noalias ptr @malloc(i64 noundef %35) #8
  store ptr %36, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %16) #6
  store i32 0, ptr %16, align 4, !tbaa !5
  br label %37

37:                                               ; preds = %101, %26
  %38 = load i32, ptr %16, align 4, !tbaa !5
  %39 = load i32, ptr %9, align 4, !tbaa !5
  %40 = icmp slt i32 %38, %39
  br i1 %40, label %42, label %41

41:                                               ; preds = %37
  store i32 2, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %16) #6
  br label %104

42:                                               ; preds = %37
  %43 = load i32, ptr %14, align 4, !tbaa !5
  %44 = sext i32 %43 to i64
  %45 = mul i64 %44, 8
  %46 = call noalias ptr @malloc(i64 noundef %45) #8
  %47 = load ptr, ptr %15, align 8, !tbaa !9
  %48 = load i32, ptr %16, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds ptr, ptr %47, i64 %49
  store ptr %46, ptr %50, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %18) #6
  store i32 0, ptr %18, align 4, !tbaa !5
  br label %51

51:                                               ; preds = %97, %42
  %52 = load i32, ptr %18, align 4, !tbaa !5
  %53 = load i32, ptr %8, align 4, !tbaa !5
  %54 = icmp slt i32 %52, %53
  br i1 %54, label %56, label %55

55:                                               ; preds = %51
  store i32 5, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %18) #6
  br label %100

56:                                               ; preds = %51
  %57 = load i32, ptr %13, align 4, !tbaa !5
  %58 = sext i32 %57 to i64
  %59 = mul i64 %58, 4
  %60 = call noalias ptr @malloc(i64 noundef %59) #8
  %61 = load ptr, ptr %15, align 8, !tbaa !9
  %62 = load i32, ptr %16, align 4, !tbaa !5
  %63 = sext i32 %62 to i64
  %64 = getelementptr inbounds ptr, ptr %61, i64 %63
  %65 = load ptr, ptr %64, align 8, !tbaa !9
  %66 = load i32, ptr %18, align 4, !tbaa !5
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds ptr, ptr %65, i64 %67
  store ptr %60, ptr %68, align 8, !tbaa !9
  br label %69

69:                                               ; preds = %79, %56
  %70 = load ptr, ptr %11, align 8, !tbaa !9
  %71 = call i32 @feof(ptr noundef %70) #6
  %72 = icmp ne i32 %71, 0
  br i1 %72, label %77, label %73

73:                                               ; preds = %69
  %74 = load i32, ptr %12, align 4, !tbaa !5
  %75 = load i32, ptr %13, align 4, !tbaa !5
  %76 = icmp slt i32 %74, %75
  br label %77

77:                                               ; preds = %73, %69
  %78 = phi i1 [ false, %69 ], [ %76, %73 ]
  br i1 %78, label %79, label %96

79:                                               ; preds = %77
  %80 = load ptr, ptr %11, align 8, !tbaa !9
  %81 = load ptr, ptr %15, align 8, !tbaa !9
  %82 = load i32, ptr %16, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds ptr, ptr %81, i64 %83
  %85 = load ptr, ptr %84, align 8, !tbaa !9
  %86 = load i32, ptr %18, align 4, !tbaa !5
  %87 = sext i32 %86 to i64
  %88 = getelementptr inbounds ptr, ptr %85, i64 %87
  %89 = load ptr, ptr %88, align 8, !tbaa !9
  %90 = load i32, ptr %12, align 4, !tbaa !5
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds float, ptr %89, i64 %91
  %93 = call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef %80, ptr noundef @.str.11, ptr noundef %92)
  %94 = load i32, ptr %12, align 4, !tbaa !5
  %95 = add nsw i32 %94, 1
  store i32 %95, ptr %12, align 4, !tbaa !5
  br label %69, !llvm.loop !11

96:                                               ; preds = %77
  store i32 0, ptr %12, align 4, !tbaa !5
  br label %97

97:                                               ; preds = %96
  %98 = load i32, ptr %18, align 4, !tbaa !5
  %99 = add nsw i32 %98, 1
  store i32 %99, ptr %18, align 4, !tbaa !5
  br label %51, !llvm.loop !13

100:                                              ; preds = %55
  br label %101

101:                                              ; preds = %100
  %102 = load i32, ptr %16, align 4, !tbaa !5
  %103 = add nsw i32 %102, 1
  store i32 %103, ptr %16, align 4, !tbaa !5
  br label %37, !llvm.loop !14

104:                                              ; preds = %41
  %105 = load ptr, ptr %11, align 8, !tbaa !9
  %106 = call i32 @fclose(ptr noundef %105)
  %107 = load ptr, ptr %15, align 8, !tbaa !9
  store i32 1, ptr %17, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #6
  ret ptr %107
}

declare i32 @printf(ptr noundef, ...) #2

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

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #2

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) #4

; Function Attrs: nounwind
declare i32 @feof(ptr noundef) #5

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) #2

declare i32 @fclose(ptr noundef) #2

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


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

@.str.9 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [3 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noalias noundef ptr @readKernels(i32 noundef %0, i32 noundef %1, i32 noundef %2, i32 noundef %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = tail call noalias ptr @fopen(ptr noundef %4, ptr noundef nonnull @.str.9)
  %7 = icmp eq ptr %6, null
  br i1 %7, label %8, label %10

8:                                                ; preds = %5
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10, ptr noundef %4)
  tail call void @exit(i32 noundef 0) #5
  unreachable

10:                                               ; preds = %5
  %11 = mul i32 %1, %0
  %12 = sext i32 %3 to i64
  %13 = shl nsw i64 %12, 3
  %14 = tail call noalias ptr @malloc(i64 noundef %13) #6
  %15 = icmp sgt i32 %3, 0
  br i1 %15, label %.lr.ph42, label %._crit_edge43

.lr.ph42:                                         ; preds = %10
  %16 = mul nsw i32 %11, %2
  %17 = sext i32 %16 to i64
  %18 = shl nsw i64 %17, 3
  %19 = icmp sgt i32 %2, 0
  %20 = sext i32 %11 to i64
  %21 = shl nsw i64 %20, 2
  br i1 %19, label %.lr.ph42.split.us, label %.lr.ph42.split.preheader

.lr.ph42.split.preheader:                         ; preds = %.lr.ph42
  %wide.trip.count = zext nneg i32 %3 to i64
  br label %.lr.ph42.split

.lr.ph42.split.us:                                ; preds = %.lr.ph42
  %22 = icmp sgt i32 %11, 0
  %wide.trip.count72 = zext nneg i32 %3 to i64
  %wide.trip.count67 = zext nneg i32 %2 to i64
  br i1 %22, label %.lr.ph38.us.us, label %.lr.ph38.us

.lr.ph38.us.us:                                   ; preds = %.lr.ph42.split.us, %._crit_edge39.split.us45.us
  %indvars.iv69 = phi i64 [ %indvars.iv.next70, %._crit_edge39.split.us45.us ], [ 0, %.lr.ph42.split.us ]
  %23 = tail call noalias ptr @malloc(i64 noundef %18) #6
  %24 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv69
  store ptr %23, ptr %24, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %.lr.ph38.us.us, %._crit_edge.us.us
  %indvars.iv64 = phi i64 [ 0, %.lr.ph38.us.us ], [ %indvars.iv.next65, %._crit_edge.us.us ]
  %26 = tail call noalias ptr @malloc(i64 noundef %21) #6
  %27 = getelementptr inbounds ptr, ptr %23, i64 %indvars.iv64
  store ptr %26, ptr %27, align 8, !tbaa !5
  %28 = tail call i32 @feof(ptr noundef nonnull %6) #7
  %.not34.us.us = icmp eq i32 %28, 0
  br i1 %.not34.us.us, label %.lr.ph.us.us, label %._crit_edge.us.us

._crit_edge.us.us:                                ; preds = %.lr.ph.us.us, %25
  %indvars.iv.next65 = add nuw nsw i64 %indvars.iv64, 1
  %exitcond68.not = icmp eq i64 %indvars.iv.next65, %wide.trip.count67
  br i1 %exitcond68.not, label %._crit_edge39.split.us45.us, label %25, !llvm.loop !9

.lr.ph.us.us:                                     ; preds = %25, %.lr.ph.us.us
  %indvars.iv61 = phi i64 [ %indvars.iv.next62, %.lr.ph.us.us ], [ 0, %25 ]
  %29 = load ptr, ptr %27, align 8, !tbaa !5
  %30 = getelementptr inbounds float, ptr %29, i64 %indvars.iv61
  %31 = tail call i32 (ptr, ptr, ...) @__isoc99_fscanf(ptr noundef nonnull %6, ptr noundef nonnull @.str.11, ptr noundef %30) #7
  %indvars.iv.next62 = add nuw nsw i64 %indvars.iv61, 1
  %32 = tail call i32 @feof(ptr noundef nonnull %6) #7
  %.not.us.us = icmp eq i32 %32, 0
  %33 = icmp slt i64 %indvars.iv.next62, %20
  %34 = select i1 %.not.us.us, i1 %33, i1 false
  br i1 %34, label %.lr.ph.us.us, label %._crit_edge.us.us, !llvm.loop !11

._crit_edge39.split.us45.us:                      ; preds = %._crit_edge.us.us
  %indvars.iv.next70 = add nuw nsw i64 %indvars.iv69, 1
  %exitcond73.not = icmp eq i64 %indvars.iv.next70, %wide.trip.count72
  br i1 %exitcond73.not, label %._crit_edge43, label %.lr.ph38.us.us, !llvm.loop !12

.lr.ph38.us:                                      ; preds = %.lr.ph42.split.us, %._crit_edge39.split.us.us
  %indvars.iv56 = phi i64 [ %indvars.iv.next57, %._crit_edge39.split.us.us ], [ 0, %.lr.ph42.split.us ]
  %35 = tail call noalias ptr @malloc(i64 noundef %18) #6
  %36 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv56
  store ptr %35, ptr %36, align 8, !tbaa !5
  br label %37

37:                                               ; preds = %37, %.lr.ph38.us
  %indvars.iv51 = phi i64 [ %indvars.iv.next52, %37 ], [ 0, %.lr.ph38.us ]
  %38 = tail call noalias ptr @malloc(i64 noundef %21) #6
  %39 = getelementptr inbounds ptr, ptr %35, i64 %indvars.iv51
  store ptr %38, ptr %39, align 8, !tbaa !5
  %40 = tail call i32 @feof(ptr noundef nonnull %6) #7
  %indvars.iv.next52 = add nuw nsw i64 %indvars.iv51, 1
  %exitcond55.not = icmp eq i64 %indvars.iv.next52, %wide.trip.count67
  br i1 %exitcond55.not, label %._crit_edge39.split.us.us, label %37, !llvm.loop !9

._crit_edge39.split.us.us:                        ; preds = %37
  %indvars.iv.next57 = add nuw nsw i64 %indvars.iv56, 1
  %exitcond60.not = icmp eq i64 %indvars.iv.next57, %wide.trip.count72
  br i1 %exitcond60.not, label %._crit_edge43, label %.lr.ph38.us, !llvm.loop !12

._crit_edge43:                                    ; preds = %.lr.ph42.split, %._crit_edge39.split.us.us, %._crit_edge39.split.us45.us, %10
  %41 = tail call i32 @fclose(ptr noundef nonnull %6)
  ret ptr %14

.lr.ph42.split:                                   ; preds = %.lr.ph42.split.preheader, %.lr.ph42.split
  %indvars.iv = phi i64 [ 0, %.lr.ph42.split.preheader ], [ %indvars.iv.next, %.lr.ph42.split ]
  %42 = tail call noalias ptr @malloc(i64 noundef %18) #6
  %43 = getelementptr inbounds ptr, ptr %14, i64 %indvars.iv
  store ptr %42, ptr %43, align 8, !tbaa !5
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge43, label %.lr.ph42.split, !llvm.loop !12
}

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #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 #2

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #1

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #3

; Function Attrs: nofree nounwind
declare noundef i32 @feof(ptr nocapture noundef) local_unnamed_addr #1

declare i32 @__isoc99_fscanf(ptr noundef, ptr noundef, ...) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #1

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 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 #3 = { 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 #4 = { "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 = { noreturn nounwind }
attributes #6 = { nounwind allocsize(0) }
attributes #7 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}
!11 = distinct !{!11, !10}
!12 = distinct !{!12, !10}


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