; LLVM IR from wumo/vkg :: src/par/test (lz4)

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

; 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: alwaysinline nounwind uwtable
declare hidden i32 @LZ4_decompress_generic(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @LZ4_decompress_fast_continue(ptr noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) #2 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store ptr %2, ptr %8, align 8, !tbaa !5
  store i32 %3, ptr %9, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %13 = load ptr, ptr %6, align 8, !tbaa !5
  store ptr %13, ptr %10, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %14 = load ptr, ptr %10, align 8, !tbaa !5
  %15 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %14, i32 0, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !11
  %17 = load ptr, ptr %8, align 8, !tbaa !5
  %18 = icmp eq ptr %16, %17
  br i1 %18, label %19, label %55

19:                                               ; preds = %4
  %20 = load ptr, ptr %7, align 8, !tbaa !5
  %21 = load ptr, ptr %8, align 8, !tbaa !5
  %22 = load i32, ptr %9, align 4, !tbaa !9
  %23 = load ptr, ptr %10, align 8, !tbaa !5
  %24 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %23, i32 0, i32 2
  %25 = load ptr, ptr %24, align 8, !tbaa !11
  %26 = load ptr, ptr %10, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %26, i32 0, i32 3
  %28 = load i64, ptr %27, align 8, !tbaa !14
  %29 = sub i64 0, %28
  %30 = getelementptr inbounds i8, ptr %25, i64 %29
  %31 = load ptr, ptr %10, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !15
  %34 = load ptr, ptr %10, align 8, !tbaa !5
  %35 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %34, i32 0, i32 1
  %36 = load i64, ptr %35, align 8, !tbaa !16
  %37 = call i32 @LZ4_decompress_generic(ptr noundef %20, ptr noundef %21, i32 noundef 0, i32 noundef %22, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 2, ptr noundef %30, ptr noundef %33, i64 noundef %36)
  store i32 %37, ptr %11, align 4, !tbaa !9
  %38 = load i32, ptr %11, align 4, !tbaa !9
  %39 = icmp sle i32 %38, 0
  br i1 %39, label %40, label %42

40:                                               ; preds = %19
  %41 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %41, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %97

42:                                               ; preds = %19
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = sext i32 %43 to i64
  %45 = load ptr, ptr %10, align 8, !tbaa !5
  %46 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %45, i32 0, i32 3
  %47 = load i64, ptr %46, align 8, !tbaa !14
  %48 = add i64 %47, %44
  store i64 %48, ptr %46, align 8, !tbaa !14
  %49 = load i32, ptr %9, align 4, !tbaa !9
  %50 = load ptr, ptr %10, align 8, !tbaa !5
  %51 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %50, i32 0, i32 2
  %52 = load ptr, ptr %51, align 8, !tbaa !11
  %53 = sext i32 %49 to i64
  %54 = getelementptr inbounds i8, ptr %52, i64 %53
  store ptr %54, ptr %51, align 8, !tbaa !11
  br label %95

55:                                               ; preds = %4
  %56 = load ptr, ptr %10, align 8, !tbaa !5
  %57 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %56, i32 0, i32 3
  %58 = load i64, ptr %57, align 8, !tbaa !14
  %59 = load ptr, ptr %10, align 8, !tbaa !5
  %60 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %59, i32 0, i32 1
  store i64 %58, ptr %60, align 8, !tbaa !16
  %61 = load ptr, ptr %8, align 8, !tbaa !5
  %62 = load ptr, ptr %10, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %62, i32 0, i32 1
  %64 = load i64, ptr %63, align 8, !tbaa !16
  %65 = sub i64 0, %64
  %66 = getelementptr inbounds i8, ptr %61, i64 %65
  %67 = load ptr, ptr %10, align 8, !tbaa !5
  %68 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %67, i32 0, i32 0
  store ptr %66, ptr %68, align 8, !tbaa !15
  %69 = load ptr, ptr %7, align 8, !tbaa !5
  %70 = load ptr, ptr %8, align 8, !tbaa !5
  %71 = load i32, ptr %9, align 4, !tbaa !9
  %72 = load ptr, ptr %8, align 8, !tbaa !5
  %73 = load ptr, ptr %10, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %73, i32 0, i32 0
  %75 = load ptr, ptr %74, align 8, !tbaa !15
  %76 = load ptr, ptr %10, align 8, !tbaa !5
  %77 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %76, i32 0, i32 1
  %78 = load i64, ptr %77, align 8, !tbaa !16
  %79 = call i32 @LZ4_decompress_generic(ptr noundef %69, ptr noundef %70, i32 noundef 0, i32 noundef %71, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 2, ptr noundef %72, ptr noundef %75, i64 noundef %78)
  store i32 %79, ptr %11, align 4, !tbaa !9
  %80 = load i32, ptr %11, align 4, !tbaa !9
  %81 = icmp sle i32 %80, 0
  br i1 %81, label %82, label %84

82:                                               ; preds = %55
  %83 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %83, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %97

84:                                               ; preds = %55
  %85 = load i32, ptr %9, align 4, !tbaa !9
  %86 = sext i32 %85 to i64
  %87 = load ptr, ptr %10, align 8, !tbaa !5
  %88 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %87, i32 0, i32 3
  store i64 %86, ptr %88, align 8, !tbaa !14
  %89 = load ptr, ptr %8, align 8, !tbaa !5
  %90 = load i32, ptr %9, align 4, !tbaa !9
  %91 = sext i32 %90 to i64
  %92 = getelementptr inbounds i8, ptr %89, i64 %91
  %93 = load ptr, ptr %10, align 8, !tbaa !5
  %94 = getelementptr inbounds %struct.LZ4_streamDecode_t_internal, ptr %93, i32 0, i32 2
  store ptr %92, ptr %94, align 8, !tbaa !11
  br label %95

95:                                               ; preds = %84, %42
  %96 = load i32, ptr %11, align 4, !tbaa !9
  store i32 %96, ptr %5, align 4
  store i32 1, ptr %12, align 4
  br label %97

97:                                               ; preds = %95, %82, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  %98 = load i32, ptr %5, align 4
  ret i32 %98
}

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


; 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: alwaysinline nounwind uwtable
declare hidden i32 @LZ4_decompress_generic(ptr noundef, ptr noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, i32 noundef, ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local i32 @LZ4_decompress_fast_continue(ptr nocapture noundef %0, ptr noundef %1, ptr noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = icmp eq ptr %6, %2
  %8 = getelementptr inbounds i8, ptr %0, i64 24
  %9 = load i64, ptr %8, align 8, !tbaa !11
  br i1 %7, label %10, label %24

10:                                               ; preds = %4
  %11 = sub i64 0, %9
  %12 = getelementptr inbounds i8, ptr %6, i64 %11
  %13 = load ptr, ptr %0, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load i64, ptr %14, align 8, !tbaa !13
  %16 = tail call i32 @LZ4_decompress_generic(ptr noundef %1, ptr noundef %2, i32 noundef 0, i32 noundef %3, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 2, ptr noundef %12, ptr noundef %13, i64 noundef %15)
  %17 = icmp slt i32 %16, 1
  br i1 %17, label %34, label %18

18:                                               ; preds = %10
  %19 = sext i32 %3 to i64
  %20 = load i64, ptr %8, align 8, !tbaa !11
  %21 = add i64 %20, %19
  store i64 %21, ptr %8, align 8, !tbaa !11
  %22 = load ptr, ptr %5, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %22, i64 %19
  br label %33

24:                                               ; preds = %4
  %25 = getelementptr inbounds i8, ptr %0, i64 8
  store i64 %9, ptr %25, align 8, !tbaa !13
  %26 = sub i64 0, %9
  %27 = getelementptr inbounds i8, ptr %2, i64 %26
  store ptr %27, ptr %0, align 8, !tbaa !12
  %28 = tail call i32 @LZ4_decompress_generic(ptr noundef %1, ptr noundef %2, i32 noundef 0, i32 noundef %3, i32 noundef 0, i32 noundef 0, i32 noundef 0, i32 noundef 2, ptr noundef %2, ptr noundef %27, i64 noundef %9)
  %29 = icmp slt i32 %28, 1
  br i1 %29, label %34, label %30

30:                                               ; preds = %24
  %31 = sext i32 %3 to i64
  store i64 %31, ptr %8, align 8, !tbaa !11
  %32 = getelementptr inbounds i8, ptr %2, i64 %31
  br label %33

33:                                               ; preds = %30, %18
  %storemerge = phi ptr [ %32, %30 ], [ %23, %18 ]
  %.0 = phi i32 [ %28, %30 ], [ %16, %18 ]
  store ptr %storemerge, ptr %5, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %24, %10, %33
  %.035 = phi i32 [ %.0, %33 ], [ %16, %10 ], [ %28, %24 ]
  ret i32 %.035
}

attributes #0 = { alwaysinline 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 #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" }

!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 = !{!"", !7, i64 0, !10, i64 8, !7, i64 16, !10, i64 24}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"long", !8, i64 0}
!11 = !{!6, !10, i64 24}
!12 = !{!6, !7, i64 0}
!13 = !{!6, !10, i64 8}


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