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

; 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: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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) #2

; Function Attrs: nounwind uwtable
define dso_local i32 @CRYPTO_ocb128_setiv(ptr noundef %0, ptr noundef %1, i64 noundef %2, i64 noundef %3) #3 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  %9 = alloca i64, align 8
  %10 = alloca [16 x i8], align 16
  %11 = alloca [16 x i8], align 16
  %12 = alloca i8, align 1
  %13 = alloca [24 x i8], align 16
  %14 = alloca [16 x i8], align 16
  %15 = alloca i64, align 8
  %16 = alloca i64, align 8
  %17 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i64 %2, ptr %8, align 8, !tbaa !9
  store i64 %3, ptr %9, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr %13) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %14) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %16) #4
  %18 = load i64, ptr %8, align 8, !tbaa !9
  %19 = icmp ugt i64 %18, 15
  br i1 %19, label %29, label %20

20:                                               ; preds = %4
  %21 = load i64, ptr %8, align 8, !tbaa !9
  %22 = icmp ult i64 %21, 1
  br i1 %22, label %29, label %23

23:                                               ; preds = %20
  %24 = load i64, ptr %9, align 8, !tbaa !9
  %25 = icmp ugt i64 %24, 16
  br i1 %25, label %29, label %26

26:                                               ; preds = %23
  %27 = load i64, ptr %9, align 8, !tbaa !9
  %28 = icmp ult i64 %27, 1
  br i1 %28, label %29, label %30

29:                                               ; preds = %26, %23, %20, %4
  store i32 -1, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %122

30:                                               ; preds = %26
  %31 = load ptr, ptr %6, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.ocb128_context, ptr %31, i32 0, i32 10
  call void @llvm.memset.p0.i64(ptr align 8 %32, i8 0, i64 80, i1 false)
  %33 = load i64, ptr %9, align 8, !tbaa !9
  %34 = mul i64 %33, 8
  %35 = urem i64 %34, 128
  %36 = shl i64 %35, 1
  %37 = trunc i64 %36 to i8
  %38 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 0
  store i8 %37, ptr %38, align 16, !tbaa !11
  %39 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 0
  %40 = getelementptr inbounds i8, ptr %39, i64 1
  call void @llvm.memset.p0.i64(ptr align 1 %40, i8 0, i64 15, i1 false)
  %41 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 0
  %42 = getelementptr inbounds i8, ptr %41, i64 16
  %43 = load i64, ptr %8, align 8, !tbaa !9
  %44 = sub i64 0, %43
  %45 = getelementptr inbounds i8, ptr %42, i64 %44
  %46 = load ptr, ptr %7, align 8, !tbaa !5
  %47 = load i64, ptr %8, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 1 %45, ptr align 1 %46, i64 %47, i1 false)
  %48 = load i64, ptr %8, align 8, !tbaa !9
  %49 = sub i64 15, %48
  %50 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 %49
  %51 = load i8, ptr %50, align 1, !tbaa !11
  %52 = zext i8 %51 to i32
  %53 = or i32 %52, 1
  %54 = trunc i32 %53 to i8
  store i8 %54, ptr %50, align 1, !tbaa !11
  %55 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  %56 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %55, ptr align 16 %56, i64 16, i1 false)
  %57 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 15
  %58 = load i8, ptr %57, align 1, !tbaa !11
  %59 = zext i8 %58 to i32
  %60 = and i32 %59, 192
  %61 = trunc i32 %60 to i8
  store i8 %61, ptr %57, align 1, !tbaa !11
  %62 = load ptr, ptr %6, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.ocb128_context, ptr %62, i32 0, i32 0
  %64 = load ptr, ptr %63, align 8, !tbaa !12
  %65 = getelementptr inbounds [16 x i8], ptr %11, i64 0, i64 0
  %66 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %67 = load ptr, ptr %6, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.ocb128_context, ptr %67, i32 0, i32 2
  %69 = load ptr, ptr %68, align 8, !tbaa !16
  call void %64(ptr noundef %65, ptr noundef %66, ptr noundef %69)
  %70 = getelementptr inbounds [24 x i8], ptr %13, i64 0, i64 0
  %71 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %70, ptr align 16 %71, i64 16, i1 false)
  %72 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %73 = getelementptr inbounds [16 x i8], ptr %10, i64 0, i64 0
  %74 = getelementptr inbounds i8, ptr %73, i64 1
  %75 = getelementptr inbounds [24 x i8], ptr %13, i64 0, i64 0
  %76 = getelementptr inbounds i8, ptr %75, i64 16
  call void @ocb_block_xor(ptr noundef %72, ptr noundef %74, i64 noundef 8, ptr noundef %76)
  %77 = getelementptr inbounds [16 x i8], ptr %14, i64 0, i64 15
  %78 = load i8, ptr %77, align 1, !tbaa !11
  %79 = zext i8 %78 to i32
  %80 = and i32 %79, 63
  %81 = sext i32 %80 to i64
  store i64 %81, ptr %15, align 8, !tbaa !9
  %82 = load i64, ptr %15, align 8, !tbaa !9
  %83 = urem i64 %82, 8
  store i64 %83, ptr %16, align 8, !tbaa !9
  %84 = getelementptr inbounds [24 x i8], ptr %13, i64 0, i64 0
  %85 = load i64, ptr %15, align 8, !tbaa !9
  %86 = udiv i64 %85, 8
  %87 = getelementptr inbounds i8, ptr %84, i64 %86
  %88 = load i64, ptr %16, align 8, !tbaa !9
  %89 = load ptr, ptr %6, align 8, !tbaa !5
  %90 = getelementptr inbounds %struct.ocb128_context, ptr %89, i32 0, i32 10
  %91 = getelementptr inbounds %struct.anon, ptr %90, i32 0, i32 4
  %92 = getelementptr inbounds [16 x i8], ptr %91, i64 0, i64 0
  call void @ocb_block_lshift(ptr noundef %87, i64 noundef %88, ptr noundef %92)
  store i8 -1, ptr %12, align 1, !tbaa !11
  %93 = load i64, ptr %16, align 8, !tbaa !9
  %94 = sub i64 8, %93
  %95 = load i8, ptr %12, align 1, !tbaa !11
  %96 = zext i8 %95 to i32
  %97 = trunc i64 %94 to i32
  %98 = shl i32 %96, %97
  %99 = trunc i32 %98 to i8
  store i8 %99, ptr %12, align 1, !tbaa !11
  %100 = getelementptr inbounds [24 x i8], ptr %13, i64 0, i64 0
  %101 = load i64, ptr %15, align 8, !tbaa !9
  %102 = udiv i64 %101, 8
  %103 = getelementptr inbounds i8, ptr %100, i64 %102
  %104 = getelementptr inbounds i8, ptr %103, i64 16
  %105 = load i8, ptr %104, align 1, !tbaa !11
  %106 = zext i8 %105 to i32
  %107 = load i8, ptr %12, align 1, !tbaa !11
  %108 = zext i8 %107 to i32
  %109 = and i32 %106, %108
  %110 = load i64, ptr %16, align 8, !tbaa !9
  %111 = sub i64 8, %110
  %112 = trunc i64 %111 to i32
  %113 = ashr i32 %109, %112
  %114 = load ptr, ptr %6, align 8, !tbaa !5
  %115 = getelementptr inbounds %struct.ocb128_context, ptr %114, i32 0, i32 10
  %116 = getelementptr inbounds %struct.anon, ptr %115, i32 0, i32 4
  %117 = getelementptr inbounds [16 x i8], ptr %116, i64 0, i64 15
  %118 = load i8, ptr %117, align 1, !tbaa !11
  %119 = zext i8 %118 to i32
  %120 = or i32 %119, %113
  %121 = trunc i32 %120 to i8
  store i8 %121, ptr %117, align 1, !tbaa !11
  store i32 1, ptr %5, align 4
  store i32 1, ptr %17, align 4
  br label %122

122:                                              ; preds = %30, %29
  call void @llvm.lifetime.end.p0(i64 8, ptr %16) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 1, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  %123 = load i32, ptr %5, align 4
  ret i32 %123
}

; Function Attrs: nounwind uwtable
declare hidden void @ocb_block_xor(ptr noundef, ptr noundef, i64 noundef, ptr noundef) #3

; Function Attrs: nounwind uwtable
declare hidden void @ocb_block_lshift(ptr noundef, i64 noundef, ptr noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #2 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { 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 = !{!"long", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = !{!13, !6, i64 0}
!13 = !{!"ocb128_context", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !10, i64 40, !10, i64 48, !7, i64 56, !7, i64 72, !6, i64 88, !14, i64 96}
!14 = !{!"", !15, i64 0, !15, i64 8, !7, i64 16, !7, i64 32, !7, i64 48, !7, i64 64}
!15 = !{!"long long", !7, i64 0}
!16 = !{!13, !6, i64 16}


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

; 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: mustprogress nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #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) #2

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 2) i32 @CRYPTO_ocb128_setiv(ptr noundef %0, ptr nocapture noundef readonly %1, i64 noundef %2, i64 noundef %3) local_unnamed_addr #3 {
  %5 = alloca [16 x i8], align 16
  %6 = alloca [16 x i8], align 16
  %7 = alloca [24 x i8], align 16
  %8 = alloca [16 x i8], align 16
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %7) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %8) #4
  %9 = add i64 %2, -16
  %or.cond = icmp ult i64 %9, -15
  %10 = add i64 %3, -17
  %11 = icmp ult i64 %10, -16
  %or.cond5 = or i1 %or.cond, %11
  br i1 %or.cond5, label %49, label %12

12:                                               ; preds = %4
  %13 = getelementptr inbounds i8, ptr %0, i64 96
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(80) %13, i8 0, i64 80, i1 false)
  %.tr = trunc nuw i64 %3 to i8
  %14 = shl i8 %.tr, 4
  store i8 %14, ptr %8, align 16, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %8, i64 1
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(15) %15, i8 0, i64 15, i1 false)
  %16 = getelementptr inbounds i8, ptr %8, i64 16
  %17 = sub nsw i64 0, %2
  %18 = getelementptr inbounds i8, ptr %16, i64 %17
  call void @llvm.memcpy.p0.p0.i64(ptr nonnull align 1 %18, ptr align 1 %1, i64 %2, i1 false)
  %19 = sub nuw nsw i64 15, %2
  %20 = getelementptr inbounds [16 x i8], ptr %8, i64 0, i64 %19
  %21 = load i8, ptr %20, align 1, !tbaa !5
  %22 = or i8 %21, 1
  store i8 %22, ptr %20, align 1, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %6, ptr noundef nonnull align 16 dereferenceable(16) %8, i64 16, i1 false)
  %23 = getelementptr inbounds i8, ptr %6, i64 15
  %24 = load i8, ptr %23, align 1, !tbaa !5
  %25 = and i8 %24, -64
  store i8 %25, ptr %23, align 1, !tbaa !5
  %26 = load ptr, ptr %0, align 8, !tbaa !8
  %27 = getelementptr inbounds i8, ptr %0, i64 16
  %28 = load ptr, ptr %27, align 8, !tbaa !14
  call void %26(ptr noundef nonnull %6, ptr noundef nonnull %5, ptr noundef %28) #4
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(16) %7, ptr noundef nonnull align 16 dereferenceable(16) %5, i64 16, i1 false)
  %29 = getelementptr inbounds i8, ptr %5, i64 1
  %30 = getelementptr inbounds i8, ptr %7, i64 16
  call void @ocb_block_xor(ptr noundef nonnull %5, ptr noundef nonnull %29, i64 noundef 8, ptr noundef nonnull %30)
  %31 = getelementptr inbounds i8, ptr %8, i64 15
  %32 = load i8, ptr %31, align 1, !tbaa !5
  %33 = and i8 %32, 63
  %34 = zext nneg i8 %33 to i64
  %35 = and i64 %34, 7
  %36 = lshr i64 %34, 3
  %37 = getelementptr inbounds i8, ptr %7, i64 %36
  %38 = getelementptr inbounds i8, ptr %0, i64 144
  call void @ocb_block_lshift(ptr noundef nonnull %37, i64 noundef %35, ptr noundef nonnull %38)
  %39 = trunc nuw nsw i64 %35 to i16
  %40 = sub nuw nsw i16 8, %39
  %41 = getelementptr inbounds i8, ptr %37, i64 16
  %42 = load i8, ptr %41, align 1, !tbaa !5
  %43 = zext i8 %42 to i16
  %44 = lshr i16 %43, %40
  %45 = getelementptr inbounds i8, ptr %0, i64 159
  %46 = load i8, ptr %45, align 1, !tbaa !5
  %47 = trunc nuw nsw i16 %44 to i8
  %48 = or i8 %46, %47
  store i8 %48, ptr %45, align 1, !tbaa !5
  br label %49

49:                                               ; preds = %4, %12
  %.0 = phi i32 [ 1, %12 ], [ -1, %4 ]
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %8) #4
  call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %7) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %6) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %5) #4
  ret i32 %.0
}

; Function Attrs: nounwind uwtable
declare hidden void @ocb_block_xor(ptr noundef, ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden void @ocb_block_lshift(ptr noundef, i64 noundef, ptr noundef) local_unnamed_addr #3

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


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