; LLVM IR from openssl/openssl :: crypto (params)

; 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.ossl_param_st = type { ptr, i32, ptr, i64, i64 }

@.str = external hidden unnamed_addr constant [65 x i8], align 1
@__func__.OSSL_PARAM_get_double = external hidden unnamed_addr constant [22 x i8], align 1

declare void @ERR_new() #0

declare void @ERR_set_debug(ptr noundef, i32 noundef, ptr noundef) #0

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) #0

; 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

; Function Attrs: nounwind uwtable
declare hidden i32 @real_shift() #2

; Function Attrs: nounwind uwtable
define dso_local i32 @OSSL_PARAM_get_double(ptr noundef %0, ptr noundef %1) #2 {
  %3 = alloca i32, align 4
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = alloca i32, align 4
  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 8, ptr %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #3
  %9 = load ptr, ptr %5, align 8, !tbaa !5
  %10 = icmp eq ptr %9, null
  br i1 %10, label %19, label %11

11:                                               ; preds = %2
  %12 = load ptr, ptr %4, align 8, !tbaa !5
  %13 = icmp eq ptr %12, null
  br i1 %13, label %19, label %14

14:                                               ; preds = %11
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ossl_param_st, ptr %15, i32 0, i32 2
  %17 = load ptr, ptr %16, align 8, !tbaa !9
  %18 = icmp eq ptr %17, null
  br i1 %18, label %19, label %20

19:                                               ; preds = %14, %11, %2
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1183, ptr noundef @__func__.OSSL_PARAM_get_double)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 786690, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %113

20:                                               ; preds = %14
  %21 = load ptr, ptr %4, align 8, !tbaa !5
  %22 = getelementptr inbounds %struct.ossl_param_st, ptr %21, i32 0, i32 1
  %23 = load i32, ptr %22, align 8, !tbaa !13
  %24 = icmp eq i32 %23, 3
  br i1 %24, label %25, label %36

25:                                               ; preds = %20
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.ossl_param_st, ptr %26, i32 0, i32 3
  %28 = load i64, ptr %27, align 8, !tbaa !14
  switch i64 %28, label %35 [
    i64 8, label %29
  ]

29:                                               ; preds = %25
  %30 = load ptr, ptr %4, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ossl_param_st, ptr %30, i32 0, i32 2
  %32 = load ptr, ptr %31, align 8, !tbaa !9
  %33 = load double, ptr %32, align 8, !tbaa !15
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  store double %33, ptr %34, align 8, !tbaa !15
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %113

35:                                               ; preds = %25
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1193, ptr noundef @__func__.OSSL_PARAM_get_double)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 130, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %113

36:                                               ; preds = %20
  %37 = load ptr, ptr %4, align 8, !tbaa !5
  %38 = getelementptr inbounds %struct.ossl_param_st, ptr %37, i32 0, i32 1
  %39 = load i32, ptr %38, align 8, !tbaa !13
  %40 = icmp eq i32 %39, 2
  br i1 %40, label %41, label %68

41:                                               ; preds = %36
  %42 = load ptr, ptr %4, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ossl_param_st, ptr %42, i32 0, i32 3
  %44 = load i64, ptr %43, align 8, !tbaa !14
  switch i64 %44, label %67 [
    i64 4, label %45
    i64 8, label %52
  ]

45:                                               ; preds = %41
  %46 = load ptr, ptr %4, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.ossl_param_st, ptr %46, i32 0, i32 2
  %48 = load ptr, ptr %47, align 8, !tbaa !9
  %49 = load i32, ptr %48, align 4, !tbaa !17
  %50 = uitofp i32 %49 to double
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  store double %50, ptr %51, align 8, !tbaa !15
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %113

52:                                               ; preds = %41
  %53 = load ptr, ptr %4, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ossl_param_st, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !9
  %56 = load i64, ptr %55, align 8, !tbaa !18
  store i64 %56, ptr %7, align 8, !tbaa !18
  %57 = load i64, ptr %7, align 8, !tbaa !18
  %58 = call i32 @real_shift()
  %59 = zext i32 %58 to i64
  %60 = lshr i64 %57, %59
  %61 = icmp eq i64 %60, 0
  br i1 %61, label %62, label %66

62:                                               ; preds = %52
  %63 = load i64, ptr %7, align 8, !tbaa !18
  %64 = uitofp i64 %63 to double
  %65 = load ptr, ptr %5, align 8, !tbaa !5
  store double %64, ptr %65, align 8, !tbaa !15
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %113

66:                                               ; preds = %52
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1206, ptr noundef @__func__.OSSL_PARAM_get_double)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 123, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %113

67:                                               ; preds = %41
  br label %111

68:                                               ; preds = %36
  %69 = load ptr, ptr %4, align 8, !tbaa !5
  %70 = getelementptr inbounds %struct.ossl_param_st, ptr %69, i32 0, i32 1
  %71 = load i32, ptr %70, align 8, !tbaa !13
  %72 = icmp eq i32 %71, 1
  br i1 %72, label %73, label %110

73:                                               ; preds = %68
  %74 = load ptr, ptr %4, align 8, !tbaa !5
  %75 = getelementptr inbounds %struct.ossl_param_st, ptr %74, i32 0, i32 3
  %76 = load i64, ptr %75, align 8, !tbaa !14
  switch i64 %76, label %109 [
    i64 4, label %77
    i64 8, label %84
  ]

77:                                               ; preds = %73
  %78 = load ptr, ptr %4, align 8, !tbaa !5
  %79 = getelementptr inbounds %struct.ossl_param_st, ptr %78, i32 0, i32 2
  %80 = load ptr, ptr %79, align 8, !tbaa !9
  %81 = load i32, ptr %80, align 4, !tbaa !17
  %82 = sitofp i32 %81 to double
  %83 = load ptr, ptr %5, align 8, !tbaa !5
  store double %82, ptr %83, align 8, !tbaa !15
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %113

84:                                               ; preds = %73
  %85 = load ptr, ptr %4, align 8, !tbaa !5
  %86 = getelementptr inbounds %struct.ossl_param_st, ptr %85, i32 0, i32 2
  %87 = load ptr, ptr %86, align 8, !tbaa !9
  %88 = load i64, ptr %87, align 8, !tbaa !18
  store i64 %88, ptr %6, align 8, !tbaa !18
  %89 = load i64, ptr %6, align 8, !tbaa !18
  %90 = icmp slt i64 %89, 0
  br i1 %90, label %91, label %94

91:                                               ; preds = %84
  %92 = load i64, ptr %6, align 8, !tbaa !18
  %93 = sub nsw i64 0, %92
  br label %96

94:                                               ; preds = %84
  %95 = load i64, ptr %6, align 8, !tbaa !18
  br label %96

96:                                               ; preds = %94, %91
  %97 = phi i64 [ %93, %91 ], [ %95, %94 ]
  store i64 %97, ptr %7, align 8, !tbaa !18
  %98 = load i64, ptr %7, align 8, !tbaa !18
  %99 = call i32 @real_shift()
  %100 = zext i32 %99 to i64
  %101 = lshr i64 %98, %100
  %102 = icmp eq i64 %101, 0
  br i1 %102, label %103, label %108

103:                                              ; preds = %96
  %104 = load i64, ptr %6, align 8, !tbaa !18
  %105 = sitofp i64 %104 to double
  %106 = fadd double 0.000000e+00, %105
  %107 = load ptr, ptr %5, align 8, !tbaa !5
  store double %106, ptr %107, align 8, !tbaa !15
  store i32 1, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %113

108:                                              ; preds = %96
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1221, ptr noundef @__func__.OSSL_PARAM_get_double)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 123, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %113

109:                                              ; preds = %73
  br label %110

110:                                              ; preds = %109, %68
  br label %111

111:                                              ; preds = %110, %67
  br label %112

112:                                              ; preds = %111
  call void @ERR_new()
  call void @ERR_set_debug(ptr noundef @.str, i32 noundef 1225, ptr noundef @__func__.OSSL_PARAM_get_double)
  call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 129, ptr noundef null)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %8, align 4
  br label %113

113:                                              ; preds = %112, %108, %103, %77, %66, %62, %45, %35, %29, %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %114 = load i32, ptr %3, align 4
  ret i32 %114
}

attributes #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 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 #3 = { 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, !6, i64 16}
!10 = !{!"ossl_param_st", !6, i64 0, !11, i64 8, !6, i64 16, !12, i64 24, !12, i64 32}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!10, !11, i64 8}
!14 = !{!10, !12, i64 24}
!15 = !{!16, !16, i64 0}
!16 = !{!"double", !7, i64 0}
!17 = !{!11, !11, i64 0}
!18 = !{!12, !12, 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 = external hidden unnamed_addr constant [65 x i8], align 1
@__func__.OSSL_PARAM_get_double = external hidden unnamed_addr constant [22 x i8], align 1

declare void @ERR_new() local_unnamed_addr #0

declare void @ERR_set_debug(ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

declare void @ERR_set_error(i32 noundef, i32 noundef, ptr noundef, ...) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare hidden i32 @real_shift() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @OSSL_PARAM_get_double(ptr noundef readonly %0, ptr noundef writeonly %1) local_unnamed_addr #1 {
  %3 = icmp eq ptr %1, null
  %4 = icmp eq ptr %0, null
  %or.cond = or i1 %4, %3
  br i1 %or.cond, label %9, label %5

5:                                                ; preds = %2
  %6 = getelementptr inbounds i8, ptr %0, i64 16
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %10

9:                                                ; preds = %5, %2
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 1183, ptr noundef nonnull @__func__.OSSL_PARAM_get_double) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 786690, ptr noundef null) #3
  br label %51

10:                                               ; preds = %5
  %11 = getelementptr inbounds i8, ptr %0, i64 8
  %12 = load i32, ptr %11, align 8, !tbaa !12
  switch i32 %12, label %50 [
    i32 3, label %13
    i32 2, label %19
    i32 1, label %34
  ]

13:                                               ; preds = %10
  %14 = getelementptr inbounds i8, ptr %0, i64 24
  %15 = load i64, ptr %14, align 8, !tbaa !13
  %cond = icmp eq i64 %15, 8
  br i1 %cond, label %16, label %18

16:                                               ; preds = %13
  %17 = load double, ptr %7, align 8, !tbaa !14
  store double %17, ptr %1, align 8, !tbaa !14
  br label %51

18:                                               ; preds = %13
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 1193, ptr noundef nonnull @__func__.OSSL_PARAM_get_double) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 130, ptr noundef null) #3
  br label %51

19:                                               ; preds = %10
  %20 = getelementptr inbounds i8, ptr %0, i64 24
  %21 = load i64, ptr %20, align 8, !tbaa !13
  switch i64 %21, label %50 [
    i64 4, label %22
    i64 8, label %25
  ]

22:                                               ; preds = %19
  %23 = load i32, ptr %7, align 4, !tbaa !16
  %24 = uitofp i32 %23 to double
  store double %24, ptr %1, align 8, !tbaa !14
  br label %51

25:                                               ; preds = %19
  %26 = load i64, ptr %7, align 8, !tbaa !17
  %27 = tail call i32 @real_shift()
  %28 = zext nneg i32 %27 to i64
  %29 = lshr i64 %26, %28
  %30 = icmp eq i64 %29, 0
  br i1 %30, label %31, label %33

31:                                               ; preds = %25
  %32 = uitofp i64 %26 to double
  store double %32, ptr %1, align 8, !tbaa !14
  br label %51

33:                                               ; preds = %25
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 1206, ptr noundef nonnull @__func__.OSSL_PARAM_get_double) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 123, ptr noundef null) #3
  br label %51

34:                                               ; preds = %10
  %35 = getelementptr inbounds i8, ptr %0, i64 24
  %36 = load i64, ptr %35, align 8, !tbaa !13
  switch i64 %36, label %50 [
    i64 4, label %37
    i64 8, label %40
  ]

37:                                               ; preds = %34
  %38 = load i32, ptr %7, align 4, !tbaa !16
  %39 = sitofp i32 %38 to double
  store double %39, ptr %1, align 8, !tbaa !14
  br label %51

40:                                               ; preds = %34
  %41 = load i64, ptr %7, align 8, !tbaa !17
  %42 = tail call i64 @llvm.abs.i64(i64 %41, i1 true)
  %43 = tail call i32 @real_shift()
  %44 = zext nneg i32 %43 to i64
  %45 = lshr i64 %42, %44
  %46 = icmp eq i64 %45, 0
  br i1 %46, label %47, label %49

47:                                               ; preds = %40
  %48 = sitofp i64 %41 to double
  store double %48, ptr %1, align 8, !tbaa !14
  br label %51

49:                                               ; preds = %40
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 1221, ptr noundef nonnull @__func__.OSSL_PARAM_get_double) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 123, ptr noundef null) #3
  br label %51

50:                                               ; preds = %10, %19, %34
  tail call void @ERR_new() #3
  tail call void @ERR_set_debug(ptr noundef nonnull @.str, i32 noundef 1225, ptr noundef nonnull @__func__.OSSL_PARAM_get_double) #3
  tail call void (i32, i32, ptr, ...) @ERR_set_error(i32 noundef 15, i32 noundef 129, ptr noundef null) #3
  br label %51

51:                                               ; preds = %50, %49, %47, %37, %33, %31, %22, %18, %16, %9
  %.0 = phi i32 [ 0, %9 ], [ 1, %16 ], [ 0, %18 ], [ 0, %50 ], [ 1, %31 ], [ 0, %33 ], [ 1, %22 ], [ 1, %47 ], [ 0, %49 ], [ 1, %37 ]
  ret i32 %.0
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i64 @llvm.abs.i64(i64, i1 immarg) #2

attributes #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 = { 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 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #3 = { 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, !7, i64 16}
!6 = !{!"ossl_param_st", !7, i64 0, !10, i64 8, !7, i64 16, !11, i64 24, !11, i64 32}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"long", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!6, !11, i64 24}
!14 = !{!15, !15, i64 0}
!15 = !{!"double", !8, i64 0}
!16 = !{!10, !10, i64 0}
!17 = !{!11, !11, i64 0}


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