; LLVM IR from seppo0010/rlite :: src (rlite)

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

; 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: nounwind uwtable
declare dso_local i32 @rl_select(ptr noundef, i32 noundef) #1

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

23:                                               ; preds = %4
  br label %73

24:                                               ; preds = %4
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = load i32, ptr %8, align 4, !tbaa !11
  %27 = call i32 @rl_select(ptr noundef %25, i32 noundef %26)
  store i32 %27, ptr %9, align 4, !tbaa !11
  %28 = load i32, ptr %9, align 4, !tbaa !11
  %29 = icmp ne i32 0, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  br label %73

31:                                               ; preds = %24
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = load ptr, ptr %6, align 8, !tbaa !5
  %34 = load i64, ptr %7, align 8, !tbaa !9
  %35 = call i32 @rl_key_get(ptr noundef %32, ptr noundef %33, i64 noundef %34, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef null)
  store i32 %35, ptr %9, align 4, !tbaa !11
  %36 = load i32, ptr %9, align 4, !tbaa !11
  %37 = icmp ne i32 3, %36
  br i1 %37, label %38, label %39

38:                                               ; preds = %31
  br label %73

39:                                               ; preds = %31
  %40 = load ptr, ptr %5, align 8, !tbaa !5
  %41 = load i32, ptr %10, align 4, !tbaa !11
  %42 = call i32 @rl_select(ptr noundef %40, i32 noundef %41)
  store i32 %42, ptr %9, align 4, !tbaa !11
  %43 = load i32, ptr %9, align 4, !tbaa !11
  %44 = icmp ne i32 0, %43
  br i1 %44, label %45, label %46

45:                                               ; preds = %39
  br label %73

46:                                               ; preds = %39
  %47 = load ptr, ptr %5, align 8, !tbaa !5
  %48 = load ptr, ptr %6, align 8, !tbaa !5
  %49 = load i64, ptr %7, align 8, !tbaa !9
  %50 = call i32 @rl_key_delete(ptr noundef %47, ptr noundef %48, i64 noundef %49)
  store i32 %50, ptr %9, align 4, !tbaa !11
  %51 = load i32, ptr %9, align 4, !tbaa !11
  %52 = icmp ne i32 0, %51
  br i1 %52, label %53, label %54

53:                                               ; preds = %46
  br label %73

54:                                               ; preds = %46
  %55 = load ptr, ptr %5, align 8, !tbaa !5
  %56 = load i32, ptr %8, align 4, !tbaa !11
  %57 = call i32 @rl_select(ptr noundef %55, i32 noundef %56)
  store i32 %57, ptr %9, align 4, !tbaa !11
  %58 = load i32, ptr %9, align 4, !tbaa !11
  %59 = icmp ne i32 0, %58
  br i1 %59, label %60, label %61

60:                                               ; preds = %54
  br label %73

61:                                               ; preds = %54
  %62 = load ptr, ptr %5, align 8, !tbaa !5
  %63 = load ptr, ptr %6, align 8, !tbaa !5
  %64 = load i64, ptr %7, align 8, !tbaa !9
  %65 = load i8, ptr %11, align 1, !tbaa !15
  %66 = load i64, ptr %13, align 8, !tbaa !9
  %67 = load i64, ptr %12, align 8, !tbaa !16
  %68 = call i32 @rl_key_set(ptr noundef %62, ptr noundef %63, i64 noundef %64, i8 noundef zeroext %65, i64 noundef %66, i64 noundef %67, i64 noundef 0)
  store i32 %68, ptr %9, align 4, !tbaa !11
  %69 = load i32, ptr %9, align 4, !tbaa !11
  %70 = icmp ne i32 0, %69
  br i1 %70, label %71, label %72

71:                                               ; preds = %61
  br label %73

72:                                               ; preds = %61
  store i32 0, ptr %9, align 4, !tbaa !11
  br label %73

73:                                               ; preds = %72, %71, %60, %53, %45, %38, %30, %23
  %74 = load ptr, ptr %5, align 8, !tbaa !5
  %75 = load i32, ptr %10, align 4, !tbaa !11
  %76 = call i32 @rl_select(ptr noundef %74, i32 noundef %75)
  %77 = load i32, ptr %9, align 4, !tbaa !11
  call void @llvm.lifetime.end.p0(i64 8, ptr %13) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr %11) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 %77
}

declare i32 @rl_key_get(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) #2

declare i32 @rl_key_delete(ptr noundef, ptr noundef, i64 noundef) #2

declare i32 @rl_key_set(ptr noundef, ptr noundef, i64 noundef, i8 noundef zeroext, i64 noundef, i64 noundef, i64 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 = !{!"long", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!14, !12, i64 72}
!14 = !{!"rlite", !10, i64 0, !10, i64 8, !12, i64 16, !6, i64 24, !10, i64 32, !10, i64 40, !10, i64 48, !6, i64 56, !12, i64 64, !12, i64 68, !12, i64 72, !12, i64 76, !6, i64 80, !10, i64 88, !10, i64 96, !6, i64 104, !10, i64 112, !10, i64 120, !6, i64 128, !6, i64 136, !6, i64 144, !6, i64 152}
!15 = !{!7, !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"long long", !7, i64 0}


; 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: nounwind uwtable
declare dso_local i32 @rl_select(ptr noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local i32 @rl_move(ptr noundef %0, ptr noundef %1, i64 noundef %2, i32 noundef %3) local_unnamed_addr #1 {
  %5 = alloca i8, align 1
  %6 = alloca i64, align 8
  %7 = alloca i64, align 8
  %8 = getelementptr inbounds i8, ptr %0, i64 72
  %9 = load i32, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 1, ptr nonnull %5) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %7) #3
  %10 = call i32 @rl_key_get(ptr noundef %0, ptr noundef %1, i64 noundef %2, ptr noundef nonnull %5, ptr noundef null, ptr noundef nonnull %7, ptr noundef nonnull %6, ptr noundef null) #3
  %.not = icmp eq i32 %10, 2
  br i1 %.not, label %11, label %26

11:                                               ; preds = %4
  %12 = call i32 @rl_select(ptr noundef nonnull %0, i32 noundef %3)
  %.not34 = icmp eq i32 %12, 0
  br i1 %.not34, label %13, label %26

13:                                               ; preds = %11
  %14 = call i32 @rl_key_get(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %2, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef null, ptr noundef null) #3
  %.not35 = icmp eq i32 %14, 3
  br i1 %.not35, label %15, label %26

15:                                               ; preds = %13
  %16 = call i32 @rl_select(ptr noundef nonnull %0, i32 noundef %9)
  %.not36 = icmp eq i32 %16, 0
  br i1 %.not36, label %17, label %26

17:                                               ; preds = %15
  %18 = call i32 @rl_key_delete(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %2) #3
  %.not37 = icmp eq i32 %18, 0
  br i1 %.not37, label %19, label %26

19:                                               ; preds = %17
  %20 = call i32 @rl_select(ptr noundef nonnull %0, i32 noundef %3)
  %.not38 = icmp eq i32 %20, 0
  br i1 %.not38, label %21, label %26

21:                                               ; preds = %19
  %22 = load i8, ptr %5, align 1, !tbaa !12
  %23 = load i64, ptr %7, align 8, !tbaa !13
  %24 = load i64, ptr %6, align 8, !tbaa !14
  %25 = call i32 @rl_key_set(ptr noundef nonnull %0, ptr noundef %1, i64 noundef %2, i8 noundef zeroext %22, i64 noundef %23, i64 noundef %24, i64 noundef 0) #3
  br label %26

26:                                               ; preds = %21, %19, %17, %15, %13, %11, %4
  %.0 = phi i32 [ %10, %4 ], [ %12, %11 ], [ %14, %13 ], [ %16, %15 ], [ %18, %17 ], [ %20, %19 ], [ %25, %21 ]
  %27 = call i32 @rl_select(ptr noundef nonnull %0, i32 noundef %9)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %6) #3
  call void @llvm.lifetime.end.p0(i64 1, ptr nonnull %5) #3
  ret i32 %.0
}

declare i32 @rl_key_get(ptr noundef, ptr noundef, i64 noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @rl_key_delete(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #2

declare i32 @rl_key_set(ptr noundef, ptr noundef, i64 noundef, i8 noundef zeroext, i64 noundef, i64 noundef, i64 noundef) local_unnamed_addr #2

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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, !10, i64 72}
!6 = !{!"rlite", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !11, i64 56, !10, i64 64, !10, i64 68, !10, i64 72, !10, i64 76, !11, i64 80, !7, i64 88, !7, i64 96, !11, i64 104, !7, i64 112, !7, i64 120, !11, i64 128, !11, i64 136, !11, i64 144, !11, i64 152}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"any pointer", !8, i64 0}
!12 = !{!8, !8, i64 0}
!13 = !{!7, !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"long long", !8, i64 0}


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