; LLVM IR from AllAlgorithms/c :: algorithms (sparse_matrix_addition)

; 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.sparse = type { i32, i32, i32, [20 x i32], [20 x i32], [20 x i32] }

@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [60 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @addMatrix(ptr dead_on_unwind noalias writable sret(%struct.sparse) align 4, ptr noundef byval(%struct.sparse) align 8, ptr noundef byval(%struct.sparse) align 8) #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 uwtable
declare dso_local void @readMatrix(ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @printMatrix(ptr noundef byval(%struct.sparse) align 8) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca %struct.sparse, align 8
  %3 = alloca %struct.sparse, align 8
  %4 = alloca %struct.sparse, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 252, ptr %2) #3
  call void @llvm.lifetime.start.p0(i64 252, ptr %3) #3
  %5 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  call void @readMatrix(ptr noundef %2)
  %6 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  call void @readMatrix(ptr noundef %3)
  %7 = call i32 (ptr, ...) @printf(ptr noundef @.str.11)
  call void @printMatrix(ptr noundef byval(%struct.sparse) align 8 %2)
  %8 = call i32 (ptr, ...) @printf(ptr noundef @.str.12)
  call void @printMatrix(ptr noundef byval(%struct.sparse) align 8 %3)
  %9 = getelementptr inbounds %struct.sparse, ptr %2, i32 0, i32 0
  %10 = load i32, ptr %9, align 4, !tbaa !5
  %11 = getelementptr inbounds %struct.sparse, ptr %3, i32 0, i32 0
  %12 = load i32, ptr %11, align 4, !tbaa !5
  %13 = icmp eq i32 %10, %12
  br i1 %13, label %14, label %22

14:                                               ; preds = %0
  %15 = getelementptr inbounds %struct.sparse, ptr %2, i32 0, i32 1
  %16 = load i32, ptr %15, align 4, !tbaa !10
  %17 = getelementptr inbounds %struct.sparse, ptr %3, i32 0, i32 1
  %18 = load i32, ptr %17, align 4, !tbaa !10
  %19 = icmp eq i32 %16, %18
  br i1 %19, label %20, label %22

20:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 252, ptr %4) #3
  call void @addMatrix(ptr dead_on_unwind writable sret(%struct.sparse) align 4 %4, ptr noundef byval(%struct.sparse) align 8 %2, ptr noundef byval(%struct.sparse) align 8 %3)
  %21 = call i32 (ptr, ...) @printf(ptr noundef @.str.13)
  call void @printMatrix(ptr noundef byval(%struct.sparse) align 8 %4)
  call void @llvm.lifetime.end.p0(i64 252, ptr %4) #3
  br label %24

22:                                               ; preds = %14, %0
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.14)
  br label %24

24:                                               ; preds = %22, %20
  call void @llvm.lifetime.end.p0(i64 252, ptr %3) #3
  call void @llvm.lifetime.end.p0(i64 252, ptr %2) #3
  ret i32 0
}

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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 }

!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 = !{!"sparse", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !8, i64 92, !8, i64 172}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}


; 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.sparse = type { i32, i32, i32, [20 x i32], [20 x i32], [20 x i32] }

@.str.9 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [18 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.13 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.14 = external hidden unnamed_addr constant [60 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @addMatrix(ptr dead_on_unwind noalias writable sret(%struct.sparse) align 4, ptr noundef byval(%struct.sparse) align 8, ptr noundef byval(%struct.sparse) align 8) 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: nounwind uwtable
declare dso_local void @readMatrix(ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @printMatrix(ptr noundef byval(%struct.sparse) align 8) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca %struct.sparse, align 8
  %2 = alloca %struct.sparse, align 8
  %3 = alloca %struct.sparse, align 8
  call void @llvm.lifetime.start.p0(i64 252, ptr nonnull %1) #3
  call void @llvm.lifetime.start.p0(i64 252, ptr nonnull %2) #3
  %4 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  call void @readMatrix(ptr noundef nonnull %1)
  %5 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  call void @readMatrix(ptr noundef nonnull %2)
  %6 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.11)
  call void @printMatrix(ptr noundef nonnull byval(%struct.sparse) align 8 %1)
  %7 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.12)
  call void @printMatrix(ptr noundef nonnull byval(%struct.sparse) align 8 %2)
  %8 = load i32, ptr %1, align 8, !tbaa !5
  %9 = load i32, ptr %2, align 8, !tbaa !5
  %10 = icmp eq i32 %8, %9
  br i1 %10, label %11, label %19

11:                                               ; preds = %0
  %12 = getelementptr inbounds i8, ptr %1, i64 4
  %13 = load i32, ptr %12, align 4, !tbaa !10
  %14 = getelementptr inbounds i8, ptr %2, i64 4
  %15 = load i32, ptr %14, align 4, !tbaa !10
  %16 = icmp eq i32 %13, %15
  br i1 %16, label %17, label %19

17:                                               ; preds = %11
  call void @llvm.lifetime.start.p0(i64 252, ptr nonnull %3) #3
  call void @addMatrix(ptr dead_on_unwind nonnull writable sret(%struct.sparse) align 4 %3, ptr noundef nonnull byval(%struct.sparse) align 8 %1, ptr noundef nonnull byval(%struct.sparse) align 8 %2)
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.13)
  call void @printMatrix(ptr noundef nonnull byval(%struct.sparse) align 8 %3)
  call void @llvm.lifetime.end.p0(i64 252, ptr nonnull %3) #3
  br label %21

19:                                               ; preds = %11, %0
  %20 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.14)
  br label %21

21:                                               ; preds = %19, %17
  call void @llvm.lifetime.end.p0(i64 252, ptr nonnull %2) #3
  call void @llvm.lifetime.end.p0(i64 252, ptr nonnull %1) #3
  ret i32 0
}

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 = { 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 = { 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 = !{!"sparse", !7, i64 0, !7, i64 4, !7, i64 8, !8, i64 12, !8, i64 92, !8, i64 172}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 4}


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