; LLVM IR from facebookresearch/StarSpace :: 3rdparty/gzip.ll (ZN5boost9iostreams6detail11gzip_footer7processEc)

; 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.boost::iostreams::detail::gzip_footer" = type { i32, i32, i32, i32 }

@.str = external hidden unnamed_addr constant [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__._ZN5boost9iostreams6detail11gzip_footer7processEc = external hidden unnamed_addr constant [58 x i8], align 1

; 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: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #1

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5boost9iostreams6detail11gzip_footer7processEc(ptr noundef nonnull align 4 dereferenceable(16) %0, i8 noundef signext %1) #2 align 2 {
  %3 = alloca ptr, align 8
  %4 = alloca i8, align 1
  %5 = alloca i8, align 1
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i8 %1, ptr %4, align 1, !tbaa !9
  %6 = load ptr, ptr %3, align 8
  call void @llvm.lifetime.start.p0(i64 1, ptr %5) #3
  %7 = load i8, ptr %4, align 1, !tbaa !9
  store i8 %7, ptr %5, align 1, !tbaa !9
  %8 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 2
  %9 = load i32, ptr %8, align 4, !tbaa !10
  %10 = icmp eq i32 %9, 1
  br i1 %10, label %11, label %32

11:                                               ; preds = %2
  %12 = load i8, ptr %5, align 1, !tbaa !9
  %13 = zext i8 %12 to i32
  %14 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 3
  %15 = load i32, ptr %14, align 4, !tbaa !13
  %16 = mul nsw i32 %15, 8
  %17 = shl i32 %13, %16
  %18 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 0
  %19 = load i32, ptr %18, align 4, !tbaa !14
  %20 = add i32 %19, %17
  store i32 %20, ptr %18, align 4, !tbaa !14
  %21 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 3
  %22 = load i32, ptr %21, align 4, !tbaa !13
  %23 = icmp eq i32 %22, 3
  br i1 %23, label %24, label %27

24:                                               ; preds = %11
  %25 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 2
  store i32 2, ptr %25, align 4, !tbaa !10
  %26 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 3
  store i32 0, ptr %26, align 4, !tbaa !13
  br label %31

27:                                               ; preds = %11
  %28 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 3
  %29 = load i32, ptr %28, align 4, !tbaa !13
  %30 = add nsw i32 %29, 1
  store i32 %30, ptr %28, align 4, !tbaa !13
  br label %31

31:                                               ; preds = %27, %24
  br label %59

32:                                               ; preds = %2
  %33 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 2
  %34 = load i32, ptr %33, align 4, !tbaa !10
  %35 = icmp eq i32 %34, 2
  br i1 %35, label %36, label %57

36:                                               ; preds = %32
  %37 = load i8, ptr %5, align 1, !tbaa !9
  %38 = zext i8 %37 to i32
  %39 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 3
  %40 = load i32, ptr %39, align 4, !tbaa !13
  %41 = mul nsw i32 %40, 8
  %42 = shl i32 %38, %41
  %43 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 1
  %44 = load i32, ptr %43, align 4, !tbaa !15
  %45 = add i32 %44, %42
  store i32 %45, ptr %43, align 4, !tbaa !15
  %46 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 3
  %47 = load i32, ptr %46, align 4, !tbaa !13
  %48 = icmp eq i32 %47, 3
  br i1 %48, label %49, label %52

49:                                               ; preds = %36
  %50 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 2
  store i32 3, ptr %50, align 4, !tbaa !10
  %51 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 3
  store i32 0, ptr %51, align 4, !tbaa !13
  br label %56

52:                                               ; preds = %36
  %53 = getelementptr inbounds %"class.boost::iostreams::detail::gzip_footer", ptr %6, i32 0, i32 3
  %54 = load i32, ptr %53, align 4, !tbaa !13
  %55 = add nsw i32 %54, 1
  store i32 %55, ptr %53, align 4, !tbaa !13
  br label %56

56:                                               ; preds = %52, %49
  br label %58

57:                                               ; preds = %32
  call void @__assert_fail(ptr noundef @.str, ptr noundef @.str.1, i32 noundef 162, ptr noundef @__PRETTY_FUNCTION__._ZN5boost9iostreams6detail11gzip_footer7processEc) #4
  unreachable

58:                                               ; preds = %56
  br label %59

59:                                               ; preds = %58, %31
  call void @llvm.lifetime.end.p0(i64 1, ptr %5) #3
  ret void
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn nounwind "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 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 }
attributes #4 = { noreturn 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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 8}
!11 = !{!"_ZTSN5boost9iostreams6detail11gzip_footerE", !12, i64 0, !12, i64 4, !12, i64 8, !12, i64 12}
!12 = !{!"int", !7, i64 0}
!13 = !{!11, !12, i64 12}
!14 = !{!11, !12, i64 0}
!15 = !{!11, !12, i64 4}


; 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 [2 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [78 x i8], align 1
@__PRETTY_FUNCTION__._ZN5boost9iostreams6detail11gzip_footer7processEc = external hidden unnamed_addr constant [58 x i8], align 1

; Function Attrs: noreturn nounwind
declare void @__assert_fail(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_ZN5boost9iostreams6detail11gzip_footer7processEc(ptr nocapture noundef nonnull align 4 dereferenceable(16) %0, i8 noundef signext %1) local_unnamed_addr #1 align 2 {
  %3 = getelementptr inbounds i8, ptr %0, i64 8
  %4 = load i32, ptr %3, align 4, !tbaa !5
  switch i32 %4, label %30 [
    i32 1, label %5
    i32 2, label %17
  ]

5:                                                ; preds = %2
  %6 = zext i8 %1 to i32
  %7 = getelementptr inbounds i8, ptr %0, i64 12
  %8 = load i32, ptr %7, align 4, !tbaa !10
  %9 = shl nsw i32 %8, 3
  %10 = shl i32 %6, %9
  %11 = load i32, ptr %0, align 4, !tbaa !11
  %12 = add i32 %10, %11
  store i32 %12, ptr %0, align 4, !tbaa !11
  %13 = icmp eq i32 %8, 3
  br i1 %13, label %14, label %15

14:                                               ; preds = %5
  store i32 2, ptr %3, align 4, !tbaa !5
  store i32 0, ptr %7, align 4, !tbaa !10
  br label %31

15:                                               ; preds = %5
  %16 = add nsw i32 %8, 1
  store i32 %16, ptr %7, align 4, !tbaa !10
  br label %31

17:                                               ; preds = %2
  %18 = zext i8 %1 to i32
  %19 = getelementptr inbounds i8, ptr %0, i64 12
  %20 = load i32, ptr %19, align 4, !tbaa !10
  %21 = shl nsw i32 %20, 3
  %22 = shl i32 %18, %21
  %23 = getelementptr inbounds i8, ptr %0, i64 4
  %24 = load i32, ptr %23, align 4, !tbaa !12
  %25 = add i32 %22, %24
  store i32 %25, ptr %23, align 4, !tbaa !12
  %26 = icmp eq i32 %20, 3
  br i1 %26, label %27, label %28

27:                                               ; preds = %17
  store i32 3, ptr %3, align 4, !tbaa !5
  store i32 0, ptr %19, align 4, !tbaa !10
  br label %31

28:                                               ; preds = %17
  %29 = add nsw i32 %20, 1
  store i32 %29, ptr %19, align 4, !tbaa !10
  br label %31

30:                                               ; preds = %2
  tail call void @__assert_fail(ptr noundef nonnull @.str, ptr noundef nonnull @.str.1, i32 noundef 162, ptr noundef nonnull @__PRETTY_FUNCTION__._ZN5boost9iostreams6detail11gzip_footer7processEc) #2
  unreachable

31:                                               ; preds = %28, %27, %14, %15
  ret void
}

attributes #0 = { noreturn nounwind "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 = { 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 = { noreturn 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 8}
!6 = !{!"_ZTSN5boost9iostreams6detail11gzip_footerE", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 12}
!11 = !{!6, !7, i64 0}
!12 = !{!6, !7, i64 4}


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