; LLVM IR from openssl/openssl :: crypto/modes (ocb128)

; 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.ocb128_context = type { ptr, ptr, ptr, ptr, ptr, i64, i64, %union.OCB_BLOCK, %union.OCB_BLOCK, ptr, %struct.anon }
%union.OCB_BLOCK = type { [2 x i64] }
%struct.anon = type { i64, i64, %union.OCB_BLOCK, %union.OCB_BLOCK, %union.OCB_BLOCK, %union.OCB_BLOCK }

@.str = external hidden unnamed_addr constant [71 x i8], align 1

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local i32 @CRYPTO_ocb128_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) #1 {
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca ptr, align 8
  %12 = alloca ptr, align 8
  %13 = alloca ptr, align 8
  store ptr %0, ptr %8, align 8, !tbaa !5
  store ptr %1, ptr %9, align 8, !tbaa !5
  store ptr %2, ptr %10, align 8, !tbaa !5
  store ptr %3, ptr %11, align 8, !tbaa !5
  store ptr %4, ptr %12, align 8, !tbaa !5
  store ptr %5, ptr %13, align 8, !tbaa !5
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %14, i8 0, i64 176, i1 false)
  %15 = load ptr, ptr %8, align 8, !tbaa !5
  %16 = getelementptr inbounds %struct.ocb128_context, ptr %15, i32 0, i32 5
  store i64 0, ptr %16, align 8, !tbaa !9
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.ocb128_context, ptr %17, i32 0, i32 6
  store i64 5, ptr %18, align 8, !tbaa !14
  %19 = load ptr, ptr %8, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.ocb128_context, ptr %19, i32 0, i32 6
  %21 = load i64, ptr %20, align 8, !tbaa !14
  %22 = mul i64 %21, 16
  %23 = call ptr @CRYPTO_malloc(i64 noundef %22, ptr noundef @.str, i32 noundef 158)
  %24 = load ptr, ptr %8, align 8, !tbaa !5
  %25 = getelementptr inbounds %struct.ocb128_context, ptr %24, i32 0, i32 9
  store ptr %23, ptr %25, align 8, !tbaa !15
  %26 = icmp eq ptr %23, null
  br i1 %26, label %27, label %28

27:                                               ; preds = %6
  store i32 0, ptr %7, align 4
  br label %98

28:                                               ; preds = %6
  %29 = load ptr, ptr %11, align 8, !tbaa !5
  %30 = load ptr, ptr %8, align 8, !tbaa !5
  %31 = getelementptr inbounds %struct.ocb128_context, ptr %30, i32 0, i32 0
  store ptr %29, ptr %31, align 8, !tbaa !16
  %32 = load ptr, ptr %12, align 8, !tbaa !5
  %33 = load ptr, ptr %8, align 8, !tbaa !5
  %34 = getelementptr inbounds %struct.ocb128_context, ptr %33, i32 0, i32 1
  store ptr %32, ptr %34, align 8, !tbaa !17
  %35 = load ptr, ptr %13, align 8, !tbaa !5
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = getelementptr inbounds %struct.ocb128_context, ptr %36, i32 0, i32 4
  store ptr %35, ptr %37, align 8, !tbaa !18
  %38 = load ptr, ptr %9, align 8, !tbaa !5
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds %struct.ocb128_context, ptr %39, i32 0, i32 2
  store ptr %38, ptr %40, align 8, !tbaa !19
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = getelementptr inbounds %struct.ocb128_context, ptr %42, i32 0, i32 3
  store ptr %41, ptr %43, align 8, !tbaa !20
  %44 = load ptr, ptr %8, align 8, !tbaa !5
  %45 = getelementptr inbounds %struct.ocb128_context, ptr %44, i32 0, i32 0
  %46 = load ptr, ptr %45, align 8, !tbaa !16
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  %48 = getelementptr inbounds %struct.ocb128_context, ptr %47, i32 0, i32 7
  %49 = getelementptr inbounds [16 x i8], ptr %48, i64 0, i64 0
  %50 = load ptr, ptr %8, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.ocb128_context, ptr %50, i32 0, i32 7
  %52 = getelementptr inbounds [16 x i8], ptr %51, i64 0, i64 0
  %53 = load ptr, ptr %8, align 8, !tbaa !5
  %54 = getelementptr inbounds %struct.ocb128_context, ptr %53, i32 0, i32 2
  %55 = load ptr, ptr %54, align 8, !tbaa !19
  call void %46(ptr noundef %49, ptr noundef %52, ptr noundef %55)
  %56 = load ptr, ptr %8, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.ocb128_context, ptr %56, i32 0, i32 7
  %58 = load ptr, ptr %8, align 8, !tbaa !5
  %59 = getelementptr inbounds %struct.ocb128_context, ptr %58, i32 0, i32 8
  call void @ocb_double(ptr noundef %57, ptr noundef %59)
  %60 = load ptr, ptr %8, align 8, !tbaa !5
  %61 = getelementptr inbounds %struct.ocb128_context, ptr %60, i32 0, i32 8
  %62 = load ptr, ptr %8, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ocb128_context, ptr %62, i32 0, i32 9
  %64 = load ptr, ptr %63, align 8, !tbaa !15
  call void @ocb_double(ptr noundef %61, ptr noundef %64)
  %65 = load ptr, ptr %8, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.ocb128_context, ptr %65, i32 0, i32 9
  %67 = load ptr, ptr %66, align 8, !tbaa !15
  %68 = load ptr, ptr %8, align 8, !tbaa !5
  %69 = getelementptr inbounds %struct.ocb128_context, ptr %68, i32 0, i32 9
  %70 = load ptr, ptr %69, align 8, !tbaa !15
  %71 = getelementptr inbounds %union.OCB_BLOCK, ptr %70, i64 1
  call void @ocb_double(ptr noundef %67, ptr noundef %71)
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = getelementptr inbounds %struct.ocb128_context, ptr %72, i32 0, i32 9
  %74 = load ptr, ptr %73, align 8, !tbaa !15
  %75 = getelementptr inbounds %union.OCB_BLOCK, ptr %74, i64 1
  %76 = load ptr, ptr %8, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.ocb128_context, ptr %76, i32 0, i32 9
  %78 = load ptr, ptr %77, align 8, !tbaa !15
  %79 = getelementptr inbounds %union.OCB_BLOCK, ptr %78, i64 2
  call void @ocb_double(ptr noundef %75, ptr noundef %79)
  %80 = load ptr, ptr %8, align 8, !tbaa !5
  %81 = getelementptr inbounds %struct.ocb128_context, ptr %80, i32 0, i32 9
  %82 = load ptr, ptr %81, align 8, !tbaa !15
  %83 = getelementptr inbounds %union.OCB_BLOCK, ptr %82, i64 2
  %84 = load ptr, ptr %8, align 8, !tbaa !5
  %85 = getelementptr inbounds %struct.ocb128_context, ptr %84, i32 0, i32 9
  %86 = load ptr, ptr %85, align 8, !tbaa !15
  %87 = getelementptr inbounds %union.OCB_BLOCK, ptr %86, i64 3
  call void @ocb_double(ptr noundef %83, ptr noundef %87)
  %88 = load ptr, ptr %8, align 8, !tbaa !5
  %89 = getelementptr inbounds %struct.ocb128_context, ptr %88, i32 0, i32 9
  %90 = load ptr, ptr %89, align 8, !tbaa !15
  %91 = getelementptr inbounds %union.OCB_BLOCK, ptr %90, i64 3
  %92 = load ptr, ptr %8, align 8, !tbaa !5
  %93 = getelementptr inbounds %struct.ocb128_context, ptr %92, i32 0, i32 9
  %94 = load ptr, ptr %93, align 8, !tbaa !15
  %95 = getelementptr inbounds %union.OCB_BLOCK, ptr %94, i64 4
  call void @ocb_double(ptr noundef %91, ptr noundef %95)
  %96 = load ptr, ptr %8, align 8, !tbaa !5
  %97 = getelementptr inbounds %struct.ocb128_context, ptr %96, i32 0, i32 5
  store i64 4, ptr %97, align 8, !tbaa !9
  store i32 1, ptr %7, align 4
  br label %98

98:                                               ; preds = %28, %27
  %99 = load i32, ptr %7, align 4
  ret i32 %99
}

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

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

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 nounwind willreturn memory(argmem: write) }

!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, !11, i64 40}
!10 = !{!"ocb128_context", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !11, i64 40, !11, i64 48, !7, i64 56, !7, i64 72, !6, i64 88, !12, i64 96}
!11 = !{!"long", !7, i64 0}
!12 = !{!"", !13, i64 0, !13, i64 8, !7, i64 16, !7, i64 32, !7, i64 48, !7, i64 64}
!13 = !{!"long long", !7, i64 0}
!14 = !{!10, !11, i64 48}
!15 = !{!10, !6, i64 88}
!16 = !{!10, !6, i64 0}
!17 = !{!10, !6, i64 8}
!18 = !{!10, !6, i64 32}
!19 = !{!10, !6, i64 16}
!20 = !{!10, !6, i64 24}


; 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 [71 x i8], align 1

declare ptr @CRYPTO_malloc(i64 noundef, ptr noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @CRYPTO_ocb128_init(ptr noundef %0, ptr noundef %1, ptr noundef %2, ptr noundef %3, ptr noundef %4, ptr noundef %5) local_unnamed_addr #1 {
  %7 = getelementptr inbounds i8, ptr %0, i64 48
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(176) %0, i8 0, i64 176, i1 false)
  store i64 5, ptr %7, align 8, !tbaa !5
  %8 = tail call ptr @CRYPTO_malloc(i64 noundef 80, ptr noundef nonnull @.str, i32 noundef 158) #3
  %9 = getelementptr inbounds i8, ptr %0, i64 88
  store ptr %8, ptr %9, align 8, !tbaa !13
  %10 = icmp eq ptr %8, null
  br i1 %10, label %31, label %11

11:                                               ; preds = %6
  %12 = getelementptr inbounds i8, ptr %0, i64 40
  store ptr %3, ptr %0, align 8, !tbaa !14
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  store ptr %4, ptr %13, align 8, !tbaa !15
  %14 = getelementptr inbounds i8, ptr %0, i64 32
  store ptr %5, ptr %14, align 8, !tbaa !16
  %15 = getelementptr inbounds i8, ptr %0, i64 16
  store ptr %1, ptr %15, align 8, !tbaa !17
  %16 = getelementptr inbounds i8, ptr %0, i64 24
  store ptr %2, ptr %16, align 8, !tbaa !18
  %17 = getelementptr inbounds i8, ptr %0, i64 56
  tail call void %3(ptr noundef nonnull %17, ptr noundef nonnull %17, ptr noundef %1) #3
  %18 = getelementptr inbounds i8, ptr %0, i64 72
  tail call void @ocb_double(ptr noundef nonnull %17, ptr noundef nonnull %18)
  %19 = load ptr, ptr %9, align 8, !tbaa !13
  tail call void @ocb_double(ptr noundef nonnull %18, ptr noundef %19)
  %20 = load ptr, ptr %9, align 8, !tbaa !13
  %21 = getelementptr inbounds i8, ptr %20, i64 16
  tail call void @ocb_double(ptr noundef %20, ptr noundef nonnull %21)
  %22 = load ptr, ptr %9, align 8, !tbaa !13
  %23 = getelementptr inbounds i8, ptr %22, i64 16
  %24 = getelementptr inbounds i8, ptr %22, i64 32
  tail call void @ocb_double(ptr noundef nonnull %23, ptr noundef nonnull %24)
  %25 = load ptr, ptr %9, align 8, !tbaa !13
  %26 = getelementptr inbounds i8, ptr %25, i64 32
  %27 = getelementptr inbounds i8, ptr %25, i64 48
  tail call void @ocb_double(ptr noundef nonnull %26, ptr noundef nonnull %27)
  %28 = load ptr, ptr %9, align 8, !tbaa !13
  %29 = getelementptr inbounds i8, ptr %28, i64 48
  %30 = getelementptr inbounds i8, ptr %28, i64 64
  tail call void @ocb_double(ptr noundef nonnull %29, ptr noundef nonnull %30)
  store i64 4, ptr %12, align 8, !tbaa !19
  br label %31

31:                                               ; preds = %6, %11
  %.0 = phi i32 [ 1, %11 ], [ 0, %6 ]
  ret i32 %.0
}

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

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

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
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, !10, i64 48}
!6 = !{!"ocb128_context", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !10, i64 40, !10, i64 48, !8, i64 56, !8, i64 72, !7, i64 88, !11, i64 96}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!"", !12, i64 0, !12, i64 8, !8, i64 16, !8, i64 32, !8, i64 48, !8, i64 64}
!12 = !{!"long long", !8, i64 0}
!13 = !{!6, !7, i64 88}
!14 = !{!6, !7, i64 0}
!15 = !{!6, !7, i64 8}
!16 = !{!6, !7, i64 32}
!17 = !{!6, !7, i64 16}
!18 = !{!6, !7, i64 24}
!19 = !{!6, !10, i64 40}


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