; LLVM IR from robertklee/C-Optimization-DCT :: src/util (helpers)

; 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.9 = external hidden unnamed_addr constant [343 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [64 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 i32 @printf(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: noreturn nounwind
declare void @exit(i32 noundef) #2

; Function Attrs: nounwind uwtable
define dso_local void @read_arguments(i32 noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #3 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  %14 = alloca ptr, align 8
  %15 = alloca ptr, align 8
  %16 = alloca ptr, align 8
  %17 = alloca i64, align 8
  %18 = alloca i64, align 8
  %19 = alloca i32, align 4
  %20 = alloca ptr, align 8
  store i32 %0, ptr %7, align 4, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !9
  store ptr %2, ptr %9, align 8, !tbaa !9
  store ptr %3, ptr %10, align 8, !tbaa !9
  store ptr %4, ptr %11, align 8, !tbaa !9
  store ptr %5, ptr %12, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %13) #6
  store ptr @.str.9, ptr %13, align 8, !tbaa !9
  %21 = load i32, ptr %7, align 4, !tbaa !5
  %22 = icmp ne i32 %21, 4
  br i1 %22, label %23, label %28

23:                                               ; preds = %6
  %24 = load i32, ptr %7, align 4, !tbaa !5
  %25 = icmp ne i32 %24, 5
  br i1 %25, label %26, label %28

26:                                               ; preds = %23
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  call void @exit(i32 noundef -1) #7
  unreachable

28:                                               ; preds = %23, %6
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #6
  %29 = load ptr, ptr %8, align 8, !tbaa !9
  %30 = getelementptr inbounds ptr, ptr %29, i64 1
  %31 = load ptr, ptr %30, align 8, !tbaa !9
  store ptr %31, ptr %14, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #6
  %32 = load ptr, ptr %8, align 8, !tbaa !9
  %33 = getelementptr inbounds ptr, ptr %32, i64 2
  %34 = load ptr, ptr %33, align 8, !tbaa !9
  store ptr %34, ptr %15, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #6
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = getelementptr inbounds ptr, ptr %35, i64 3
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  store ptr %37, ptr %16, align 8, !tbaa !9
  %38 = call ptr @__errno_location() #8
  store i32 0, ptr %38, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %17) #6
  %39 = load ptr, ptr %15, align 8, !tbaa !9
  %40 = call i64 @strtol(ptr noundef %39, ptr noundef null, i32 noundef 10) #6
  store i64 %40, ptr %17, align 8, !tbaa !11
  %41 = call ptr @__errno_location() #8
  %42 = load i32, ptr %41, align 4, !tbaa !5
  %43 = icmp eq i32 %42, 34
  br i1 %43, label %47, label %44

44:                                               ; preds = %28
  %45 = load i64, ptr %17, align 8, !tbaa !11
  %46 = icmp sle i64 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %44, %28
  %48 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  call void @exit(i32 noundef -1) #7
  unreachable

49:                                               ; preds = %44
  call void @llvm.lifetime.start.p0(i64 8, ptr %18) #6
  %50 = load ptr, ptr %16, align 8, !tbaa !9
  %51 = call i64 @strtol(ptr noundef %50, ptr noundef null, i32 noundef 10) #6
  store i64 %51, ptr %18, align 8, !tbaa !11
  %52 = call ptr @__errno_location() #8
  %53 = load i32, ptr %52, align 4, !tbaa !5
  %54 = icmp eq i32 %53, 34
  br i1 %54, label %58, label %55

55:                                               ; preds = %49
  %56 = load i64, ptr %18, align 8, !tbaa !11
  %57 = icmp sle i64 %56, 0
  br i1 %57, label %58, label %60

58:                                               ; preds = %55, %49
  %59 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  call void @exit(i32 noundef -1) #7
  unreachable

60:                                               ; preds = %55
  call void @llvm.lifetime.start.p0(i64 4, ptr %19) #6
  store i32 0, ptr %19, align 4, !tbaa !5
  %61 = load i32, ptr %7, align 4, !tbaa !5
  %62 = icmp eq i32 %61, 5
  br i1 %62, label %63, label %76

63:                                               ; preds = %60
  call void @llvm.lifetime.start.p0(i64 8, ptr %20) #6
  %64 = load ptr, ptr %8, align 8, !tbaa !9
  %65 = getelementptr inbounds ptr, ptr %64, i64 4
  %66 = load ptr, ptr %65, align 8, !tbaa !9
  store ptr %66, ptr %20, align 8, !tbaa !9
  %67 = load ptr, ptr %20, align 8, !tbaa !9
  %68 = call i64 @strtol(ptr noundef %67, ptr noundef null, i32 noundef 10) #6
  %69 = trunc i64 %68 to i32
  store i32 %69, ptr %19, align 4, !tbaa !5
  %70 = call ptr @__errno_location() #8
  %71 = load i32, ptr %70, align 4, !tbaa !5
  %72 = icmp eq i32 %71, 34
  br i1 %72, label %73, label %75

73:                                               ; preds = %63
  %74 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  call void @exit(i32 noundef -1) #7
  unreachable

75:                                               ; preds = %63
  call void @llvm.lifetime.end.p0(i64 8, ptr %20) #6
  br label %76

76:                                               ; preds = %75, %60
  %77 = load i64, ptr %17, align 8, !tbaa !11
  %78 = srem i64 %77, 8
  %79 = icmp ne i64 %78, 0
  br i1 %79, label %90, label %80

80:                                               ; preds = %76
  %81 = load i64, ptr %18, align 8, !tbaa !11
  %82 = srem i64 %81, 8
  %83 = icmp ne i64 %82, 0
  br i1 %83, label %90, label %84

84:                                               ; preds = %80
  %85 = load i64, ptr %17, align 8, !tbaa !11
  %86 = icmp slt i64 %85, 0
  br i1 %86, label %90, label %87

87:                                               ; preds = %84
  %88 = load i64, ptr %18, align 8, !tbaa !11
  %89 = icmp slt i64 %88, 0
  br i1 %89, label %90, label %92

90:                                               ; preds = %87, %84, %80, %76
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.10)
  call void @exit(i32 noundef -1) #7
  unreachable

92:                                               ; preds = %87
  %93 = load ptr, ptr %14, align 8, !tbaa !9
  %94 = load ptr, ptr %9, align 8, !tbaa !9
  store ptr %93, ptr %94, align 8, !tbaa !9
  %95 = load i64, ptr %17, align 8, !tbaa !11
  %96 = load ptr, ptr %10, align 8, !tbaa !9
  store i64 %95, ptr %96, align 8, !tbaa !11
  %97 = load i64, ptr %18, align 8, !tbaa !11
  %98 = load ptr, ptr %11, align 8, !tbaa !9
  store i64 %97, ptr %98, align 8, !tbaa !11
  %99 = load i32, ptr %19, align 4, !tbaa !5
  %100 = load ptr, ptr %12, align 8, !tbaa !9
  store i32 %99, ptr %100, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %19) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %18) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %17) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #6
  ret void
}

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

; Function Attrs: nounwind
declare i64 @strtol(ptr noundef, ptr noundef, i32 noundef) #5

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 = { 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 #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 = { 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { noreturn nounwind }
attributes #8 = { nounwind willreturn memory(none) }

!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 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !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.9 = external hidden unnamed_addr constant [343 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [64 x i8], align 1

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

; Function Attrs: noreturn nounwind
declare void @exit(i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local void @read_arguments(i32 noundef %0, ptr nocapture noundef readonly %1, ptr nocapture noundef writeonly %2, ptr nocapture noundef writeonly %3, ptr nocapture noundef writeonly %4, ptr nocapture noundef writeonly %5) local_unnamed_addr #2 {
  %7 = add i32 %0, -6
  %or.cond = icmp ult i32 %7, -2
  br i1 %or.cond, label %8, label %10

8:                                                ; preds = %6
  %9 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  tail call void @exit(i32 noundef -1) #5
  unreachable

10:                                               ; preds = %6
  %11 = getelementptr inbounds i8, ptr %1, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %13 = getelementptr inbounds i8, ptr %1, i64 16
  %14 = load ptr, ptr %13, align 8, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %1, i64 24
  %16 = load ptr, ptr %15, align 8, !tbaa !5
  %17 = tail call ptr @__errno_location() #6
  store i32 0, ptr %17, align 4, !tbaa !9
  %18 = tail call i64 @strtol(ptr nocapture noundef %14, ptr noundef null, i32 noundef 10) #7
  %19 = load i32, ptr %17, align 4, !tbaa !9
  %20 = icmp eq i32 %19, 34
  %21 = icmp slt i64 %18, 1
  %or.cond3 = select i1 %20, i1 true, i1 %21
  br i1 %or.cond3, label %22, label %24

22:                                               ; preds = %10
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  tail call void @exit(i32 noundef -1) #5
  unreachable

24:                                               ; preds = %10
  %25 = tail call i64 @strtol(ptr nocapture noundef %16, ptr noundef null, i32 noundef 10) #7
  %26 = load i32, ptr %17, align 4, !tbaa !9
  %27 = icmp eq i32 %26, 34
  %28 = icmp slt i64 %25, 1
  %or.cond5 = select i1 %27, i1 true, i1 %28
  br i1 %or.cond5, label %29, label %31

29:                                               ; preds = %24
  %30 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  tail call void @exit(i32 noundef -1) #5
  unreachable

31:                                               ; preds = %24
  %32 = icmp eq i32 %0, 5
  br i1 %32, label %33, label %43

33:                                               ; preds = %31
  %34 = getelementptr inbounds i8, ptr %1, i64 32
  %35 = load ptr, ptr %34, align 8, !tbaa !5
  %36 = tail call i64 @strtol(ptr nocapture noundef %35, ptr noundef null, i32 noundef 10) #7
  %37 = load i32, ptr %17, align 4, !tbaa !9
  %38 = icmp eq i32 %37, 34
  br i1 %38, label %39, label %41

39:                                               ; preds = %33
  %40 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  tail call void @exit(i32 noundef -1) #5
  unreachable

41:                                               ; preds = %33
  %42 = trunc i64 %36 to i32
  br label %43

43:                                               ; preds = %41, %31
  %.0 = phi i32 [ %42, %41 ], [ 0, %31 ]
  %44 = and i64 %18, 7
  %.not = icmp eq i64 %44, 0
  %45 = and i64 %25, 7
  %.not34 = icmp eq i64 %45, 0
  %or.cond35 = select i1 %.not, i1 %.not34, i1 false
  br i1 %or.cond35, label %48, label %46

46:                                               ; preds = %43
  %47 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.10)
  tail call void @exit(i32 noundef -1) #5
  unreachable

48:                                               ; preds = %43
  store ptr %12, ptr %2, align 8, !tbaa !5
  store i64 %18, ptr %3, align 8, !tbaa !11
  store i64 %25, ptr %4, align 8, !tbaa !11
  store i32 %.0, ptr %5, align 4, !tbaa !9
  ret void
}

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

; Function Attrs: mustprogress nofree nounwind willreturn
declare i64 @strtol(ptr noundef readonly, ptr nocapture noundef, i32 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 = { 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 #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 = { mustprogress nofree nounwind willreturn "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 = { noreturn nounwind }
attributes #6 = { nounwind willreturn memory(none) }
attributes #7 = { 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, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, i64 0}


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