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

; 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 [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [59 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @run_dct(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @copy_data(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) #0 {
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store i64 %1, ptr %6, align 8, !tbaa !9
  store i64 %2, ptr %7, align 8, !tbaa !9
  store i32 %3, ptr %8, align 4, !tbaa !11
  %9 = load i64, ptr %6, align 8, !tbaa !9
  %10 = srem i64 %9, 8
  %11 = icmp ne i64 %10, 0
  br i1 %11, label %16, label %12

12:                                               ; preds = %4
  %13 = load i64, ptr %7, align 8, !tbaa !9
  %14 = srem i64 %13, 8
  %15 = icmp ne i64 %14, 0
  br i1 %15, label %16, label %18

16:                                               ; preds = %12, %4
  %17 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  br label %99

18:                                               ; preds = %12
  %19 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %20 = load ptr, ptr %5, align 8, !tbaa !5
  %21 = load i64, ptr %6, align 8, !tbaa !9
  %22 = load i64, ptr %7, align 8, !tbaa !9
  call void @run_dct(ptr noundef %20, i64 noundef %21, i64 noundef %22, ptr noundef @copy_data)
  %23 = load i32, ptr %8, align 4, !tbaa !11
  %24 = icmp eq i32 %23, 2
  br i1 %24, label %28, label %25

25:                                               ; preds = %18
  %26 = load i32, ptr %8, align 4, !tbaa !11
  %27 = icmp eq i32 %26, 0
  br i1 %27, label %28, label %33

28:                                               ; preds = %25, %18
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = load i64, ptr %6, align 8, !tbaa !9
  %32 = load i64, ptr %7, align 8, !tbaa !9
  call void @run_dct(ptr noundef %30, i64 noundef %31, i64 noundef %32, ptr noundef @dct_naive)
  br label %33

33:                                               ; preds = %28, %25
  %34 = load i32, ptr %8, align 4, !tbaa !11
  %35 = icmp eq i32 %34, 3
  br i1 %35, label %39, label %36

36:                                               ; preds = %33
  %37 = load i32, ptr %8, align 4, !tbaa !11
  %38 = icmp eq i32 %37, 0
  br i1 %38, label %39, label %44

39:                                               ; preds = %36, %33
  %40 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  %41 = load ptr, ptr %5, align 8, !tbaa !5
  %42 = load i64, ptr %6, align 8, !tbaa !9
  %43 = load i64, ptr %7, align 8, !tbaa !9
  call void @run_dct(ptr noundef %41, i64 noundef %42, i64 noundef %43, ptr noundef @dct_twostep_slow)
  br label %44

44:                                               ; preds = %39, %36
  %45 = load i32, ptr %8, align 4, !tbaa !11
  %46 = icmp eq i32 %45, 4
  br i1 %46, label %50, label %47

47:                                               ; preds = %44
  %48 = load i32, ptr %8, align 4, !tbaa !11
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %55

50:                                               ; preds = %47, %44
  %51 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  %52 = load ptr, ptr %5, align 8, !tbaa !5
  %53 = load i64, ptr %6, align 8, !tbaa !9
  %54 = load i64, ptr %7, align 8, !tbaa !9
  call void @run_dct(ptr noundef %52, i64 noundef %53, i64 noundef %54, ptr noundef @dct_loeffler_float)
  br label %55

55:                                               ; preds = %50, %47
  %56 = load i32, ptr %8, align 4, !tbaa !11
  %57 = icmp eq i32 %56, 5
  br i1 %57, label %61, label %58

58:                                               ; preds = %55
  %59 = load i32, ptr %8, align 4, !tbaa !11
  %60 = icmp eq i32 %59, 0
  br i1 %60, label %61, label %66

61:                                               ; preds = %58, %55
  %62 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %63 = load ptr, ptr %5, align 8, !tbaa !5
  %64 = load i64, ptr %6, align 8, !tbaa !9
  %65 = load i64, ptr %7, align 8, !tbaa !9
  call void @run_dct(ptr noundef %63, i64 noundef %64, i64 noundef %65, ptr noundef @dct_loeffler_fixed)
  br label %66

66:                                               ; preds = %61, %58
  %67 = load i32, ptr %8, align 4, !tbaa !11
  %68 = icmp eq i32 %67, 6
  br i1 %68, label %72, label %69

69:                                               ; preds = %66
  %70 = load i32, ptr %8, align 4, !tbaa !11
  %71 = icmp eq i32 %70, 0
  br i1 %71, label %72, label %77

72:                                               ; preds = %69, %66
  %73 = call i32 (ptr, ...) @printf(ptr noundef @.str.7)
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load i64, ptr %6, align 8, !tbaa !9
  %76 = load i64, ptr %7, align 8, !tbaa !9
  call void @run_dct(ptr noundef %74, i64 noundef %75, i64 noundef %76, ptr noundef @dct_loeffler_2d_fixed)
  br label %77

77:                                               ; preds = %72, %69
  %78 = load i32, ptr %8, align 4, !tbaa !11
  %79 = icmp eq i32 %78, 7
  br i1 %79, label %83, label %80

80:                                               ; preds = %77
  %81 = load i32, ptr %8, align 4, !tbaa !11
  %82 = icmp eq i32 %81, 0
  br i1 %82, label %83, label %88

83:                                               ; preds = %80, %77
  %84 = call i32 (ptr, ...) @printf(ptr noundef @.str.8)
  %85 = load ptr, ptr %5, align 8, !tbaa !5
  %86 = load i64, ptr %6, align 8, !tbaa !9
  %87 = load i64, ptr %7, align 8, !tbaa !9
  call void @run_dct(ptr noundef %85, i64 noundef %86, i64 noundef %87, ptr noundef @dct_loeffler_2d_fixed_inline)
  br label %88

88:                                               ; preds = %83, %80
  %89 = load i32, ptr %8, align 4, !tbaa !11
  %90 = icmp eq i32 %89, 8
  br i1 %90, label %94, label %91

91:                                               ; preds = %88
  %92 = load i32, ptr %8, align 4, !tbaa !11
  %93 = icmp eq i32 %92, 0
  br i1 %93, label %94, label %99

94:                                               ; preds = %91, %88
  %95 = call i32 (ptr, ...) @printf(ptr noundef @.str.9)
  %96 = load ptr, ptr %5, align 8, !tbaa !5
  %97 = load i64, ptr %6, align 8, !tbaa !9
  %98 = load i64, ptr %7, align 8, !tbaa !9
  call void @run_dct(ptr noundef %96, i64 noundef %97, i64 noundef %98, ptr noundef @dct_loeffler_2d_fixed_macro)
  br label %99

99:                                               ; preds = %94, %91, %16
  ret void
}

declare void @dct_naive(ptr noundef, ptr noundef) #1

declare void @dct_twostep_slow(ptr noundef, ptr noundef) #1

declare void @dct_loeffler_float(ptr noundef, ptr noundef) #1

declare void @dct_loeffler_fixed(ptr noundef, ptr noundef) #1

declare void @dct_loeffler_2d_fixed(ptr noundef, ptr noundef) #1

declare void @dct_loeffler_2d_fixed_inline(ptr noundef, ptr noundef) #1

declare void @dct_loeffler_2d_fixed_macro(ptr noundef, ptr noundef) #1

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 = { "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" }

!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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !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 [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [8 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [27 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [39 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [52 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [59 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local void @run_dct(ptr noundef, i64 noundef, i64 noundef, ptr noundef) local_unnamed_addr #0

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

; Function Attrs: nounwind uwtable
declare dso_local void @copy_data(ptr noundef, ptr noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #0 {
  %5 = or i64 %2, %1
  %6 = and i64 %5, 7
  %or.cond53 = icmp eq i64 %6, 0
  br i1 %or.cond53, label %9, label %7

7:                                                ; preds = %4
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %26

9:                                                ; preds = %4
  %10 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @copy_data)
  switch i32 %3, label %26 [
    i32 2, label %12
    i32 0, label %12
    i32 3, label %.thread
    i32 4, label %.thread54
    i32 5, label %.thread56
    i32 6, label %.thread58
    i32 7, label %.thread60
    i32 8, label %24
  ]

.thread:                                          ; preds = %9
  %11 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_twostep_slow)
  br label %26

12:                                               ; preds = %9, %9
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_naive)
  %cond = icmp eq i32 %3, 0
  br i1 %cond, label %14, label %26

14:                                               ; preds = %12
  %15 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_twostep_slow)
  %16 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_loeffler_float)
  %17 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_loeffler_fixed)
  %18 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_loeffler_2d_fixed)
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_loeffler_2d_fixed_inline)
  br label %24

.thread54:                                        ; preds = %9
  %20 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_loeffler_float)
  br label %26

.thread56:                                        ; preds = %9
  %21 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_loeffler_fixed)
  br label %26

.thread58:                                        ; preds = %9
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_loeffler_2d_fixed)
  br label %26

.thread60:                                        ; preds = %9
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_loeffler_2d_fixed_inline)
  br label %26

24:                                               ; preds = %14, %9
  %25 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.9)
  tail call void @run_dct(ptr noundef %0, i64 noundef %1, i64 noundef %2, ptr noundef nonnull @dct_loeffler_2d_fixed_macro)
  br label %26

26:                                               ; preds = %12, %.thread60, %.thread58, %.thread56, %.thread54, %.thread, %9, %24, %7
  ret void
}

declare void @dct_naive(ptr noundef, ptr noundef) #2

declare void @dct_twostep_slow(ptr noundef, ptr noundef) #2

declare void @dct_loeffler_float(ptr noundef, ptr noundef) #2

declare void @dct_loeffler_fixed(ptr noundef, ptr noundef) #2

declare void @dct_loeffler_2d_fixed(ptr noundef, ptr noundef) #2

declare void @dct_loeffler_2d_fixed_inline(ptr noundef, ptr noundef) #2

declare void @dct_loeffler_2d_fixed_macro(ptr noundef, ptr noundef) #2

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 = { 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 = { "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" }

!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)"}


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