; LLVM IR from Dynmi/AlexNet :: src (data)

; 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.image = type { i32, i32, i32, ptr }

; Function Attrs: nounwind
declare void @free(ptr 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 allocsize(0)
declare noalias ptr @malloc(i64 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @horizontal_flip(ptr noundef %0) #3 {
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca i16, align 2
  %5 = alloca i32, align 4
  %6 = alloca i16, align 2
  %7 = alloca i32, align 4
  %8 = alloca i16, align 2
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = getelementptr inbounds %struct.image, ptr %9, i32 0, i32 0
  %11 = load i32, ptr %10, align 8, !tbaa !9
  %12 = load ptr, ptr %2, align 8, !tbaa !5
  %13 = getelementptr inbounds %struct.image, ptr %12, i32 0, i32 1
  %14 = load i32, ptr %13, align 4, !tbaa !12
  %15 = mul nsw i32 %11, %14
  %16 = load ptr, ptr %2, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.image, ptr %16, i32 0, i32 2
  %18 = load i32, ptr %17, align 8, !tbaa !13
  %19 = mul nsw i32 %15, %18
  %20 = sext i32 %19 to i64
  %21 = mul i64 %20, 4
  %22 = call noalias ptr @malloc(i64 noundef %21) #6
  store ptr %22, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2, ptr %4) #5
  store i16 0, ptr %4, align 2, !tbaa !14
  br label %23

23:                                               ; preds = %96, %1
  %24 = load i16, ptr %4, align 2, !tbaa !14
  %25 = sext i16 %24 to i32
  %26 = load ptr, ptr %2, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.image, ptr %26, i32 0, i32 2
  %28 = load i32, ptr %27, align 8, !tbaa !13
  %29 = icmp slt i32 %25, %28
  br i1 %29, label %31, label %30

30:                                               ; preds = %23
  store i32 2, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %4) #5
  br label %99

31:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 2, ptr %6) #5
  store i16 0, ptr %6, align 2, !tbaa !14
  br label %32

32:                                               ; preds = %92, %31
  %33 = load i16, ptr %6, align 2, !tbaa !14
  %34 = sext i16 %33 to i32
  %35 = load ptr, ptr %2, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.image, ptr %35, i32 0, i32 1
  %37 = load i32, ptr %36, align 4, !tbaa !12
  %38 = icmp slt i32 %34, %37
  br i1 %38, label %40, label %39

39:                                               ; preds = %32
  store i32 5, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %6) #5
  br label %95

40:                                               ; preds = %32
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %41 = load i16, ptr %6, align 2, !tbaa !14
  %42 = sext i16 %41 to i32
  %43 = load ptr, ptr %2, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.image, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 8, !tbaa !9
  %46 = mul nsw i32 %42, %45
  %47 = load i16, ptr %4, align 2, !tbaa !14
  %48 = sext i16 %47 to i32
  %49 = load ptr, ptr %2, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.image, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 8, !tbaa !9
  %52 = mul nsw i32 %48, %51
  %53 = load ptr, ptr %2, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.image, ptr %53, i32 0, i32 1
  %55 = load i32, ptr %54, align 4, !tbaa !12
  %56 = mul nsw i32 %52, %55
  %57 = add nsw i32 %46, %56
  store i32 %57, ptr %7, align 4, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 2, ptr %8) #5
  store i16 0, ptr %8, align 2, !tbaa !14
  br label %58

58:                                               ; preds = %88, %40
  %59 = load i16, ptr %8, align 2, !tbaa !14
  %60 = sext i16 %59 to i32
  %61 = load ptr, ptr %2, align 8, !tbaa !5
  %62 = getelementptr inbounds %struct.image, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !9
  %64 = icmp slt i32 %60, %63
  br i1 %64, label %66, label %65

65:                                               ; preds = %58
  store i32 8, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 2, ptr %8) #5
  br label %91

66:                                               ; preds = %58
  %67 = load ptr, ptr %2, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.image, ptr %67, i32 0, i32 3
  %69 = load ptr, ptr %68, align 8, !tbaa !17
  %70 = load i32, ptr %7, align 4, !tbaa !16
  %71 = load ptr, ptr %2, align 8, !tbaa !5
  %72 = getelementptr inbounds %struct.image, ptr %71, i32 0, i32 0
  %73 = load i32, ptr %72, align 8, !tbaa !9
  %74 = add nsw i32 %70, %73
  %75 = load i16, ptr %8, align 2, !tbaa !14
  %76 = sext i16 %75 to i32
  %77 = sub nsw i32 %74, %76
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds float, ptr %69, i64 %78
  %80 = load float, ptr %79, align 4, !tbaa !18
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = load i32, ptr %7, align 4, !tbaa !16
  %83 = load i16, ptr %8, align 2, !tbaa !14
  %84 = sext i16 %83 to i32
  %85 = add nsw i32 %82, %84
  %86 = sext i32 %85 to i64
  %87 = getelementptr inbounds float, ptr %81, i64 %86
  store float %80, ptr %87, align 4, !tbaa !18
  br label %88

88:                                               ; preds = %66
  %89 = load i16, ptr %8, align 2, !tbaa !14
  %90 = add i16 %89, 1
  store i16 %90, ptr %8, align 2, !tbaa !14
  br label %58, !llvm.loop !20

91:                                               ; preds = %65
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  br label %92

92:                                               ; preds = %91
  %93 = load i16, ptr %6, align 2, !tbaa !14
  %94 = add i16 %93, 1
  store i16 %94, ptr %6, align 2, !tbaa !14
  br label %32, !llvm.loop !22

95:                                               ; preds = %39
  br label %96

96:                                               ; preds = %95
  %97 = load i16, ptr %4, align 2, !tbaa !14
  %98 = add i16 %97, 1
  store i16 %98, ptr %4, align 2, !tbaa !14
  br label %23, !llvm.loop !23

99:                                               ; preds = %30
  %100 = load ptr, ptr %2, align 8, !tbaa !5
  %101 = getelementptr inbounds %struct.image, ptr %100, i32 0, i32 3
  %102 = load ptr, ptr %101, align 8, !tbaa !17
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = load ptr, ptr %2, align 8, !tbaa !5
  %105 = getelementptr inbounds %struct.image, ptr %104, i32 0, i32 0
  %106 = load i32, ptr %105, align 8, !tbaa !9
  %107 = load ptr, ptr %2, align 8, !tbaa !5
  %108 = getelementptr inbounds %struct.image, ptr %107, i32 0, i32 1
  %109 = load i32, ptr %108, align 4, !tbaa !12
  %110 = mul nsw i32 %106, %109
  %111 = load ptr, ptr %2, align 8, !tbaa !5
  %112 = getelementptr inbounds %struct.image, ptr %111, i32 0, i32 2
  %113 = load i32, ptr %112, align 8, !tbaa !13
  %114 = mul nsw i32 %110, %113
  %115 = sext i32 %114 to i64
  %116 = mul i64 %115, 4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %102, ptr align 4 %103, i64 %116, i1 false)
  %117 = load ptr, ptr %3, align 8, !tbaa !5
  call void @free(ptr noundef %117) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  ret void
}

; 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) #4

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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: readwrite) }
attributes #5 = { nounwind }
attributes #6 = { 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/C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"", !11, i64 0, !11, i64 4, !11, i64 8, !6, i64 16}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 4}
!13 = !{!10, !11, i64 8}
!14 = !{!15, !15, i64 0}
!15 = !{!"short", !7, i64 0}
!16 = !{!11, !11, i64 0}
!17 = !{!10, !6, i64 16}
!18 = !{!19, !19, i64 0}
!19 = !{!"float", !7, i64 0}
!20 = distinct !{!20, !21}
!21 = !{!"llvm.loop.mustprogress"}
!22 = distinct !{!22, !21}
!23 = distinct !{!23, !21}


; 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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
define dso_local void @horizontal_flip(ptr nocapture noundef readonly %0) local_unnamed_addr #2 {
  %2 = load i32, ptr %0, align 8, !tbaa !5
  %3 = getelementptr inbounds i8, ptr %0, i64 4
  %4 = load i32, ptr %3, align 4, !tbaa !11
  %5 = mul nsw i32 %4, %2
  %6 = getelementptr inbounds i8, ptr %0, i64 8
  %7 = load i32, ptr %6, align 8, !tbaa !12
  %8 = mul nsw i32 %5, %7
  %9 = sext i32 %8 to i64
  %10 = shl nsw i64 %9, 2
  %11 = tail call noalias ptr @malloc(i64 noundef %10) #4
  %12 = icmp sgt i32 %7, 0
  br i1 %12, label %.preheader.lr.ph, label %._crit_edge

.preheader.lr.ph:                                 ; preds = %1
  %13 = icmp sgt i32 %4, 0
  %14 = icmp sgt i32 %2, 0
  %or.cond = and i1 %13, %14
  br i1 %or.cond, label %.preheader.lr.ph.split.us.split.us, label %._crit_edge

.preheader.lr.ph.split.us.split.us:               ; preds = %.preheader.lr.ph
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  %16 = load ptr, ptr %15, align 8, !tbaa !13
  %17 = add nsw i32 %2, -1
  %min.iters.check = icmp ult i32 %2, 16
  %18 = icmp ugt i32 %17, 32767
  %19 = trunc i32 %17 to i16
  %20 = icmp ugt i16 %19, 32766
  %21 = or i1 %20, %18
  %n.vec = and i32 %2, 65528
  %ind.end = trunc nuw i32 %n.vec to i16
  %cmp.n = icmp eq i32 %2, %n.vec
  br label %.preheader.us.us

.preheader.us.us:                                 ; preds = %._crit_edge40.split.us.us.us, %.preheader.lr.ph.split.us.split.us
  %22 = phi i32 [ 0, %.preheader.lr.ph.split.us.split.us ], [ %58, %._crit_edge40.split.us.us.us ]
  %.02941.us.us = phi i16 [ 0, %.preheader.lr.ph.split.us.split.us ], [ %57, %._crit_edge40.split.us.us.us ]
  %23 = mul i32 %4, %22
  %24 = mul i32 %22, %4
  %25 = add i32 %23, 1
  br label %.lr.ph.us.us.us

.lr.ph.us.us.us:                                  ; preds = %._crit_edge.us.us.us, %.preheader.us.us
  %26 = phi i32 [ 0, %.preheader.us.us ], [ %55, %._crit_edge.us.us.us ]
  %.03038.us.us.us = phi i16 [ 0, %.preheader.us.us ], [ %54, %._crit_edge.us.us.us ]
  %reass.add.us.us.us = add i32 %26, %24
  %reass.mul.us.us.us = mul i32 %reass.add.us.us.us, %2
  %27 = add nsw i32 %reass.mul.us.us.us, %2
  br i1 %min.iters.check, label %scalar.ph.preheader, label %vector.scevcheck

vector.scevcheck:                                 ; preds = %.lr.ph.us.us.us
  %28 = add i32 %25, %26
  %29 = mul i32 %2, %28
  %30 = sub i32 %29, %17
  %31 = icmp sgt i32 %30, %29
  %32 = or i1 %21, %31
  br i1 %32, label %scalar.ph.preheader, label %vector.body

vector.body:                                      ; preds = %vector.scevcheck, %vector.body
  %index = phi i32 [ %index.next, %vector.body ], [ 0, %vector.scevcheck ]
  %33 = sub i32 %27, %index
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds float, ptr %16, i64 %34
  %36 = getelementptr inbounds i8, ptr %35, i64 -12
  %37 = getelementptr inbounds i8, ptr %35, i64 -28
  %wide.load = load <4 x float>, ptr %36, align 4, !tbaa !14
  %reverse = shufflevector <4 x float> %wide.load, <4 x float> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
  %wide.load48 = load <4 x float>, ptr %37, align 4, !tbaa !14
  %reverse49 = shufflevector <4 x float> %wide.load48, <4 x float> poison, <4 x i32> <i32 3, i32 2, i32 1, i32 0>
  %38 = add nsw i32 %index, %reass.mul.us.us.us
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds float, ptr %11, i64 %39
  %41 = getelementptr inbounds i8, ptr %40, i64 16
  store <4 x float> %reverse, ptr %40, align 4, !tbaa !14
  store <4 x float> %reverse49, ptr %41, align 4, !tbaa !14
  %index.next = add nuw i32 %index, 8
  %42 = icmp eq i32 %index.next, %n.vec
  br i1 %42, label %middle.block, label %vector.body, !llvm.loop !16

middle.block:                                     ; preds = %vector.body
  br i1 %cmp.n, label %._crit_edge.us.us.us, label %scalar.ph.preheader

scalar.ph.preheader:                              ; preds = %middle.block, %vector.scevcheck, %.lr.ph.us.us.us
  %.ph = phi i32 [ 0, %vector.scevcheck ], [ 0, %.lr.ph.us.us.us ], [ %n.vec, %middle.block ]
  %.037.us.us.us.ph = phi i16 [ 0, %vector.scevcheck ], [ 0, %.lr.ph.us.us.us ], [ %ind.end, %middle.block ]
  br label %scalar.ph

scalar.ph:                                        ; preds = %scalar.ph.preheader, %scalar.ph
  %43 = phi i32 [ %52, %scalar.ph ], [ %.ph, %scalar.ph.preheader ]
  %.037.us.us.us = phi i16 [ %51, %scalar.ph ], [ %.037.us.us.us.ph, %scalar.ph.preheader ]
  %44 = sub i32 %27, %43
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds float, ptr %16, i64 %45
  %47 = load float, ptr %46, align 4, !tbaa !14
  %48 = add nsw i32 %43, %reass.mul.us.us.us
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds float, ptr %11, i64 %49
  store float %47, ptr %50, align 4, !tbaa !14
  %51 = add i16 %.037.us.us.us, 1
  %52 = sext i16 %51 to i32
  %53 = icmp sgt i32 %2, %52
  br i1 %53, label %scalar.ph, label %._crit_edge.us.us.us, !llvm.loop !20

._crit_edge.us.us.us:                             ; preds = %scalar.ph, %middle.block
  %54 = add i16 %.03038.us.us.us, 1
  %55 = sext i16 %54 to i32
  %56 = icmp sgt i32 %4, %55
  br i1 %56, label %.lr.ph.us.us.us, label %._crit_edge40.split.us.us.us, !llvm.loop !21

._crit_edge40.split.us.us.us:                     ; preds = %._crit_edge.us.us.us
  %57 = add i16 %.02941.us.us, 1
  %58 = sext i16 %57 to i32
  %59 = icmp sgt i32 %7, %58
  br i1 %59, label %.preheader.us.us, label %._crit_edge, !llvm.loop !22

._crit_edge:                                      ; preds = %._crit_edge40.split.us.us.us, %.preheader.lr.ph, %1
  %60 = getelementptr inbounds i8, ptr %0, i64 16
  %61 = load ptr, ptr %60, align 8, !tbaa !13
  tail call void @llvm.memcpy.p0.p0.i64(ptr align 4 %61, ptr align 4 %11, i64 %10, i1 false)
  tail call void @free(ptr noundef %11) #5
  ret void
}

; 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) #3

attributes #0 = { mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, 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 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 #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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 4, !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 4}
!12 = !{!6, !7, i64 8}
!13 = !{!6, !10, i64 16}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = distinct !{!16, !17, !18, !19}
!17 = !{!"llvm.loop.mustprogress"}
!18 = !{!"llvm.loop.isvectorized", i32 1}
!19 = !{!"llvm.loop.unroll.runtime.disable"}
!20 = distinct !{!20, !17, !18}
!21 = distinct !{!21, !17}
!22 = distinct !{!22, !17}


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