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

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

@.str.34 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.60 = external hidden unnamed_addr constant [35 x i8], align 1
@__PRETTY_FUNCTION__.sim_config_save_spikes = external hidden unnamed_addr constant [53 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare hidden ptr @device_type_name(i32 noundef) #1

; Function Attrs: nounwind uwtable
declare hidden ptr @algo_name(i32 noundef) #1

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

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

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
define dso_local void @sim_config_save_spikes(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca [256 x i8], align 16
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 256, ptr %5) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.sim_config, ptr %8, i32 0, i32 6
  %10 = load i8, ptr %9, align 8, !tbaa !9, !range !14, !noundef !15
  %11 = trunc i8 %10 to i1
  %12 = zext i1 %11 to i64
  %13 = select i1 %11, ptr @.str.34, ptr @.str.35
  store ptr %13, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %14 = load ptr, ptr %3, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.sim_config, ptr %14, i32 0, i32 0
  %16 = load i32, ptr %15, align 8, !tbaa !16
  store i32 %16, ptr %7, align 4, !tbaa !17
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.sim_config, ptr %17, i32 0, i32 2
  %19 = load i8, ptr %18, align 8, !tbaa !18, !range !14, !noundef !15
  %20 = trunc i8 %19 to i1
  br i1 %20, label %21, label %26

21:                                               ; preds = %2
  %22 = getelementptr inbounds [256 x i8], ptr %5, i64 0, i64 0
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = load i32, ptr %7, align 4, !tbaa !17
  %25 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %22, ptr noundef @.str.57, ptr noundef %23, i32 noundef %24) #5
  br label %44

26:                                               ; preds = %2
  %27 = getelementptr inbounds [256 x i8], ptr %5, i64 0, i64 0
  %28 = load ptr, ptr %3, align 8, !tbaa !5
  %29 = getelementptr inbounds %struct.sim_config, ptr %28, i32 0, i32 7
  %30 = load i32, ptr %29, align 4, !tbaa !19
  %31 = call ptr @device_type_name(i32 noundef %30)
  %32 = load ptr, ptr %3, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.sim_config, ptr %32, i32 0, i32 8
  %34 = load i32, ptr %33, align 8, !tbaa !20
  %35 = call ptr @algo_name(i32 noundef %34)
  %36 = load ptr, ptr %3, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.sim_config, ptr %36, i32 0, i32 9
  %38 = load i8, ptr %37, align 4, !tbaa !21, !range !14, !noundef !15
  %39 = trunc i8 %38 to i1
  %40 = call ptr @multi_tag(i1 noundef zeroext %39)
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i32, ptr %7, align 4, !tbaa !17
  %43 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef %27, ptr noundef @.str.58, ptr noundef %31, ptr noundef %35, ptr noundef %40, ptr noundef %41, i32 noundef %42) #5
  br label %44

44:                                               ; preds = %26, %21
  %45 = getelementptr inbounds [256 x i8], ptr %5, i64 0, i64 0
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.59, ptr noundef %45)
  %47 = load ptr, ptr %4, align 8, !tbaa !5
  %48 = getelementptr inbounds [256 x i8], ptr %5, i64 0, i64 0
  %49 = call i32 @npy_save(ptr noundef %47, ptr noundef %48)
  %50 = icmp eq i32 %49, 0
  br i1 %50, label %51, label %52

51:                                               ; preds = %44
  br label %53

52:                                               ; preds = %44
  call void @__assert_fail(ptr noundef @.str.60, ptr noundef @.str.47, i32 noundef 368, ptr noundef @__PRETTY_FUNCTION__.sim_config_save_spikes) #6
  unreachable

53:                                               ; preds = %51
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 256, ptr %5) #5
  ret void
}

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

; Function Attrs: nounwind uwtable
declare hidden ptr @multi_tag(i1 noundef zeroext) #1

declare i32 @npy_save(ptr noundef, ptr noundef) #0

attributes #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 = { 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 }
attributes #6 = { noreturn 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, !12, i64 40}
!10 = !{!"", !11, i64 0, !6, i64 8, !12, i64 16, !6, i64 24, !11, i64 32, !11, i64 36, !12, i64 40, !11, i64 44, !11, i64 48, !12, i64 52, !13, i64 56, !13, i64 64, !13, i64 72, !13, i64 80, !13, i64 88, !13, i64 96, !13, i64 104, !7, i64 112, !11, i64 116, !6, i64 120, !11, i64 128, !6, i64 136, !6, i64 144, !11, i64 152, !6, i64 160, !6, i64 168}
!11 = !{!"int", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!"double", !7, i64 0}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !11, i64 0}
!17 = !{!11, !11, i64 0}
!18 = !{!10, !12, i64 16}
!19 = !{!10, !11, i64 44}
!20 = !{!10, !11, i64 48}
!21 = !{!10, !12, i64 52}


; 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.34 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.35 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.47 = external hidden unnamed_addr constant [72 x i8], align 1
@.str.57 = external hidden unnamed_addr constant [16 x i8], align 1
@.str.58 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.59 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.60 = external hidden unnamed_addr constant [35 x i8], align 1
@__PRETTY_FUNCTION__.sim_config_save_spikes = external hidden unnamed_addr constant [53 x i8], align 1

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

; Function Attrs: nounwind uwtable
declare hidden ptr @device_type_name(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden ptr @algo_name(i32 noundef) local_unnamed_addr #1

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

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

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

; Function Attrs: nounwind uwtable
define dso_local void @sim_config_save_spikes(ptr nocapture noundef readonly %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca [256 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 256, ptr nonnull %3) #5
  %4 = getelementptr inbounds i8, ptr %0, i64 40
  %5 = load i8, ptr %4, align 8, !tbaa !5, !range !13, !noundef !14
  %6 = trunc nuw i8 %5 to i1
  %7 = select i1 %6, ptr @.str.34, ptr @.str.35
  %8 = load i32, ptr %0, align 8, !tbaa !15
  %9 = getelementptr inbounds i8, ptr %0, i64 16
  %10 = load i8, ptr %9, align 8, !tbaa !16, !range !13, !noundef !14
  %11 = trunc nuw i8 %10 to i1
  br i1 %11, label %12, label %14

12:                                               ; preds = %2
  %13 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.57, ptr noundef nonnull %7, i32 noundef %8) #5
  br label %26

14:                                               ; preds = %2
  %15 = getelementptr inbounds i8, ptr %0, i64 44
  %16 = load i32, ptr %15, align 4, !tbaa !17
  %17 = tail call ptr @device_type_name(i32 noundef %16)
  %18 = getelementptr inbounds i8, ptr %0, i64 48
  %19 = load i32, ptr %18, align 8, !tbaa !18
  %20 = tail call ptr @algo_name(i32 noundef %19)
  %21 = getelementptr inbounds i8, ptr %0, i64 52
  %22 = load i8, ptr %21, align 4, !tbaa !19, !range !13, !noundef !14
  %23 = trunc nuw i8 %22 to i1
  %24 = tail call ptr @multi_tag(i1 noundef zeroext %23)
  %25 = call i32 (ptr, ptr, ...) @sprintf(ptr noundef nonnull dereferenceable(1) %3, ptr noundef nonnull dereferenceable(1) @.str.58, ptr noundef %17, ptr noundef %20, ptr noundef %24, ptr noundef nonnull %7, i32 noundef %8) #5
  br label %26

26:                                               ; preds = %14, %12
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.59, ptr noundef nonnull %3)
  %28 = call i32 @npy_save(ptr noundef %1, ptr noundef nonnull %3) #5
  %29 = icmp eq i32 %28, 0
  br i1 %29, label %31, label %30

30:                                               ; preds = %26
  call void @__assert_fail(ptr noundef nonnull @.str.60, ptr noundef nonnull @.str.47, i32 noundef 368, ptr noundef nonnull @__PRETTY_FUNCTION__.sim_config_save_spikes) #6
  unreachable

31:                                               ; preds = %26
  call void @llvm.lifetime.end.p0(i64 256, ptr nonnull %3) #5
  ret void
}

; 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
declare hidden ptr @multi_tag(i1 noundef zeroext) local_unnamed_addr #1

declare i32 @npy_save(ptr noundef, ptr noundef) local_unnamed_addr #4

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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { nounwind }
attributes #6 = { noreturn 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, !11, i64 40}
!6 = !{!"", !7, i64 0, !10, i64 8, !11, i64 16, !10, i64 24, !7, i64 32, !7, i64 36, !11, i64 40, !7, i64 44, !7, i64 48, !11, i64 52, !12, i64 56, !12, i64 64, !12, i64 72, !12, i64 80, !12, i64 88, !12, i64 96, !12, i64 104, !8, i64 112, !7, i64 116, !10, i64 120, !7, i64 128, !10, i64 136, !10, i64 144, !7, i64 152, !10, i64 160, !10, i64 168}
!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 = !{!"double", !8, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!6, !7, i64 0}
!16 = !{!6, !11, i64 16}
!17 = !{!6, !7, i64 44}
!18 = !{!6, !7, i64 48}
!19 = !{!6, !11, i64 52}


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