; LLVM IR from cvxgrp/scs :: src/rw.ll (scs_read_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"

@.str.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [189 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [119 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [230 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [24 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

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

declare i32 @fclose(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 i32 @_scs_read_data(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca [16 x i8], align 16
  %14 = alloca ptr, align 8
  %15 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store ptr %3, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #6
  %16 = call ptr @__errno_location() #7
  store i32 0, ptr %16, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %17 = load ptr, ptr %6, align 8, !tbaa !5
  %18 = call noalias ptr @fopen(ptr noundef %17, ptr noundef @.str.2)
  store ptr %18, ptr %14, align 8, !tbaa !5
  %19 = load ptr, ptr %14, align 8, !tbaa !5
  %20 = icmp ne ptr %19, null
  br i1 %20, label %30, label %21

21:                                               ; preds = %4
  %22 = load ptr, ptr %6, align 8, !tbaa !5
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.3, ptr noundef %22)
  %24 = call ptr @__errno_location() #7
  %25 = load i32, ptr %24, align 4, !tbaa !9
  %26 = call ptr @__errno_location() #7
  %27 = load i32, ptr %26, align 4, !tbaa !9
  %28 = call ptr @strerror(i32 noundef %27) #6
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.4, i32 noundef %25, ptr noundef %28)
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %88

30:                                               ; preds = %4
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %31)
  %33 = load ptr, ptr %14, align 8, !tbaa !5
  %34 = call i64 @fread(ptr noundef %10, i64 noundef 4, i64 noundef 1, ptr noundef %33)
  %35 = load ptr, ptr %14, align 8, !tbaa !5
  %36 = call i64 @fread(ptr noundef %11, i64 noundef 4, i64 noundef 1, ptr noundef %35)
  %37 = load i32, ptr %10, align 4, !tbaa !9
  %38 = icmp ne i32 %37, 4
  br i1 %38, label %39, label %43

39:                                               ; preds = %30
  %40 = load i32, ptr %10, align 4, !tbaa !9
  %41 = zext i32 %40 to i64
  %42 = call i32 (ptr, ...) @printf(ptr noundef @.str.6, i64 noundef %41, i64 noundef 4)
  br label %43

43:                                               ; preds = %39, %30
  %44 = load i32, ptr %11, align 4, !tbaa !9
  %45 = icmp ne i32 %44, 8
  br i1 %45, label %46, label %52

46:                                               ; preds = %43
  %47 = load i32, ptr %11, align 4, !tbaa !9
  %48 = zext i32 %47 to i64
  %49 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, i64 noundef %48, i64 noundef 8)
  %50 = load ptr, ptr %14, align 8, !tbaa !5
  %51 = call i32 @fclose(ptr noundef %50)
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %88

52:                                               ; preds = %43
  %53 = load ptr, ptr %14, align 8, !tbaa !5
  %54 = call i64 @fread(ptr noundef %12, i64 noundef 4, i64 noundef 1, ptr noundef %53)
  %55 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 0
  %56 = load i32, ptr %12, align 4, !tbaa !9
  %57 = zext i32 %56 to i64
  %58 = load ptr, ptr %14, align 8, !tbaa !5
  %59 = call i64 @fread(ptr noundef %55, i64 noundef 1, i64 noundef %57, ptr noundef %58)
  %60 = load i32, ptr %12, align 4, !tbaa !9
  %61 = zext i32 %60 to i64
  %62 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 %61
  store i8 0, ptr %62, align 1, !tbaa !11
  %63 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 0
  %64 = call i32 @strcmp(ptr noundef %63, ptr noundef @.str.1) #8
  %65 = icmp ne i32 %64, 0
  br i1 %65, label %66, label %69

66:                                               ; preds = %52
  %67 = getelementptr inbounds [16 x i8], ptr %13, i64 0, i64 0
  %68 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, ptr noundef %67, ptr noundef @.str.1)
  br label %69

69:                                               ; preds = %66, %52
  %70 = load ptr, ptr %14, align 8, !tbaa !5
  %71 = load i32, ptr %10, align 4, !tbaa !9
  %72 = zext i32 %71 to i64
  %73 = call ptr @read_scs_cone(ptr noundef %70, i64 noundef %72)
  %74 = load ptr, ptr %8, align 8, !tbaa !5
  store ptr %73, ptr %74, align 8, !tbaa !5
  %75 = load ptr, ptr %14, align 8, !tbaa !5
  %76 = load i32, ptr %10, align 4, !tbaa !9
  %77 = zext i32 %76 to i64
  %78 = call ptr @read_scs_data(ptr noundef %75, i64 noundef %77)
  %79 = load ptr, ptr %7, align 8, !tbaa !5
  store ptr %78, ptr %79, align 8, !tbaa !5
  %80 = load ptr, ptr %14, align 8, !tbaa !5
  %81 = load i32, ptr %10, align 4, !tbaa !9
  %82 = zext i32 %81 to i64
  %83 = call ptr @read_scs_stgs(ptr noundef %80, i64 noundef %82)
  %84 = load ptr, ptr %9, align 8, !tbaa !5
  store ptr %83, ptr %84, align 8, !tbaa !5
  %85 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %86 = load ptr, ptr %14, align 8, !tbaa !5
  %87 = call i32 @fclose(ptr noundef %86)
  store i32 0, ptr %5, align 4
  store i32 1, ptr %15, align 4
  br label %88

88:                                               ; preds = %69, %46, %21
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #6
  %89 = load i32, ptr %5, align 4
  ret i32 %89
}

; Function Attrs: nounwind willreturn memory(none)
declare ptr @__errno_location() #3

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) #4

declare i64 @fread(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind willreturn memory(read)
declare i32 @strcmp(ptr noundef, ptr noundef) #5

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

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

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

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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(none) "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 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }
attributes #8 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}


; 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.1 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [3 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [189 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [119 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [230 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [24 x i8], align 1

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

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

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

; Function Attrs: mustprogress 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 range(i32 -1, 1) i32 @_scs_read_data(ptr noundef %0, ptr nocapture noundef writeonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #2 {
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  %7 = alloca i32, align 4
  %8 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %7) #6
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #6
  %9 = tail call ptr @__errno_location() #7
  store i32 0, ptr %9, align 4, !tbaa !5
  %10 = tail call noalias ptr @fopen(ptr noundef %0, ptr noundef nonnull @.str.2)
  %.not = icmp eq ptr %10, null
  br i1 %.not, label %11, label %16

11:                                               ; preds = %4
  %12 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3, ptr noundef %0)
  %13 = load i32, ptr %9, align 4, !tbaa !5
  %14 = tail call ptr @strerror(i32 noundef %13) #6
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4, i32 noundef %13, ptr noundef %14)
  br label %46

16:                                               ; preds = %4
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef %0)
  %18 = call i64 @fread(ptr noundef nonnull %5, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %10)
  %19 = call i64 @fread(ptr noundef nonnull %6, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %10)
  %20 = load i32, ptr %5, align 4, !tbaa !5
  %.not19 = icmp eq i32 %20, 4
  br i1 %.not19, label %24, label %21

21:                                               ; preds = %16
  %22 = zext i32 %20 to i64
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6, i64 noundef %22, i64 noundef 4)
  br label %24

24:                                               ; preds = %21, %16
  %25 = load i32, ptr %6, align 4, !tbaa !5
  %.not20 = icmp eq i32 %25, 8
  br i1 %.not20, label %30, label %26

26:                                               ; preds = %24
  %27 = zext i32 %25 to i64
  %28 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, i64 noundef %27, i64 noundef 8)
  %29 = tail call i32 @fclose(ptr noundef nonnull %10)
  br label %46

30:                                               ; preds = %24
  %31 = call i64 @fread(ptr noundef nonnull %7, i64 noundef 4, i64 noundef 1, ptr noundef nonnull %10)
  %32 = load i32, ptr %7, align 4, !tbaa !5
  %33 = zext i32 %32 to i64
  %34 = call i64 @fread(ptr noundef nonnull %8, i64 noundef 1, i64 noundef %33, ptr noundef nonnull %10)
  %35 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 %33
  store i8 0, ptr %35, align 1, !tbaa !9
  %36 = call i32 @strcmp(ptr noundef nonnull dereferenceable(1) %8, ptr noundef nonnull dereferenceable(1) @.str.1) #8
  %.not21 = icmp eq i32 %36, 0
  br i1 %.not21, label %39, label %37

37:                                               ; preds = %30
  %38 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, ptr noundef nonnull %8, ptr noundef nonnull @.str.1)
  br label %39

39:                                               ; preds = %37, %30
  %40 = zext i32 %20 to i64
  %41 = call ptr @read_scs_cone(ptr noundef nonnull %10, i64 noundef %40)
  store ptr %41, ptr %2, align 8, !tbaa !10
  %42 = call ptr @read_scs_data(ptr noundef nonnull %10, i64 noundef %40)
  store ptr %42, ptr %1, align 8, !tbaa !10
  %43 = call ptr @read_scs_stgs(ptr noundef nonnull %10, i64 noundef %40)
  store ptr %43, ptr %3, align 8, !tbaa !10
  %44 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  %45 = call i32 @fclose(ptr noundef nonnull %10)
  br label %46

46:                                               ; preds = %39, %26, %11
  %.0 = phi i32 [ -1, %26 ], [ 0, %39 ], [ -1, %11 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %7) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #6
  ret i32 %.0
}

; Function Attrs: mustprogress nofree nosync nounwind willreturn memory(none)
declare ptr @__errno_location() local_unnamed_addr #3

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

; Function Attrs: nounwind
declare ptr @strerror(i32 noundef) local_unnamed_addr #4

; Function Attrs: nofree nounwind
declare noundef i64 @fread(ptr nocapture noundef, i64 noundef, i64 noundef, ptr nocapture noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i32 @strcmp(ptr nocapture noundef, ptr nocapture noundef) local_unnamed_addr #5

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

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

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

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 nofree nosync nounwind willreturn memory(none) "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 = { 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(none) }
attributes #8 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"any pointer", !7, i64 0}


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