; LLVM IR from openssl/openssl :: crypto/des (set_key)

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

@odd_parity = external hidden constant [256 x i8], align 16

; Function Attrs: nounwind uwtable
define dso_local void @DES_set_odd_parity(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  br label %4

4:                                                ; preds = %21, %1
  %5 = load i32, ptr %3, align 4, !tbaa !9
  %6 = zext i32 %5 to i64
  %7 = icmp ult i64 %6, 8
  br i1 %7, label %8, label %24

8:                                                ; preds = %4
  %9 = load ptr, ptr %2, align 8, !tbaa !5
  %10 = load i32, ptr %3, align 4, !tbaa !9
  %11 = zext i32 %10 to i64
  %12 = getelementptr inbounds [8 x i8], ptr %9, i64 0, i64 %11
  %13 = load i8, ptr %12, align 1, !tbaa !11
  %14 = zext i8 %13 to i64
  %15 = getelementptr inbounds [256 x i8], ptr @odd_parity, i64 0, i64 %14
  %16 = load i8, ptr %15, align 1, !tbaa !11
  %17 = load ptr, ptr %2, align 8, !tbaa !5
  %18 = load i32, ptr %3, align 4, !tbaa !9
  %19 = zext i32 %18 to i64
  %20 = getelementptr inbounds [8 x i8], ptr %17, i64 0, i64 %19
  store i8 %16, ptr %20, align 1, !tbaa !11
  br label %21

21:                                               ; preds = %8
  %22 = load i32, ptr %3, align 4, !tbaa !9
  %23 = add i32 %22, 1
  store i32 %23, ptr %3, align 4, !tbaa !9
  br label %4, !llvm.loop !12

24:                                               ; preds = %4
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #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: 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 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}


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

@odd_parity = external hidden local_unnamed_addr constant [256 x i8], align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @DES_set_odd_parity(ptr nocapture noundef %0) local_unnamed_addr #0 {
  %2 = load i8, ptr %0, align 1, !tbaa !5
  %3 = zext i8 %2 to i64
  %4 = getelementptr inbounds [256 x i8], ptr @odd_parity, i64 0, i64 %3
  %5 = load i8, ptr %4, align 1, !tbaa !5
  store i8 %5, ptr %0, align 1, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %0, i64 1
  %7 = load i8, ptr %6, align 1, !tbaa !5
  %8 = zext i8 %7 to i64
  %9 = getelementptr inbounds [256 x i8], ptr @odd_parity, i64 0, i64 %8
  %10 = load i8, ptr %9, align 1, !tbaa !5
  store i8 %10, ptr %6, align 1, !tbaa !5
  %11 = getelementptr inbounds i8, ptr %0, i64 2
  %12 = load i8, ptr %11, align 1, !tbaa !5
  %13 = zext i8 %12 to i64
  %14 = getelementptr inbounds [256 x i8], ptr @odd_parity, i64 0, i64 %13
  %15 = load i8, ptr %14, align 1, !tbaa !5
  store i8 %15, ptr %11, align 1, !tbaa !5
  %16 = getelementptr inbounds i8, ptr %0, i64 3
  %17 = load i8, ptr %16, align 1, !tbaa !5
  %18 = zext i8 %17 to i64
  %19 = getelementptr inbounds [256 x i8], ptr @odd_parity, i64 0, i64 %18
  %20 = load i8, ptr %19, align 1, !tbaa !5
  store i8 %20, ptr %16, align 1, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 4
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = zext i8 %22 to i64
  %24 = getelementptr inbounds [256 x i8], ptr @odd_parity, i64 0, i64 %23
  %25 = load i8, ptr %24, align 1, !tbaa !5
  store i8 %25, ptr %21, align 1, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %0, i64 5
  %27 = load i8, ptr %26, align 1, !tbaa !5
  %28 = zext i8 %27 to i64
  %29 = getelementptr inbounds [256 x i8], ptr @odd_parity, i64 0, i64 %28
  %30 = load i8, ptr %29, align 1, !tbaa !5
  store i8 %30, ptr %26, align 1, !tbaa !5
  %31 = getelementptr inbounds i8, ptr %0, i64 6
  %32 = load i8, ptr %31, align 1, !tbaa !5
  %33 = zext i8 %32 to i64
  %34 = getelementptr inbounds [256 x i8], ptr @odd_parity, i64 0, i64 %33
  %35 = load i8, ptr %34, align 1, !tbaa !5
  store i8 %35, ptr %31, align 1, !tbaa !5
  %36 = getelementptr inbounds i8, ptr %0, i64 7
  %37 = load i8, ptr %36, align 1, !tbaa !5
  %38 = zext i8 %37 to i64
  %39 = getelementptr inbounds [256 x i8], ptr @odd_parity, i64 0, i64 %38
  %40 = load i8, ptr %39, align 1, !tbaa !5
  store i8 %40, ptr %36, align 1, !tbaa !5
  ret void
}

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

!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 = !{!"omnipotent char", !7, i64 0}
!7 = !{!"Simple C/C++ TBAA"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass