; LLVM IR from stamparm/cryptospecs :: symmetrical/sources (scop)

; 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.st_key = type { [384 x i64], i8, i8, i8 }

@kt = external dso_local global %struct.st_key, align 8

; Function Attrs: nounwind uwtable
define dso_local void @init_key(ptr noundef %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca [4 x i64], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #2
  call void @llvm.lifetime.start.p0(i64 32, ptr %6) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #2
  %9 = load ptr, ptr %3, align 8, !tbaa !5
  %10 = load i32, ptr %4, align 4, !tbaa !9
  call void @expand_key(ptr noundef %9, i32 noundef %10)
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %11

11:                                               ; preds = %16, %2
  %12 = load i32, ptr %7, align 4, !tbaa !9
  %13 = icmp slt i32 %12, 8
  br i1 %13, label %14, label %19

14:                                               ; preds = %11
  %15 = getelementptr inbounds [4 x i64], ptr %6, i64 0, i64 0
  call void @gp8(ptr noundef %15)
  br label %16

16:                                               ; preds = %14
  %17 = load i32, ptr %7, align 4, !tbaa !9
  %18 = add nsw i32 %17, 1
  store i32 %18, ptr %7, align 4, !tbaa !9
  br label %11, !llvm.loop !11

19:                                               ; preds = %11
  store i32 0, ptr %7, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %41, %19
  %21 = load i32, ptr %7, align 4, !tbaa !9
  %22 = icmp slt i32 %21, 12
  br i1 %22, label %23, label %44

23:                                               ; preds = %20
  store i32 0, ptr %8, align 4, !tbaa !9
  br label %24

24:                                               ; preds = %36, %23
  %25 = load i32, ptr %8, align 4, !tbaa !9
  %26 = icmp slt i32 %25, 8
  br i1 %26, label %27, label %39

27:                                               ; preds = %24
  %28 = load i32, ptr %7, align 4, !tbaa !9
  %29 = mul nsw i32 %28, 32
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds i64, ptr @kt, i64 %30
  %32 = load i32, ptr %8, align 4, !tbaa !9
  %33 = mul nsw i32 %32, 4
  %34 = sext i32 %33 to i64
  %35 = getelementptr inbounds i64, ptr %31, i64 %34
  call void @gp8(ptr noundef %35)
  br label %36

36:                                               ; preds = %27
  %37 = load i32, ptr %8, align 4, !tbaa !9
  %38 = add nsw i32 %37, 1
  store i32 %38, ptr %8, align 4, !tbaa !9
  br label %24, !llvm.loop !13

39:                                               ; preds = %24
  %40 = getelementptr inbounds [4 x i64], ptr %6, i64 0, i64 0
  call void @gp8(ptr noundef %40)
  br label %41

41:                                               ; preds = %39
  %42 = load i32, ptr %7, align 4, !tbaa !9
  %43 = add nsw i32 %42, 1
  store i32 %43, ptr %7, align 4, !tbaa !9
  br label %20, !llvm.loop !14

44:                                               ; preds = %20
  %45 = getelementptr inbounds [4 x i64], ptr %6, i64 0, i64 0
  call void @gp8(ptr noundef %45)
  %46 = getelementptr inbounds [4 x i64], ptr %6, i64 0, i64 3
  %47 = load i64, ptr %46, align 8, !tbaa !15
  %48 = lshr i64 %47, 24
  %49 = trunc i64 %48 to i8
  store i8 %49, ptr getelementptr inbounds (%struct.st_key, ptr @kt, i32 0, i32 1), align 8, !tbaa !17
  %50 = getelementptr inbounds [4 x i64], ptr %6, i64 0, i64 3
  %51 = load i64, ptr %50, align 8, !tbaa !15
  %52 = lshr i64 %51, 16
  %53 = trunc i64 %52 to i8
  store i8 %53, ptr getelementptr inbounds (%struct.st_key, ptr @kt, i32 0, i32 2), align 1, !tbaa !19
  %54 = getelementptr inbounds [4 x i64], ptr %6, i64 0, i64 3
  %55 = load i64, ptr %54, align 8, !tbaa !15
  %56 = lshr i64 %55, 8
  %57 = trunc i64 %56 to i8
  store i8 %57, ptr getelementptr inbounds (%struct.st_key, ptr @kt, i32 0, i32 3), align 2, !tbaa !20
  %58 = getelementptr inbounds [4 x i64], ptr %6, i64 0, i64 3
  %59 = load i64, ptr %58, align 8, !tbaa !15
  %60 = and i64 %59, 127
  store i64 %60, ptr %5, align 8, !tbaa !15
  %61 = load i64, ptr %5, align 8, !tbaa !15
  %62 = getelementptr inbounds [384 x i64], ptr @kt, i64 0, i64 %61
  %63 = load i64, ptr %62, align 8, !tbaa !15
  %64 = or i64 %63, 1
  store i64 %64, ptr %62, align 8, !tbaa !15
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #2
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #2
  ret void
}

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

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

; Function Attrs: nounwind uwtable
declare hidden void @gp8(ptr noundef) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = distinct !{!13, !12}
!14 = distinct !{!14, !12}
!15 = !{!16, !16, i64 0}
!16 = !{!"long", !7, i64 0}
!17 = !{!18, !7, i64 3072}
!18 = !{!"", !7, i64 0, !7, i64 3072, !7, i64 3073, !7, i64 3074}
!19 = !{!18, !7, i64 3073}
!20 = !{!18, !7, i64 3074}


; 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.st_key = type { [384 x i64], i8, i8, i8 }

@kt = external dso_local global %struct.st_key, align 8

; Function Attrs: nounwind uwtable
define dso_local void @init_key(ptr noundef %0, i32 noundef %1) local_unnamed_addr #0 {
.preheader.preheader:
  %2 = alloca [4 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %2) #2
  tail call void @expand_key(ptr noundef %0, i32 noundef %1)
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull @kt)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 32))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 64))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 96))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 128))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 160))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 192))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 224))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 256))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 288))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 320))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 352))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 384))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 416))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 448))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 480))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 512))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 544))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 576))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 608))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 640))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 672))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 704))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 736))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 768))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 800))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 832))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 864))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 896))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 928))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 960))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 992))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1024))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1056))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1088))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1120))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1152))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1184))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1216))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1248))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1280))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1312))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1344))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1376))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1408))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1440))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1472))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1504))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1536))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1568))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1600))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1632))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1664))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1696))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1728))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1760))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1792))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1824))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1856))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1888))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1920))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1952))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 1984))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2016))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2048))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2080))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2112))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2144))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2176))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2208))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2240))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2272))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2304))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2336))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2368))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2400))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2432))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2464))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2496))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2528))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2560))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2592))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2624))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2656))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2688))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2720))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2752))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2784))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2816))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2848))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2880))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2912))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2944))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 2976))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 3008))
  call void @gp8(ptr noundef nonnull getelementptr inbounds (i8, ptr @kt, i64 3040))
  call void @gp8(ptr noundef nonnull %2)
  call void @gp8(ptr noundef nonnull %2)
  %3 = getelementptr inbounds i8, ptr %2, i64 24
  %4 = load i64, ptr %3, align 8, !tbaa !5
  %5 = lshr i64 %4, 24
  %6 = trunc i64 %5 to i8
  store i8 %6, ptr getelementptr inbounds (i8, ptr @kt, i64 3072), align 8, !tbaa !9
  %7 = lshr i64 %4, 16
  %8 = trunc i64 %7 to i8
  store i8 %8, ptr getelementptr inbounds (i8, ptr @kt, i64 3073), align 1, !tbaa !11
  %9 = lshr i64 %4, 8
  %10 = trunc i64 %9 to i8
  store i8 %10, ptr getelementptr inbounds (i8, ptr @kt, i64 3074), align 2, !tbaa !12
  %11 = and i64 %4, 127
  %12 = getelementptr inbounds [384 x i64], ptr @kt, i64 0, i64 %11
  %13 = load i64, ptr %12, align 8, !tbaa !5
  %14 = or i64 %13, 1
  store i64 %14, ptr %12, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %2) #2
  ret void
}

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

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

; Function Attrs: nounwind uwtable
declare hidden void @gp8(ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !7, i64 3072}
!10 = !{!"", !7, i64 0, !7, i64 3072, !7, i64 3073, !7, i64 3074}
!11 = !{!10, !7, i64 3073}
!12 = !{!10, !7, i64 3074}


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