; LLVM IR from tsotchke/quantum_geometric_tensor :: src/quantum_geometric/core (quantum_gate_operations)

; 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.ComplexFloat = type { float, float }
%struct.quantum_gate_t = type { i64, ptr, ptr, ptr, i64, i8, i32, ptr, i64, i8 }

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

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #1

; Function Attrs: nounwind
declare void @free(ptr noundef) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; 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 ptr @create_quantum_gate(i32 noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef %3, i64 noundef %4) #4 {
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca i64, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i64, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i32, align 4
  %14 = alloca i64, align 8
  %15 = alloca [4 x %struct.ComplexFloat], align 16
  store i32 %0, ptr %7, align 4, !tbaa !5
  store ptr %1, ptr %8, align 8, !tbaa !9
  store i64 %2, ptr %9, align 8, !tbaa !11
  store ptr %3, ptr %10, align 8, !tbaa !9
  store i64 %4, ptr %11, align 8, !tbaa !11
  %16 = load ptr, ptr %8, align 8, !tbaa !9
  %17 = icmp ne ptr %16, null
  br i1 %17, label %18, label %27

18:                                               ; preds = %5
  %19 = load i64, ptr %9, align 8, !tbaa !11
  %20 = icmp eq i64 %19, 0
  br i1 %20, label %27, label %21

21:                                               ; preds = %18
  %22 = load ptr, ptr %10, align 8, !tbaa !9
  %23 = icmp eq ptr %22, null
  br i1 %23, label %24, label %28

24:                                               ; preds = %21
  %25 = load i64, ptr %11, align 8, !tbaa !11
  %26 = icmp ugt i64 %25, 0
  br i1 %26, label %27, label %28

27:                                               ; preds = %24, %18, %5
  store ptr null, ptr %6, align 8
  br label %202

28:                                               ; preds = %24, %21
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %29 = call noalias ptr @malloc(i64 noundef 72) #6
  store ptr %29, ptr %12, align 8, !tbaa !9
  %30 = load ptr, ptr %12, align 8, !tbaa !9
  %31 = icmp ne ptr %30, null
  br i1 %31, label %33, label %32

32:                                               ; preds = %28
  store ptr null, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %201

33:                                               ; preds = %28
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = load ptr, ptr %12, align 8, !tbaa !9
  %36 = getelementptr inbounds %struct.quantum_gate_t, ptr %35, i32 0, i32 6
  store i32 %34, ptr %36, align 4, !tbaa !13
  %37 = load i64, ptr %9, align 8, !tbaa !11
  %38 = load ptr, ptr %12, align 8, !tbaa !9
  %39 = getelementptr inbounds %struct.quantum_gate_t, ptr %38, i32 0, i32 0
  store i64 %37, ptr %39, align 8, !tbaa !16
  %40 = load i64, ptr %9, align 8, !tbaa !11
  %41 = mul i64 %40, 8
  %42 = call noalias ptr @malloc(i64 noundef %41) #6
  %43 = load ptr, ptr %12, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.quantum_gate_t, ptr %43, i32 0, i32 2
  store ptr %42, ptr %44, align 8, !tbaa !17
  %45 = load ptr, ptr %12, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.quantum_gate_t, ptr %45, i32 0, i32 2
  %47 = load ptr, ptr %46, align 8, !tbaa !17
  %48 = icmp ne ptr %47, null
  br i1 %48, label %51, label %49

49:                                               ; preds = %33
  %50 = load ptr, ptr %12, align 8, !tbaa !9
  call void @free(ptr noundef %50) #5
  store ptr null, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %201

51:                                               ; preds = %33
  %52 = load ptr, ptr %12, align 8, !tbaa !9
  %53 = getelementptr inbounds %struct.quantum_gate_t, ptr %52, i32 0, i32 2
  %54 = load ptr, ptr %53, align 8, !tbaa !17
  %55 = load ptr, ptr %8, align 8, !tbaa !9
  %56 = load i64, ptr %9, align 8, !tbaa !11
  %57 = mul i64 %56, 8
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %54, ptr align 8 %55, i64 %57, i1 false)
  %58 = load ptr, ptr %12, align 8, !tbaa !9
  %59 = getelementptr inbounds %struct.quantum_gate_t, ptr %58, i32 0, i32 4
  store i64 0, ptr %59, align 8, !tbaa !18
  %60 = load ptr, ptr %12, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.quantum_gate_t, ptr %60, i32 0, i32 3
  store ptr null, ptr %61, align 8, !tbaa !19
  %62 = load i32, ptr %7, align 4, !tbaa !5
  %63 = icmp eq i32 %62, 10
  br i1 %63, label %67, label %64

64:                                               ; preds = %51
  %65 = load i32, ptr %7, align 4, !tbaa !5
  %66 = icmp eq i32 %65, 11
  br label %67

67:                                               ; preds = %64, %51
  %68 = phi i1 [ true, %51 ], [ %66, %64 ]
  %69 = load ptr, ptr %12, align 8, !tbaa !9
  %70 = getelementptr inbounds %struct.quantum_gate_t, ptr %69, i32 0, i32 5
  %71 = zext i1 %68 to i8
  store i8 %71, ptr %70, align 8, !tbaa !20
  %72 = load ptr, ptr %12, align 8, !tbaa !9
  %73 = getelementptr inbounds %struct.quantum_gate_t, ptr %72, i32 0, i32 9
  store i8 0, ptr %73, align 8, !tbaa !21
  %74 = load ptr, ptr %12, align 8, !tbaa !9
  %75 = getelementptr inbounds %struct.quantum_gate_t, ptr %74, i32 0, i32 7
  store ptr null, ptr %75, align 8, !tbaa !22
  %76 = load ptr, ptr %12, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.quantum_gate_t, ptr %76, i32 0, i32 8
  store i64 0, ptr %77, align 8, !tbaa !23
  call void @llvm.lifetime.start.p0(i64 8, ptr %14) #5
  %78 = load i64, ptr %9, align 8, !tbaa !11
  %79 = trunc i64 %78 to i32
  %80 = shl i32 1, %79
  %81 = sext i32 %80 to i64
  store i64 %81, ptr %14, align 8, !tbaa !11
  %82 = load i64, ptr %14, align 8, !tbaa !11
  %83 = load i64, ptr %14, align 8, !tbaa !11
  %84 = mul i64 %82, %83
  %85 = mul i64 %84, 8
  %86 = call noalias ptr @malloc(i64 noundef %85) #6
  %87 = load ptr, ptr %12, align 8, !tbaa !9
  %88 = getelementptr inbounds %struct.quantum_gate_t, ptr %87, i32 0, i32 1
  store ptr %86, ptr %88, align 8, !tbaa !24
  %89 = load ptr, ptr %12, align 8, !tbaa !9
  %90 = getelementptr inbounds %struct.quantum_gate_t, ptr %89, i32 0, i32 1
  %91 = load ptr, ptr %90, align 8, !tbaa !24
  %92 = icmp ne ptr %91, null
  br i1 %92, label %98, label %93

93:                                               ; preds = %67
  %94 = load ptr, ptr %12, align 8, !tbaa !9
  %95 = getelementptr inbounds %struct.quantum_gate_t, ptr %94, i32 0, i32 2
  %96 = load ptr, ptr %95, align 8, !tbaa !17
  call void @free(ptr noundef %96) #5
  %97 = load ptr, ptr %12, align 8, !tbaa !9
  call void @free(ptr noundef %97) #5
  store ptr null, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %200

98:                                               ; preds = %67
  call void @llvm.lifetime.start.p0(i64 32, ptr %15) #5
  %99 = load i32, ptr %7, align 4, !tbaa !5
  switch i32 %99, label %177 [
    i32 7, label %100
    i32 8, label %100
    i32 9, label %100
    i32 10, label %154
    i32 11, label %154
    i32 12, label %154
  ]

100:                                              ; preds = %98, %98, %98
  %101 = load i64, ptr %11, align 8, !tbaa !11
  %102 = icmp ne i64 %101, 1
  br i1 %102, label %103, label %111

103:                                              ; preds = %100
  %104 = load ptr, ptr %12, align 8, !tbaa !9
  %105 = getelementptr inbounds %struct.quantum_gate_t, ptr %104, i32 0, i32 1
  %106 = load ptr, ptr %105, align 8, !tbaa !24
  call void @free(ptr noundef %106) #5
  %107 = load ptr, ptr %12, align 8, !tbaa !9
  %108 = getelementptr inbounds %struct.quantum_gate_t, ptr %107, i32 0, i32 2
  %109 = load ptr, ptr %108, align 8, !tbaa !17
  call void @free(ptr noundef %109) #5
  %110 = load ptr, ptr %12, align 8, !tbaa !9
  call void @free(ptr noundef %110) #5
  store ptr null, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %199

111:                                              ; preds = %100
  %112 = load ptr, ptr %12, align 8, !tbaa !9
  %113 = getelementptr inbounds %struct.quantum_gate_t, ptr %112, i32 0, i32 9
  store i8 1, ptr %113, align 8, !tbaa !21
  %114 = call noalias ptr @malloc(i64 noundef 8) #6
  %115 = load ptr, ptr %12, align 8, !tbaa !9
  %116 = getelementptr inbounds %struct.quantum_gate_t, ptr %115, i32 0, i32 7
  store ptr %114, ptr %116, align 8, !tbaa !22
  %117 = load ptr, ptr %12, align 8, !tbaa !9
  %118 = getelementptr inbounds %struct.quantum_gate_t, ptr %117, i32 0, i32 7
  %119 = load ptr, ptr %118, align 8, !tbaa !22
  %120 = icmp ne ptr %119, null
  br i1 %120, label %129, label %121

121:                                              ; preds = %111
  %122 = load ptr, ptr %12, align 8, !tbaa !9
  %123 = getelementptr inbounds %struct.quantum_gate_t, ptr %122, i32 0, i32 1
  %124 = load ptr, ptr %123, align 8, !tbaa !24
  call void @free(ptr noundef %124) #5
  %125 = load ptr, ptr %12, align 8, !tbaa !9
  %126 = getelementptr inbounds %struct.quantum_gate_t, ptr %125, i32 0, i32 2
  %127 = load ptr, ptr %126, align 8, !tbaa !17
  call void @free(ptr noundef %127) #5
  %128 = load ptr, ptr %12, align 8, !tbaa !9
  call void @free(ptr noundef %128) #5
  store ptr null, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %199

129:                                              ; preds = %111
  %130 = load ptr, ptr %10, align 8, !tbaa !9
  %131 = getelementptr inbounds double, ptr %130, i64 0
  %132 = load double, ptr %131, align 8, !tbaa !25
  %133 = load ptr, ptr %12, align 8, !tbaa !9
  %134 = getelementptr inbounds %struct.quantum_gate_t, ptr %133, i32 0, i32 7
  %135 = load ptr, ptr %134, align 8, !tbaa !22
  %136 = getelementptr inbounds double, ptr %135, i64 0
  store double %132, ptr %136, align 8, !tbaa !25
  %137 = load ptr, ptr %12, align 8, !tbaa !9
  %138 = getelementptr inbounds %struct.quantum_gate_t, ptr %137, i32 0, i32 8
  store i64 1, ptr %138, align 8, !tbaa !23
  %139 = load ptr, ptr %10, align 8, !tbaa !9
  %140 = getelementptr inbounds double, ptr %139, i64 0
  %141 = load double, ptr %140, align 8, !tbaa !25
  %142 = load i32, ptr %7, align 4, !tbaa !5
  %143 = icmp eq i32 %142, 7
  br i1 %143, label %144, label %145

144:                                              ; preds = %129
  br label %150

145:                                              ; preds = %129
  %146 = load i32, ptr %7, align 4, !tbaa !5
  %147 = icmp eq i32 %146, 8
  %148 = zext i1 %147 to i64
  %149 = select i1 %147, i32 121, i32 122
  br label %150

150:                                              ; preds = %145, %144
  %151 = phi i32 [ 120, %144 ], [ %149, %145 ]
  %152 = trunc i32 %151 to i8
  %153 = getelementptr inbounds [4 x %struct.ComplexFloat], ptr %15, i64 0, i64 0
  call void @compute_rotation_matrix(double noundef %141, i8 noundef signext %152, ptr noundef %153)
  br label %180

154:                                              ; preds = %98, %98, %98
  %155 = load i64, ptr %9, align 8, !tbaa !11
  %156 = icmp ne i64 %155, 2
  br i1 %156, label %157, label %165

157:                                              ; preds = %154
  %158 = load ptr, ptr %12, align 8, !tbaa !9
  %159 = getelementptr inbounds %struct.quantum_gate_t, ptr %158, i32 0, i32 1
  %160 = load ptr, ptr %159, align 8, !tbaa !24
  call void @free(ptr noundef %160) #5
  %161 = load ptr, ptr %12, align 8, !tbaa !9
  %162 = getelementptr inbounds %struct.quantum_gate_t, ptr %161, i32 0, i32 2
  %163 = load ptr, ptr %162, align 8, !tbaa !17
  call void @free(ptr noundef %163) #5
  %164 = load ptr, ptr %12, align 8, !tbaa !9
  call void @free(ptr noundef %164) #5
  store ptr null, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %199

165:                                              ; preds = %154
  %166 = load i32, ptr %7, align 4, !tbaa !5
  %167 = icmp eq i32 %166, 10
  br i1 %167, label %168, label %169

168:                                              ; preds = %165
  br label %174

169:                                              ; preds = %165
  %170 = load i32, ptr %7, align 4, !tbaa !5
  %171 = icmp eq i32 %170, 11
  %172 = zext i1 %171 to i64
  %173 = select i1 %171, i32 3, i32 0
  br label %174

174:                                              ; preds = %169, %168
  %175 = phi i32 [ 1, %168 ], [ %173, %169 ]
  %176 = getelementptr inbounds [4 x %struct.ComplexFloat], ptr %15, i64 0, i64 0
  call void @compute_fixed_matrix(i32 noundef %175, ptr noundef %176)
  br label %180

177:                                              ; preds = %98
  %178 = load i32, ptr %7, align 4, !tbaa !5
  %179 = getelementptr inbounds [4 x %struct.ComplexFloat], ptr %15, i64 0, i64 0
  call void @compute_fixed_matrix(i32 noundef %178, ptr noundef %179)
  br label %180

180:                                              ; preds = %177, %174, %150
  %181 = load i32, ptr %7, align 4, !tbaa !5
  %182 = icmp eq i32 %181, 10
  br i1 %182, label %186, label %183

183:                                              ; preds = %180
  %184 = load i32, ptr %7, align 4, !tbaa !5
  %185 = icmp eq i32 %184, 11
  br i1 %185, label %186, label %192

186:                                              ; preds = %183, %180
  %187 = getelementptr inbounds [4 x %struct.ComplexFloat], ptr %15, i64 0, i64 0
  %188 = load i64, ptr %9, align 8, !tbaa !11
  %189 = load ptr, ptr %12, align 8, !tbaa !9
  %190 = getelementptr inbounds %struct.quantum_gate_t, ptr %189, i32 0, i32 1
  %191 = load ptr, ptr %190, align 8, !tbaa !24
  call void @compute_controlled_matrix(ptr noundef %187, i64 noundef %188, ptr noundef %191)
  br label %197

192:                                              ; preds = %183
  %193 = load ptr, ptr %12, align 8, !tbaa !9
  %194 = getelementptr inbounds %struct.quantum_gate_t, ptr %193, i32 0, i32 1
  %195 = load ptr, ptr %194, align 8, !tbaa !24
  %196 = getelementptr inbounds [4 x %struct.ComplexFloat], ptr %15, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %195, ptr align 16 %196, i64 32, i1 false)
  br label %197

197:                                              ; preds = %192, %186
  %198 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %198, ptr %6, align 8
  store i32 1, ptr %13, align 4
  br label %199

199:                                              ; preds = %197, %157, %121, %103
  call void @llvm.lifetime.end.p0(i64 32, ptr %15) #5
  br label %200

200:                                              ; preds = %199, %93
  call void @llvm.lifetime.end.p0(i64 8, ptr %14) #5
  br label %201

201:                                              ; preds = %200, %49, %32
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  br label %202

202:                                              ; preds = %201, %27
  %203 = load ptr, ptr %6, align 8
  ret ptr %203
}

; Function Attrs: nounwind uwtable
declare hidden void @compute_rotation_matrix(double noundef, i8 noundef signext, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @compute_fixed_matrix(i32 noundef, ptr noundef) #4

; Function Attrs: nounwind uwtable
declare hidden void @compute_controlled_matrix(ptr noundef, i64 noundef, ptr noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nounwind allocsize(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 = { 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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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}
!13 = !{!14, !6, i64 44}
!14 = !{!"quantum_gate_t", !12, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !12, i64 32, !15, i64 40, !6, i64 44, !10, i64 48, !12, i64 56, !15, i64 64}
!15 = !{!"_Bool", !7, i64 0}
!16 = !{!14, !12, i64 0}
!17 = !{!14, !10, i64 16}
!18 = !{!14, !12, i64 32}
!19 = !{!14, !10, i64 24}
!20 = !{!14, !15, i64 40}
!21 = !{!14, !15, i64 64}
!22 = !{!14, !10, i64 48}
!23 = !{!14, !12, i64 56}
!24 = !{!14, !10, i64 8}
!25 = !{!26, !26, i64 0}
!26 = !{!"double", !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"

%struct.ComplexFloat = type { float, float }

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

; Function Attrs: mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @malloc(i64 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite)
declare void @free(ptr allocptr nocapture noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; 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 noalias noundef ptr @create_quantum_gate(i32 noundef %0, ptr noundef readonly %1, i64 noundef %2, ptr noundef readonly %3, i64 noundef %4) local_unnamed_addr #4 {
  %6 = alloca [4 x %struct.ComplexFloat], align 16
  %7 = icmp eq ptr %1, null
  %8 = icmp eq i64 %2, 0
  %or.cond = or i1 %7, %8
  br i1 %or.cond, label %58, label %9

9:                                                ; preds = %5
  %10 = icmp eq ptr %3, null
  %11 = icmp ne i64 %4, 0
  %or.cond3 = and i1 %10, %11
  br i1 %or.cond3, label %58, label %12

12:                                               ; preds = %9
  %13 = tail call noalias dereferenceable_or_null(72) ptr @malloc(i64 noundef 72) #6
  %.not = icmp eq ptr %13, null
  br i1 %.not, label %58, label %14

14:                                               ; preds = %12
  %15 = getelementptr inbounds i8, ptr %13, i64 44
  store i32 %0, ptr %15, align 4, !tbaa !5
  store i64 %2, ptr %13, align 8, !tbaa !13
  %16 = shl i64 %2, 3
  %17 = tail call noalias ptr @malloc(i64 noundef %16) #6
  %18 = getelementptr inbounds i8, ptr %13, i64 16
  store ptr %17, ptr %18, align 8, !tbaa !14
  %.not72 = icmp eq ptr %17, null
  br i1 %.not72, label %19, label %20

19:                                               ; preds = %14
  tail call void @free(ptr noundef nonnull %13) #7
  br label %58

20:                                               ; preds = %14
  tail call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 8 %17, ptr nonnull align 8 %1, i64 %16, i1 false)
  %21 = getelementptr inbounds i8, ptr %13, i64 24
  %22 = icmp eq i32 %0, 10
  %23 = icmp eq i32 %0, 11
  %24 = and i32 %0, -2
  %25 = icmp eq i32 %24, 10
  %26 = getelementptr inbounds i8, ptr %13, i64 40
  %27 = zext i1 %25 to i8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %21, i8 0, i64 16, i1 false)
  store i8 %27, ptr %26, align 8, !tbaa !15
  %28 = getelementptr inbounds i8, ptr %13, i64 64
  %29 = getelementptr inbounds i8, ptr %13, i64 48
  %30 = getelementptr inbounds i8, ptr %13, i64 56
  %31 = trunc i64 %2 to i32
  %32 = shl nuw i32 1, %31
  %33 = sext i32 %32 to i64
  %34 = shl nsw i64 %33, 3
  %35 = mul i64 %34, %33
  %36 = tail call noalias ptr @malloc(i64 noundef %35) #6
  %37 = getelementptr inbounds i8, ptr %13, i64 8
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(17) %29, i8 0, i64 17, i1 false)
  store ptr %36, ptr %37, align 8, !tbaa !16
  %.not73 = icmp eq ptr %36, null
  br i1 %.not73, label %38, label %39

38:                                               ; preds = %20
  tail call void @free(ptr noundef nonnull %17) #7
  tail call void @free(ptr noundef nonnull %13) #7
  br label %58

39:                                               ; preds = %20
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %6) #7
  switch i32 %0, label %54 [
    i32 7, label %40
    i32 8, label %40
    i32 9, label %40
    i32 10, label %50
    i32 11, label %50
    i32 12, label %50
  ]

40:                                               ; preds = %39, %39, %39
  %.not75 = icmp eq i64 %4, 1
  br i1 %.not75, label %42, label %41

41:                                               ; preds = %40
  tail call void @free(ptr noundef nonnull %36) #7
  tail call void @free(ptr noundef nonnull %17) #7
  tail call void @free(ptr noundef nonnull %13) #7
  br label %57

42:                                               ; preds = %40
  store i8 1, ptr %28, align 8, !tbaa !17
  %43 = tail call noalias dereferenceable_or_null(8) ptr @malloc(i64 noundef 8) #6
  store ptr %43, ptr %29, align 8, !tbaa !18
  %.not76 = icmp eq ptr %43, null
  br i1 %.not76, label %44, label %.thread

44:                                               ; preds = %42
  tail call void @free(ptr noundef nonnull %36) #7
  tail call void @free(ptr noundef nonnull %17) #7
  tail call void @free(ptr noundef nonnull %13) #7
  br label %57

.thread:                                          ; preds = %42
  %45 = load double, ptr %3, align 8, !tbaa !19
  store double %45, ptr %43, align 8, !tbaa !19
  store i64 1, ptr %30, align 8, !tbaa !21
  %46 = icmp eq i32 %0, 7
  %47 = icmp eq i32 %0, 8
  %48 = select i1 %47, i8 121, i8 122
  %49 = select i1 %46, i8 120, i8 %48
  call void @compute_rotation_matrix(double noundef %45, i8 noundef signext %49, ptr noundef nonnull %6)
  br label %56

50:                                               ; preds = %39, %39, %39
  %.not74 = icmp eq i64 %2, 2
  br i1 %.not74, label %52, label %51

51:                                               ; preds = %50
  tail call void @free(ptr noundef nonnull %36) #7
  tail call void @free(ptr noundef nonnull %17) #7
  tail call void @free(ptr noundef nonnull %13) #7
  br label %57

52:                                               ; preds = %50
  %53 = select i1 %23, i32 3, i32 0
  %spec.select = select i1 %22, i32 1, i32 %53
  br label %54

54:                                               ; preds = %39, %52
  %.sink = phi i32 [ %spec.select, %52 ], [ %0, %39 ]
  call void @compute_fixed_matrix(i32 noundef %.sink, ptr noundef nonnull %6)
  br i1 %25, label %55, label %56

55:                                               ; preds = %54
  call void @compute_controlled_matrix(ptr noundef nonnull %6, i64 noundef %2, ptr noundef nonnull %36)
  br label %57

56:                                               ; preds = %.thread, %54
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 4 dereferenceable(32) %36, ptr noundef nonnull align 16 dereferenceable(32) %6, i64 32, i1 false)
  br label %57

57:                                               ; preds = %55, %56, %51, %44, %41
  %.0 = phi ptr [ null, %51 ], [ null, %41 ], [ null, %44 ], [ %13, %56 ], [ %13, %55 ]
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %6) #7
  br label %58

58:                                               ; preds = %19, %12, %57, %38, %5, %9
  %.3 = phi ptr [ null, %9 ], [ null, %5 ], [ null, %19 ], [ null, %12 ], [ %.0, %57 ], [ null, %38 ]
  ret ptr %.3
}

; Function Attrs: nounwind uwtable
declare hidden void @compute_rotation_matrix(double noundef, i8 noundef signext, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden void @compute_fixed_matrix(i32 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nounwind uwtable
declare hidden void @compute_controlled_matrix(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #4

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #5

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nofree nounwind willreturn allockind("alloc,uninitialized") allocsize(0) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nounwind willreturn allockind("free") memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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 nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #6 = { nounwind allocsize(0) }
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, !12, i64 44}
!6 = !{!"quantum_gate_t", !7, i64 0, !10, i64 8, !10, i64 16, !10, i64 24, !7, i64 32, !11, i64 40, !12, i64 44, !10, i64 48, !7, i64 56, !11, i64 64}
!7 = !{!"long", !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 = !{!"int", !8, i64 0}
!13 = !{!6, !7, i64 0}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !11, i64 40}
!16 = !{!6, !10, i64 8}
!17 = !{!6, !11, i64 64}
!18 = !{!6, !10, i64 48}
!19 = !{!20, !20, i64 0}
!20 = !{!"double", !8, i64 0}
!21 = !{!6, !7, i64 56}


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