; LLVM IR from guanzhi/GmSSL :: src (kyber)

; 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.KYBER_CPA_PUBLIC_KEY = type { [2 x [384 x i8]], [32 x i8] }
%struct.KYBER_CPA_PRIVATE_KEY = type { [2 x [384 x i8]] }

@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [59 x i8], align 1
@__FUNCTION__.kyber_cpa_keygen = external hidden unnamed_addr constant [17 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

; 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
declare dso_local void @kyber_g_hash(ptr noundef, i64 noundef, ptr noundef) #1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

; Function Attrs: nounwind uwtable
declare dso_local void @kyber_poly_set_zero(ptr noundef) #1

declare i32 @rand_bytes(ptr noundef, i64 noundef) #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @kyber_poly_uniform_sample(ptr noundef, ptr noundef, i8 noundef zeroext, i8 noundef zeroext) #1

; 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) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @kyber_poly_cbd_sample(ptr noundef, i32 noundef, ptr noundef, i8 noundef zeroext) #1

declare void @gmssl_secure_clear(ptr noundef, i64 noundef) #3

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

; Function Attrs: nounwind uwtable
declare dso_local i32 @kyber_poly_ntt(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @kyber_poly_ntt_mul(ptr noundef, ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @kyber_poly_encode12(ptr noundef, ptr noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @kyber_cpa_keygen(ptr noundef %0, ptr noundef %1) #1 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca [2 x [2 x [256 x i16]]], align 16
  %7 = alloca [2 x [256 x i16]], align 16
  %8 = alloca [2 x [256 x i16]], align 16
  %9 = alloca [2 x [256 x i16]], align 16
  %10 = alloca [64 x i8], align 16
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca i8, align 1
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca i32, align 4
  %17 = alloca [256 x i16], align 16
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 2048, ptr %6) #5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %7) #5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %8) #5
  call void @llvm.lifetime.start.p0(i64 1024, ptr %9) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr %10) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr %11) #5
  %18 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  store ptr %18, ptr %11, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #5
  %19 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  %20 = getelementptr inbounds i8, ptr %19, i64 32
  store ptr %20, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr %13) #5
  store i8 0, ptr %13, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #5
  %21 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  %22 = call i32 @rand_bytes(ptr noundef %21, i64 noundef 32)
  %23 = icmp ne i32 %22, 1
  br i1 %23, label %24, label %30

24:                                               ; preds = %2
  br label %25

25:                                               ; preds = %24
  %26 = load ptr, ptr @stderr, align 8, !tbaa !5
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %26, ptr noundef @.str.4, ptr noundef @.str.5, i32 noundef 1088, ptr noundef @__FUNCTION__.kyber_cpa_keygen) #5
  br label %28

28:                                               ; preds = %25
  br label %29

29:                                               ; preds = %28
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %16, align 4
  br label %221

30:                                               ; preds = %2
  %31 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  %32 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  call void @kyber_g_hash(ptr noundef %31, i64 noundef 32, ptr noundef %32)
  store i32 0, ptr %14, align 4, !tbaa !10
  br label %33

33:                                               ; preds = %58, %30
  %34 = load i32, ptr %14, align 4, !tbaa !10
  %35 = icmp slt i32 %34, 2
  br i1 %35, label %36, label %61

36:                                               ; preds = %33
  store i32 0, ptr %15, align 4, !tbaa !10
  br label %37

37:                                               ; preds = %54, %36
  %38 = load i32, ptr %15, align 4, !tbaa !10
  %39 = icmp slt i32 %38, 2
  br i1 %39, label %40, label %57

40:                                               ; preds = %37
  %41 = load i32, ptr %14, align 4, !tbaa !10
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [2 x [2 x [256 x i16]]], ptr %6, i64 0, i64 %42
  %44 = load i32, ptr %15, align 4, !tbaa !10
  %45 = sext i32 %44 to i64
  %46 = getelementptr inbounds [2 x [256 x i16]], ptr %43, i64 0, i64 %45
  %47 = getelementptr inbounds [256 x i16], ptr %46, i64 0, i64 0
  %48 = load ptr, ptr %11, align 8, !tbaa !5
  %49 = load i32, ptr %15, align 4, !tbaa !10
  %50 = trunc i32 %49 to i8
  %51 = load i32, ptr %14, align 4, !tbaa !10
  %52 = trunc i32 %51 to i8
  %53 = call i32 @kyber_poly_uniform_sample(ptr noundef %47, ptr noundef %48, i8 noundef zeroext %50, i8 noundef zeroext %52)
  br label %54

54:                                               ; preds = %40
  %55 = load i32, ptr %15, align 4, !tbaa !10
  %56 = add nsw i32 %55, 1
  store i32 %56, ptr %15, align 4, !tbaa !10
  br label %37, !llvm.loop !12

57:                                               ; preds = %37
  br label %58

58:                                               ; preds = %57
  %59 = load i32, ptr %14, align 4, !tbaa !10
  %60 = add nsw i32 %59, 1
  store i32 %60, ptr %14, align 4, !tbaa !10
  br label %33, !llvm.loop !14

61:                                               ; preds = %33
  store i32 0, ptr %14, align 4, !tbaa !10
  br label %62

62:                                               ; preds = %75, %61
  %63 = load i32, ptr %14, align 4, !tbaa !10
  %64 = icmp slt i32 %63, 2
  br i1 %64, label %65, label %78

65:                                               ; preds = %62
  %66 = load i32, ptr %14, align 4, !tbaa !10
  %67 = sext i32 %66 to i64
  %68 = getelementptr inbounds [2 x [256 x i16]], ptr %7, i64 0, i64 %67
  %69 = getelementptr inbounds [256 x i16], ptr %68, i64 0, i64 0
  %70 = load ptr, ptr %12, align 8, !tbaa !5
  %71 = load i8, ptr %13, align 1, !tbaa !9
  %72 = call i32 @kyber_poly_cbd_sample(ptr noundef %69, i32 noundef 3, ptr noundef %70, i8 noundef zeroext %71)
  %73 = load i8, ptr %13, align 1, !tbaa !9
  %74 = add i8 %73, 1
  store i8 %74, ptr %13, align 1, !tbaa !9
  br label %75

75:                                               ; preds = %65
  %76 = load i32, ptr %14, align 4, !tbaa !10
  %77 = add nsw i32 %76, 1
  store i32 %77, ptr %14, align 4, !tbaa !10
  br label %62, !llvm.loop !15

78:                                               ; preds = %62
  store i32 0, ptr %14, align 4, !tbaa !10
  br label %79

79:                                               ; preds = %92, %78
  %80 = load i32, ptr %14, align 4, !tbaa !10
  %81 = icmp slt i32 %80, 2
  br i1 %81, label %82, label %95

82:                                               ; preds = %79
  %83 = load i32, ptr %14, align 4, !tbaa !10
  %84 = sext i32 %83 to i64
  %85 = getelementptr inbounds [2 x [256 x i16]], ptr %8, i64 0, i64 %84
  %86 = getelementptr inbounds [256 x i16], ptr %85, i64 0, i64 0
  %87 = load ptr, ptr %12, align 8, !tbaa !5
  %88 = load i8, ptr %13, align 1, !tbaa !9
  %89 = call i32 @kyber_poly_cbd_sample(ptr noundef %86, i32 noundef 3, ptr noundef %87, i8 noundef zeroext %88)
  %90 = load i8, ptr %13, align 1, !tbaa !9
  %91 = add i8 %90, 1
  store i8 %91, ptr %13, align 1, !tbaa !9
  br label %92

92:                                               ; preds = %82
  %93 = load i32, ptr %14, align 4, !tbaa !10
  %94 = add nsw i32 %93, 1
  store i32 %94, ptr %14, align 4, !tbaa !10
  br label %79, !llvm.loop !16

95:                                               ; preds = %79
  store i32 0, ptr %14, align 4, !tbaa !10
  br label %96

96:                                               ; preds = %105, %95
  %97 = load i32, ptr %14, align 4, !tbaa !10
  %98 = icmp slt i32 %97, 2
  br i1 %98, label %99, label %108

99:                                               ; preds = %96
  %100 = load i32, ptr %14, align 4, !tbaa !10
  %101 = sext i32 %100 to i64
  %102 = getelementptr inbounds [2 x [256 x i16]], ptr %7, i64 0, i64 %101
  %103 = getelementptr inbounds [256 x i16], ptr %102, i64 0, i64 0
  %104 = call i32 @kyber_poly_ntt(ptr noundef %103)
  br label %105

105:                                              ; preds = %99
  %106 = load i32, ptr %14, align 4, !tbaa !10
  %107 = add nsw i32 %106, 1
  store i32 %107, ptr %14, align 4, !tbaa !10
  br label %96, !llvm.loop !17

108:                                              ; preds = %96
  store i32 0, ptr %14, align 4, !tbaa !10
  br label %109

109:                                              ; preds = %118, %108
  %110 = load i32, ptr %14, align 4, !tbaa !10
  %111 = icmp slt i32 %110, 2
  br i1 %111, label %112, label %121

112:                                              ; preds = %109
  %113 = load i32, ptr %14, align 4, !tbaa !10
  %114 = sext i32 %113 to i64
  %115 = getelementptr inbounds [2 x [256 x i16]], ptr %8, i64 0, i64 %114
  %116 = getelementptr inbounds [256 x i16], ptr %115, i64 0, i64 0
  %117 = call i32 @kyber_poly_ntt(ptr noundef %116)
  br label %118

118:                                              ; preds = %112
  %119 = load i32, ptr %14, align 4, !tbaa !10
  %120 = add nsw i32 %119, 1
  store i32 %120, ptr %14, align 4, !tbaa !10
  br label %109, !llvm.loop !18

121:                                              ; preds = %109
  store i32 0, ptr %14, align 4, !tbaa !10
  br label %122

122:                                              ; preds = %130, %121
  %123 = load i32, ptr %14, align 4, !tbaa !10
  %124 = icmp slt i32 %123, 2
  br i1 %124, label %125, label %133

125:                                              ; preds = %122
  %126 = load i32, ptr %14, align 4, !tbaa !10
  %127 = sext i32 %126 to i64
  %128 = getelementptr inbounds [2 x [256 x i16]], ptr %9, i64 0, i64 %127
  %129 = getelementptr inbounds [256 x i16], ptr %128, i64 0, i64 0
  call void @kyber_poly_set_zero(ptr noundef %129)
  br label %130

130:                                              ; preds = %125
  %131 = load i32, ptr %14, align 4, !tbaa !10
  %132 = add nsw i32 %131, 1
  store i32 %132, ptr %14, align 4, !tbaa !10
  br label %122, !llvm.loop !19

133:                                              ; preds = %122
  store i32 0, ptr %14, align 4, !tbaa !10
  br label %134

134:                                              ; preds = %180, %133
  %135 = load i32, ptr %14, align 4, !tbaa !10
  %136 = icmp slt i32 %135, 2
  br i1 %136, label %137, label %183

137:                                              ; preds = %134
  store i32 0, ptr %15, align 4, !tbaa !10
  br label %138

138:                                              ; preds = %164, %137
  %139 = load i32, ptr %15, align 4, !tbaa !10
  %140 = icmp slt i32 %139, 2
  br i1 %140, label %141, label %167

141:                                              ; preds = %138
  call void @llvm.lifetime.start.p0(i64 512, ptr %17) #5
  %142 = getelementptr inbounds [256 x i16], ptr %17, i64 0, i64 0
  %143 = load i32, ptr %14, align 4, !tbaa !10
  %144 = sext i32 %143 to i64
  %145 = getelementptr inbounds [2 x [2 x [256 x i16]]], ptr %6, i64 0, i64 %144
  %146 = load i32, ptr %15, align 4, !tbaa !10
  %147 = sext i32 %146 to i64
  %148 = getelementptr inbounds [2 x [256 x i16]], ptr %145, i64 0, i64 %147
  %149 = getelementptr inbounds [256 x i16], ptr %148, i64 0, i64 0
  %150 = load i32, ptr %15, align 4, !tbaa !10
  %151 = sext i32 %150 to i64
  %152 = getelementptr inbounds [2 x [256 x i16]], ptr %7, i64 0, i64 %151
  %153 = getelementptr inbounds [256 x i16], ptr %152, i64 0, i64 0
  %154 = call i32 @kyber_poly_ntt_mul(ptr noundef %142, ptr noundef %149, ptr noundef %153)
  %155 = load i32, ptr %14, align 4, !tbaa !10
  %156 = sext i32 %155 to i64
  %157 = getelementptr inbounds [2 x [256 x i16]], ptr %9, i64 0, i64 %156
  %158 = getelementptr inbounds [256 x i16], ptr %157, i64 0, i64 0
  %159 = load i32, ptr %14, align 4, !tbaa !10
  %160 = sext i32 %159 to i64
  %161 = getelementptr inbounds [2 x [256 x i16]], ptr %9, i64 0, i64 %160
  %162 = getelementptr inbounds [256 x i16], ptr %161, i64 0, i64 0
  %163 = getelementptr inbounds [256 x i16], ptr %17, i64 0, i64 0
  call void @kyber_poly_add(ptr noundef %158, ptr noundef %162, ptr noundef %163)
  call void @llvm.lifetime.end.p0(i64 512, ptr %17) #5
  br label %164

164:                                              ; preds = %141
  %165 = load i32, ptr %15, align 4, !tbaa !10
  %166 = add nsw i32 %165, 1
  store i32 %166, ptr %15, align 4, !tbaa !10
  br label %138, !llvm.loop !20

167:                                              ; preds = %138
  %168 = load i32, ptr %14, align 4, !tbaa !10
  %169 = sext i32 %168 to i64
  %170 = getelementptr inbounds [2 x [256 x i16]], ptr %9, i64 0, i64 %169
  %171 = getelementptr inbounds [256 x i16], ptr %170, i64 0, i64 0
  %172 = load i32, ptr %14, align 4, !tbaa !10
  %173 = sext i32 %172 to i64
  %174 = getelementptr inbounds [2 x [256 x i16]], ptr %9, i64 0, i64 %173
  %175 = getelementptr inbounds [256 x i16], ptr %174, i64 0, i64 0
  %176 = load i32, ptr %14, align 4, !tbaa !10
  %177 = sext i32 %176 to i64
  %178 = getelementptr inbounds [2 x [256 x i16]], ptr %8, i64 0, i64 %177
  %179 = getelementptr inbounds [256 x i16], ptr %178, i64 0, i64 0
  call void @kyber_poly_add(ptr noundef %171, ptr noundef %175, ptr noundef %179)
  br label %180

180:                                              ; preds = %167
  %181 = load i32, ptr %14, align 4, !tbaa !10
  %182 = add nsw i32 %181, 1
  store i32 %182, ptr %14, align 4, !tbaa !10
  br label %134, !llvm.loop !21

183:                                              ; preds = %134
  store i32 0, ptr %14, align 4, !tbaa !10
  br label %184

184:                                              ; preds = %210, %183
  %185 = load i32, ptr %14, align 4, !tbaa !10
  %186 = icmp slt i32 %185, 2
  br i1 %186, label %187, label %213

187:                                              ; preds = %184
  %188 = load i32, ptr %14, align 4, !tbaa !10
  %189 = sext i32 %188 to i64
  %190 = getelementptr inbounds [2 x [256 x i16]], ptr %9, i64 0, i64 %189
  %191 = getelementptr inbounds [256 x i16], ptr %190, i64 0, i64 0
  %192 = load ptr, ptr %4, align 8, !tbaa !5
  %193 = getelementptr inbounds %struct.KYBER_CPA_PUBLIC_KEY, ptr %192, i32 0, i32 0
  %194 = load i32, ptr %14, align 4, !tbaa !10
  %195 = sext i32 %194 to i64
  %196 = getelementptr inbounds [2 x [384 x i8]], ptr %193, i64 0, i64 %195
  %197 = getelementptr inbounds [384 x i8], ptr %196, i64 0, i64 0
  %198 = call i32 @kyber_poly_encode12(ptr noundef %191, ptr noundef %197)
  %199 = load i32, ptr %14, align 4, !tbaa !10
  %200 = sext i32 %199 to i64
  %201 = getelementptr inbounds [2 x [256 x i16]], ptr %7, i64 0, i64 %200
  %202 = getelementptr inbounds [256 x i16], ptr %201, i64 0, i64 0
  %203 = load ptr, ptr %5, align 8, !tbaa !5
  %204 = getelementptr inbounds %struct.KYBER_CPA_PRIVATE_KEY, ptr %203, i32 0, i32 0
  %205 = load i32, ptr %14, align 4, !tbaa !10
  %206 = sext i32 %205 to i64
  %207 = getelementptr inbounds [2 x [384 x i8]], ptr %204, i64 0, i64 %206
  %208 = getelementptr inbounds [384 x i8], ptr %207, i64 0, i64 0
  %209 = call i32 @kyber_poly_encode12(ptr noundef %202, ptr noundef %208)
  br label %210

210:                                              ; preds = %187
  %211 = load i32, ptr %14, align 4, !tbaa !10
  %212 = add nsw i32 %211, 1
  store i32 %212, ptr %14, align 4, !tbaa !10
  br label %184, !llvm.loop !22

213:                                              ; preds = %184
  %214 = load ptr, ptr %4, align 8, !tbaa !5
  %215 = getelementptr inbounds %struct.KYBER_CPA_PUBLIC_KEY, ptr %214, i32 0, i32 1
  %216 = getelementptr inbounds [32 x i8], ptr %215, i64 0, i64 0
  %217 = load ptr, ptr %11, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %216, ptr align 1 %217, i64 32, i1 false)
  %218 = getelementptr inbounds [64 x i8], ptr %10, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %218, i64 noundef 64)
  %219 = getelementptr inbounds [2 x [256 x i16]], ptr %7, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %219, i64 noundef 1024)
  %220 = getelementptr inbounds [2 x [256 x i16]], ptr %8, i64 0, i64 0
  call void @gmssl_secure_clear(ptr noundef %220, i64 noundef 1024)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %16, align 4
  br label %221

221:                                              ; preds = %213, %29
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #5
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #5
  call void @llvm.lifetime.end.p0(i64 1, ptr %13) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %11) #5
  call void @llvm.lifetime.end.p0(i64 64, ptr %10) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %9) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %8) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 2048, ptr %6) #5
  %222 = load i32, ptr %3, align 4
  ret i32 %222
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = { "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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = distinct !{!14, !13}
!15 = distinct !{!15, !13}
!16 = distinct !{!16, !13}
!17 = distinct !{!17, !13}
!18 = distinct !{!18, !13}
!19 = distinct !{!19, !13}
!20 = distinct !{!20, !13}
!21 = distinct !{!21, !13}
!22 = distinct !{!22, !13}


; 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"

@stderr = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [59 x i8], align 1
@__FUNCTION__.kyber_cpa_keygen = external hidden unnamed_addr constant [17 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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

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

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

; Function Attrs: nounwind uwtable
declare dso_local void @kyber_poly_set_zero(ptr noundef) local_unnamed_addr #1

declare i32 @rand_bytes(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local i32 @kyber_poly_uniform_sample(ptr noundef, ptr noundef, i8 noundef zeroext, i8 noundef zeroext) local_unnamed_addr #1

; 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) #4

; Function Attrs: nounwind uwtable
declare dso_local i32 @kyber_poly_cbd_sample(ptr noundef, i32 noundef, ptr noundef, i8 noundef zeroext) local_unnamed_addr #1

declare void @gmssl_secure_clear(ptr noundef, i64 noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare dso_local void @kyber_poly_add(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @kyber_poly_ntt(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @kyber_poly_ntt_mul(ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local i32 @kyber_poly_encode12(ptr noundef, ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @kyber_cpa_keygen(ptr noundef %0, ptr noundef %1) local_unnamed_addr #1 {
  %3 = alloca [2 x [2 x [256 x i16]]], align 16
  %4 = alloca [2 x [256 x i16]], align 16
  %5 = alloca [2 x [256 x i16]], align 16
  %6 = alloca [2 x [256 x i16]], align 16
  %7 = alloca [64 x i8], align 16
  %8 = alloca [256 x i16], align 16
  call void @llvm.lifetime.start.p0(i64 2048, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %4) #5
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %5) #5
  call void @llvm.lifetime.start.p0(i64 1024, ptr nonnull %6) #5
  call void @llvm.lifetime.start.p0(i64 64, ptr nonnull %7) #5
  %9 = call i32 @rand_bytes(ptr noundef nonnull %7, i64 noundef 32) #5
  %.not = icmp eq i32 %9, 1
  br i1 %.not, label %.preheader64, label %10

10:                                               ; preds = %2
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.4, ptr noundef nonnull @.str.5, i32 noundef 1088, ptr noundef nonnull @__FUNCTION__.kyber_cpa_keygen) #6
  br label %43

.preheader64:                                     ; preds = %2
  %13 = getelementptr inbounds i8, ptr %7, i64 32
  call void @kyber_g_hash(ptr noundef nonnull %7, i64 noundef 32, ptr noundef nonnull %7)
  %14 = call i32 @kyber_poly_uniform_sample(ptr noundef nonnull %3, ptr noundef nonnull %7, i8 noundef zeroext 0, i8 noundef zeroext 0)
  %15 = getelementptr inbounds i8, ptr %3, i64 512
  %16 = call i32 @kyber_poly_uniform_sample(ptr noundef nonnull %15, ptr noundef nonnull %7, i8 noundef zeroext 1, i8 noundef zeroext 0)
  %17 = getelementptr inbounds i8, ptr %3, i64 1024
  %18 = call i32 @kyber_poly_uniform_sample(ptr noundef nonnull %17, ptr noundef nonnull %7, i8 noundef zeroext 0, i8 noundef zeroext 1)
  %19 = getelementptr inbounds i8, ptr %3, i64 1536
  %20 = call i32 @kyber_poly_uniform_sample(ptr noundef nonnull %19, ptr noundef nonnull %7, i8 noundef zeroext 1, i8 noundef zeroext 1)
  %21 = call i32 @kyber_poly_cbd_sample(ptr noundef nonnull %4, i32 noundef 3, ptr noundef nonnull %13, i8 noundef zeroext 0)
  %22 = getelementptr inbounds i8, ptr %4, i64 512
  %23 = call i32 @kyber_poly_cbd_sample(ptr noundef nonnull %22, i32 noundef 3, ptr noundef nonnull %13, i8 noundef zeroext 1)
  %24 = call i32 @kyber_poly_cbd_sample(ptr noundef nonnull %5, i32 noundef 3, ptr noundef nonnull %13, i8 noundef zeroext 2)
  %25 = getelementptr inbounds i8, ptr %5, i64 512
  %26 = call i32 @kyber_poly_cbd_sample(ptr noundef nonnull %25, i32 noundef 3, ptr noundef nonnull %13, i8 noundef zeroext 3)
  %27 = call i32 @kyber_poly_ntt(ptr noundef nonnull %4)
  %28 = call i32 @kyber_poly_ntt(ptr noundef nonnull %22)
  %29 = call i32 @kyber_poly_ntt(ptr noundef nonnull %5)
  %30 = call i32 @kyber_poly_ntt(ptr noundef nonnull %25)
  call void @kyber_poly_set_zero(ptr noundef nonnull %6)
  %31 = getelementptr inbounds i8, ptr %6, i64 512
  call void @kyber_poly_set_zero(ptr noundef nonnull %31)
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %8) #5
  %32 = call i32 @kyber_poly_ntt_mul(ptr noundef nonnull %8, ptr noundef nonnull %3, ptr noundef nonnull %4)
  call void @kyber_poly_add(ptr noundef nonnull %6, ptr noundef nonnull %6, ptr noundef nonnull %8)
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %8) #5
  %33 = call i32 @kyber_poly_ntt_mul(ptr noundef nonnull %8, ptr noundef nonnull %15, ptr noundef nonnull %22)
  call void @kyber_poly_add(ptr noundef nonnull %6, ptr noundef nonnull %6, ptr noundef nonnull %8)
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %8) #5
  call void @kyber_poly_add(ptr noundef nonnull %6, ptr noundef nonnull %6, ptr noundef nonnull %5)
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %8) #5
  %34 = call i32 @kyber_poly_ntt_mul(ptr noundef nonnull %8, ptr noundef nonnull %17, ptr noundef nonnull %4)
  call void @kyber_poly_add(ptr noundef nonnull %31, ptr noundef nonnull %31, ptr noundef nonnull %8)
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %8) #5
  call void @llvm.lifetime.start.p0(i64 512, ptr nonnull %8) #5
  %35 = call i32 @kyber_poly_ntt_mul(ptr noundef nonnull %8, ptr noundef nonnull %19, ptr noundef nonnull %22)
  call void @kyber_poly_add(ptr noundef nonnull %31, ptr noundef nonnull %31, ptr noundef nonnull %8)
  call void @llvm.lifetime.end.p0(i64 512, ptr nonnull %8) #5
  call void @kyber_poly_add(ptr noundef nonnull %31, ptr noundef nonnull %31, ptr noundef nonnull %25)
  %36 = call i32 @kyber_poly_encode12(ptr noundef nonnull %6, ptr noundef %0)
  %37 = call i32 @kyber_poly_encode12(ptr noundef nonnull %4, ptr noundef %1)
  %38 = getelementptr inbounds i8, ptr %0, i64 384
  %39 = call i32 @kyber_poly_encode12(ptr noundef nonnull %31, ptr noundef nonnull %38)
  %40 = getelementptr inbounds i8, ptr %1, i64 384
  %41 = call i32 @kyber_poly_encode12(ptr noundef nonnull %22, ptr noundef nonnull %40)
  %42 = getelementptr inbounds i8, ptr %0, i64 768
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 1 dereferenceable(32) %42, ptr noundef nonnull align 16 dereferenceable(32) %7, i64 32, i1 false)
  call void @gmssl_secure_clear(ptr noundef nonnull %7, i64 noundef 64) #5
  call void @gmssl_secure_clear(ptr noundef nonnull %4, i64 noundef 1024) #5
  call void @gmssl_secure_clear(ptr noundef nonnull %5, i64 noundef 1024) #5
  br label %43

43:                                               ; preds = %.preheader64, %10
  %.056 = phi i32 [ -1, %10 ], [ 1, %.preheader64 ]
  call void @llvm.lifetime.end.p0(i64 64, ptr nonnull %7) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %6) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %5) #5
  call void @llvm.lifetime.end.p0(i64 1024, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 2048, ptr nonnull %3) #5
  ret i32 %.056
}

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


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,SROAPass,SimplifyCFGPass