; LLVM IR from UBIC-repo/core :: PassportReader/Reader/SessionKeys.ll (ZN11SessionKeys24incrementSequenceCounterEv)

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

%class.SessionKeys = type { [16 x i8], [8 x i8] }

; 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: mustprogress nounwind uwtable
define dso_local void @_ZN11SessionKeys24incrementSequenceCounterEv(ptr noundef nonnull align 1 dereferenceable(24) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i8, align 1
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %6 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %3) #2
  store i8 1, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 7, ptr %4, align 4, !tbaa !11
  br label %7

7:                                                ; preds = %43, %1
  %8 = load i32, ptr %4, align 4, !tbaa !11
  %9 = icmp sge i32 %8, 0
  br i1 %9, label %11, label %10

10:                                               ; preds = %7
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  br label %46

11:                                               ; preds = %7
  %12 = load i8, ptr %3, align 1, !tbaa !9, !range !13, !noundef !14
  %13 = trunc i8 %12 to i1
  br i1 %13, label %14, label %42

14:                                               ; preds = %11
  %15 = getelementptr inbounds %class.SessionKeys, ptr %6, i32 0, i32 1
  %16 = load i32, ptr %4, align 4, !tbaa !11
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [8 x i8], ptr %15, i64 0, i64 %17
  %19 = load i8, ptr %18, align 1, !tbaa !15
  %20 = sext i8 %19 to i32
  %21 = icmp eq i32 %20, -1
  br i1 %21, label %22, label %27

22:                                               ; preds = %14
  %23 = getelementptr inbounds %class.SessionKeys, ptr %6, i32 0, i32 1
  %24 = load i32, ptr %4, align 4, !tbaa !11
  %25 = sext i32 %24 to i64
  %26 = getelementptr inbounds [8 x i8], ptr %23, i64 0, i64 %25
  store i8 0, ptr %26, align 1, !tbaa !15
  br label %41

27:                                               ; preds = %14
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #2
  %28 = getelementptr inbounds %class.SessionKeys, ptr %6, i32 0, i32 1
  %29 = load i32, ptr %4, align 4, !tbaa !11
  %30 = sext i32 %29 to i64
  %31 = getelementptr inbounds [8 x i8], ptr %28, i64 0, i64 %30
  %32 = load i8, ptr %31, align 1, !tbaa !15
  %33 = sext i8 %32 to i32
  store i32 %33, ptr %5, align 4, !tbaa !11
  %34 = load i32, ptr %5, align 4, !tbaa !11
  %35 = add i32 %34, 1
  %36 = trunc i32 %35 to i8
  %37 = getelementptr inbounds %class.SessionKeys, ptr %6, i32 0, i32 1
  %38 = load i32, ptr %4, align 4, !tbaa !11
  %39 = sext i32 %38 to i64
  %40 = getelementptr inbounds [8 x i8], ptr %37, i64 0, i64 %39
  store i8 %36, ptr %40, align 1, !tbaa !15
  store i8 0, ptr %3, align 1, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #2
  br label %41

41:                                               ; preds = %27, %22
  br label %42

42:                                               ; preds = %41, %11
  br label %43

43:                                               ; preds = %42
  %44 = load i32, ptr %4, align 4, !tbaa !11
  %45 = add nsw i32 %44, -1
  store i32 %45, ptr %4, align 4, !tbaa !11
  br label %7, !llvm.loop !16

46:                                               ; preds = %10
  call void @llvm.lifetime.end.p0(i64 1, ptr %3) #2
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress 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 = { 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"bool", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{i8 0, i8 2}
!14 = !{}
!15 = !{!7, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"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"

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
define dso_local void @_ZN11SessionKeys24incrementSequenceCounterEv(ptr nocapture noundef nonnull align 1 dereferenceable(24) %0) local_unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 16
  %3 = getelementptr inbounds i8, ptr %0, i64 23
  %4 = load i8, ptr %3, align 1, !tbaa !5
  %5 = icmp eq i8 %4, -1
  br i1 %5, label %8, label %6

6:                                                ; preds = %1
  %7 = add nuw i8 %4, 1
  store i8 %7, ptr %3, align 1, !tbaa !5
  br label %.thread28

8:                                                ; preds = %1
  store i8 0, ptr %3, align 1, !tbaa !5
  %9 = getelementptr inbounds i8, ptr %0, i64 22
  %10 = load i8, ptr %9, align 1, !tbaa !5
  %11 = icmp eq i8 %10, -1
  br i1 %11, label %14, label %12

12:                                               ; preds = %8
  %13 = add nuw i8 %10, 1
  store i8 %13, ptr %9, align 1, !tbaa !5
  br label %.thread28

14:                                               ; preds = %8
  store i8 0, ptr %9, align 1, !tbaa !5
  %15 = getelementptr inbounds i8, ptr %0, i64 21
  %16 = load i8, ptr %15, align 1, !tbaa !5
  %17 = icmp eq i8 %16, -1
  br i1 %17, label %20, label %18

18:                                               ; preds = %14
  %19 = add nuw i8 %16, 1
  store i8 %19, ptr %15, align 1, !tbaa !5
  br label %.thread28

20:                                               ; preds = %14
  store i8 0, ptr %15, align 1, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %0, i64 20
  %22 = load i8, ptr %21, align 1, !tbaa !5
  %23 = icmp eq i8 %22, -1
  br i1 %23, label %26, label %24

24:                                               ; preds = %20
  %25 = add nuw i8 %22, 1
  store i8 %25, ptr %21, align 1, !tbaa !5
  br label %.thread28

26:                                               ; preds = %20
  store i8 0, ptr %21, align 1, !tbaa !5
  %27 = getelementptr inbounds i8, ptr %0, i64 19
  %28 = load i8, ptr %27, align 1, !tbaa !5
  %29 = icmp eq i8 %28, -1
  br i1 %29, label %32, label %30

30:                                               ; preds = %26
  %31 = add nuw i8 %28, 1
  store i8 %31, ptr %27, align 1, !tbaa !5
  br label %.thread28

32:                                               ; preds = %26
  store i8 0, ptr %27, align 1, !tbaa !5
  %33 = getelementptr inbounds i8, ptr %0, i64 18
  %34 = load i8, ptr %33, align 1, !tbaa !5
  %35 = icmp eq i8 %34, -1
  br i1 %35, label %38, label %36

36:                                               ; preds = %32
  %37 = add nuw i8 %34, 1
  store i8 %37, ptr %33, align 1, !tbaa !5
  br label %.thread28

38:                                               ; preds = %32
  store i8 0, ptr %33, align 1, !tbaa !5
  %39 = getelementptr inbounds i8, ptr %0, i64 17
  %40 = load i8, ptr %39, align 1, !tbaa !5
  %41 = icmp eq i8 %40, -1
  br i1 %41, label %44, label %42

42:                                               ; preds = %38
  %43 = add nuw i8 %40, 1
  store i8 %43, ptr %39, align 1, !tbaa !5
  br label %.thread28

44:                                               ; preds = %38
  store i8 0, ptr %39, align 1, !tbaa !5
  %45 = load i8, ptr %2, align 1, !tbaa !5
  %46 = icmp eq i8 %45, -1
  br i1 %46, label %49, label %47

47:                                               ; preds = %44
  %48 = add nuw i8 %45, 1
  store i8 %48, ptr %2, align 1, !tbaa !5
  br label %.thread28

49:                                               ; preds = %44
  store i8 0, ptr %2, align 1, !tbaa !5
  br label %.thread28

.thread28:                                        ; preds = %6, %12, %18, %24, %30, %36, %42, %49, %47
  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++ TBAA"}


; Effective O3 passes: AggressiveInstCombinePass,CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SCCPPass,SROAPass,SimplifyCFGPass