; LLVM IR from bjourne/fast_snn_fpga :: src (npy)

; 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.npy_pp = type { i32, i32, ptr, [256 x i8], i32, i8, i64, ptr }
%struct.npy_arr = type { i32, i32, i8, i32, [10 x i32], i32, ptr, i32 }

@.str.22 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [9 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
declare i32 @sprintf(ptr noundef, ptr noundef, ...) #1

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

; Function Attrs: nounwind uwtable
define dso_local void @npy_pp_print_arr(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i8, align 1
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.npy_pp, ptr %11, i32 0, i32 6
  store i64 0, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #4
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.npy_arr, ptr %13, i32 0, i32 2
  %15 = load i8, ptr %14, align 8, !tbaa !14
  store i8 %15, ptr %5, align 1, !tbaa !16
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  %16 = load ptr, ptr %3, align 8, !tbaa !5
  %17 = load ptr, ptr %4, align 8, !tbaa !5
  %18 = call i64 @cell_width(ptr noundef %16, ptr noundef %17)
  %19 = trunc i64 %18 to i32
  store i32 %19, ptr %6, align 4, !tbaa !17
  %20 = load i8, ptr %5, align 1, !tbaa !16
  %21 = sext i8 %20 to i32
  %22 = icmp eq i32 %21, 83
  br i1 %22, label %23, label %30

23:                                               ; preds = %2
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.npy_pp, ptr %24, i32 0, i32 3
  %26 = getelementptr inbounds [256 x i8], ptr %25, i64 0, i64 0
  %27 = load i32, ptr %6, align 4, !tbaa !17
  %28 = load i32, ptr %6, align 4, !tbaa !17
  %29 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %26, ptr noundef @.str.22, i32 noundef %27, i32 noundef %28) #4
  br label %65

30:                                               ; preds = %2
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.npy_arr, ptr %31, i32 0, i32 2
  %33 = load i8, ptr %32, align 8, !tbaa !14
  %34 = sext i8 %33 to i32
  %35 = icmp eq i32 %34, 105
  br i1 %35, label %36, label %42

36:                                               ; preds = %30
  %37 = load ptr, ptr %3, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.npy_pp, ptr %37, i32 0, i32 3
  %39 = getelementptr inbounds [256 x i8], ptr %38, i64 0, i64 0
  %40 = load i32, ptr %6, align 4, !tbaa !17
  %41 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %39, ptr noundef @.str.23, i32 noundef %40) #4
  br label %64

42:                                               ; preds = %30
  %43 = load ptr, ptr %4, align 8, !tbaa !5
  %44 = getelementptr inbounds %struct.npy_arr, ptr %43, i32 0, i32 2
  %45 = load i8, ptr %44, align 8, !tbaa !14
  %46 = sext i8 %45 to i32
  %47 = icmp eq i32 %46, 117
  br i1 %47, label %48, label %54

48:                                               ; preds = %42
  %49 = load ptr, ptr %3, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.npy_pp, ptr %49, i32 0, i32 3
  %51 = getelementptr inbounds [256 x i8], ptr %50, i64 0, i64 0
  %52 = load i32, ptr %6, align 4, !tbaa !17
  %53 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %51, ptr noundef @.str.24, i32 noundef %52) #4
  br label %63

54:                                               ; preds = %42
  %55 = load ptr, ptr %3, align 8, !tbaa !5
  %56 = getelementptr inbounds %struct.npy_pp, ptr %55, i32 0, i32 3
  %57 = getelementptr inbounds [256 x i8], ptr %56, i64 0, i64 0
  %58 = load i32, ptr %6, align 4, !tbaa !17
  %59 = load ptr, ptr %3, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.npy_pp, ptr %59, i32 0, i32 0
  %61 = load i32, ptr %60, align 8, !tbaa !18
  %62 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %57, ptr noundef @.str.25, i32 noundef %58, i32 noundef %61) #4
  br label %63

63:                                               ; preds = %54, %48
  br label %64

64:                                               ; preds = %63, %36
  br label %65

65:                                               ; preds = %64, %23
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %66 = load ptr, ptr %4, align 8, !tbaa !5
  %67 = getelementptr inbounds %struct.npy_arr, ptr %66, i32 0, i32 5
  %68 = load i32, ptr %67, align 8, !tbaa !19
  store i32 %68, ptr %7, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.npy_pp, ptr %69, i32 0, i32 2
  %71 = load ptr, ptr %70, align 8, !tbaa !20
  %72 = call i64 @strlen(ptr noundef %71) #5
  %73 = trunc i64 %72 to i32
  store i32 %73, ptr %8, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.npy_arr, ptr %74, i32 0, i32 4
  %76 = load i32, ptr %7, align 4, !tbaa !17
  %77 = sub nsw i32 %76, 1
  %78 = sext i32 %77 to i64
  %79 = getelementptr inbounds [10 x i32], ptr %75, i64 0, i64 %78
  %80 = load i32, ptr %79, align 4, !tbaa !17
  store i32 %80, ptr %9, align 4, !tbaa !17
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #4
  %81 = load i32, ptr %9, align 4, !tbaa !17
  %82 = load i32, ptr %6, align 4, !tbaa !17
  %83 = load i32, ptr %8, align 4, !tbaa !17
  %84 = add nsw i32 %82, %83
  %85 = mul nsw i32 %81, %84
  store i32 %85, ptr %10, align 4, !tbaa !17
  %86 = load i32, ptr %10, align 4, !tbaa !17
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.npy_pp, ptr %87, i32 0, i32 1
  %89 = load i32, ptr %88, align 4, !tbaa !21
  %90 = icmp sgt i32 %86, %89
  %91 = load ptr, ptr %3, align 8, !tbaa !5
  %92 = getelementptr inbounds %struct.npy_pp, ptr %91, i32 0, i32 5
  %93 = zext i1 %90 to i8
  store i8 %93, ptr %92, align 4, !tbaa !22
  %94 = load ptr, ptr %3, align 8, !tbaa !5
  %95 = getelementptr inbounds %struct.npy_pp, ptr %94, i32 0, i32 1
  %96 = load i32, ptr %95, align 4, !tbaa !21
  %97 = load i32, ptr %7, align 4, !tbaa !17
  %98 = sub nsw i32 %96, %97
  %99 = load i32, ptr %6, align 4, !tbaa !17
  %100 = load i32, ptr %8, align 4, !tbaa !17
  %101 = add nsw i32 %99, %100
  %102 = sdiv i32 %98, %101
  %103 = load ptr, ptr %3, align 8, !tbaa !5
  %104 = getelementptr inbounds %struct.npy_pp, ptr %103, i32 0, i32 4
  store i32 %102, ptr %104, align 8, !tbaa !23
  %105 = load ptr, ptr %3, align 8, !tbaa !5
  %106 = getelementptr inbounds %struct.npy_pp, ptr %105, i32 0, i32 6
  store i64 0, ptr %106, align 8, !tbaa !9
  %107 = load ptr, ptr %4, align 8, !tbaa !5
  %108 = load ptr, ptr %3, align 8, !tbaa !5
  %109 = getelementptr inbounds %struct.npy_pp, ptr %108, i32 0, i32 7
  store ptr %107, ptr %109, align 8, !tbaa !24
  %110 = load ptr, ptr %3, align 8, !tbaa !5
  call void @pp_rec(ptr noundef %110, i32 noundef 0, i1 noundef zeroext true)
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #4
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i64 @cell_width(ptr noundef, ptr noundef) #2

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @pp_rec(ptr noundef, i32 noundef, i1 noundef zeroext) #2

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

!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, !13, i64 280}
!10 = !{!"", !11, i64 0, !11, i64 4, !6, i64 8, !7, i64 16, !11, i64 272, !12, i64 276, !13, i64 280, !6, i64 288}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"long", !7, i64 0}
!14 = !{!15, !7, i64 8}
!15 = !{!"", !11, i64 0, !11, i64 4, !7, i64 8, !11, i64 12, !7, i64 16, !11, i64 56, !6, i64 64, !11, i64 72}
!16 = !{!7, !7, i64 0}
!17 = !{!11, !11, i64 0}
!18 = !{!10, !11, i64 0}
!19 = !{!15, !11, i64 56}
!20 = !{!10, !6, i64 8}
!21 = !{!10, !11, i64 4}
!22 = !{!10, !12, i64 276}
!23 = !{!10, !11, i64 272}
!24 = !{!10, !6, i64 288}


; 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.22 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.23 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.24 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.25 = external hidden unnamed_addr constant [9 x i8], align 1

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

; Function Attrs: nounwind uwtable
define dso_local void @npy_pp_print_arr(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = getelementptr inbounds i8, ptr %0, i64 280
  store i64 0, ptr %3, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %1, i64 8
  %5 = load i8, ptr %4, align 8, !tbaa !13
  %6 = tail call i64 @cell_width(ptr noundef %0, ptr noundef %1)
  %7 = trunc i64 %6 to i32
  %8 = icmp eq i8 %5, 83
  br i1 %8, label %9, label %12

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %0, i64 16
  %11 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %10, ptr noundef nonnull dereferenceable(1) @.str.22, i32 noundef %7, i32 noundef %7) #3
  br label %22

12:                                               ; preds = %2
  %13 = load i8, ptr %4, align 8, !tbaa !13
  %14 = getelementptr inbounds i8, ptr %0, i64 16
  switch i8 %13, label %19 [
    i8 105, label %15
    i8 117, label %17
  ]

15:                                               ; preds = %12
  %16 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %14, ptr noundef nonnull dereferenceable(1) @.str.23, i32 noundef %7) #3
  br label %22

17:                                               ; preds = %12
  %18 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %14, ptr noundef nonnull dereferenceable(1) @.str.24, i32 noundef %7) #3
  br label %22

19:                                               ; preds = %12
  %20 = load i32, ptr %0, align 8, !tbaa !15
  %21 = tail call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %14, ptr noundef nonnull dereferenceable(1) @.str.25, i32 noundef %7, i32 noundef %20) #3
  br label %22

22:                                               ; preds = %15, %19, %17, %9
  %23 = getelementptr inbounds i8, ptr %1, i64 56
  %24 = load i32, ptr %23, align 8, !tbaa !16
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  %26 = load ptr, ptr %25, align 8, !tbaa !17
  %27 = tail call i64 @strlen(ptr noundef nonnull dereferenceable(1) %26) #4
  %28 = trunc i64 %27 to i32
  %29 = getelementptr inbounds i8, ptr %1, i64 16
  %30 = add nsw i32 %24, -1
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [10 x i32], ptr %29, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !18
  %34 = add nsw i32 %28, %7
  %35 = mul nsw i32 %34, %33
  %36 = getelementptr inbounds i8, ptr %0, i64 4
  %37 = load i32, ptr %36, align 4, !tbaa !19
  %38 = icmp sgt i32 %35, %37
  %39 = getelementptr inbounds i8, ptr %0, i64 276
  %40 = zext i1 %38 to i8
  store i8 %40, ptr %39, align 4, !tbaa !20
  %41 = sub nsw i32 %37, %24
  %42 = sdiv i32 %41, %34
  %43 = getelementptr inbounds i8, ptr %0, i64 272
  store i32 %42, ptr %43, align 8, !tbaa !21
  store i64 0, ptr %3, align 8, !tbaa !5
  %44 = getelementptr inbounds i8, ptr %0, i64 288
  store ptr %1, ptr %44, align 8, !tbaa !22
  tail call void @pp_rec(ptr noundef nonnull %0, i32 noundef 0, i1 noundef zeroext true)
  ret void
}

; Function Attrs: nounwind uwtable
declare hidden i64 @cell_width(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @pp_rec(ptr noundef, i32 noundef, i1 noundef zeroext) local_unnamed_addr #1

attributes #0 = { 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 #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 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 }
attributes #4 = { nounwind willreturn memory(read) }

!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, !12, i64 280}
!6 = !{!"", !7, i64 0, !7, i64 4, !10, i64 8, !8, i64 16, !7, i64 272, !11, i64 276, !12, i64 280, !10, i64 288}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"_Bool", !8, i64 0}
!12 = !{!"long", !8, i64 0}
!13 = !{!14, !8, i64 8}
!14 = !{!"", !7, i64 0, !7, i64 4, !8, i64 8, !7, i64 12, !8, i64 16, !7, i64 56, !10, i64 64, !7, i64 72}
!15 = !{!6, !7, i64 0}
!16 = !{!14, !7, i64 56}
!17 = !{!6, !10, i64 8}
!18 = !{!7, !7, i64 0}
!19 = !{!6, !7, i64 4}
!20 = !{!6, !11, i64 276}
!21 = !{!6, !7, i64 272}
!22 = !{!6, !10, i64 288}


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