; LLVM IR from cruppstahl/upscaledb :: tools/ups_bench (upscaledb)

; 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.Database = type { ptr, i32, ptr }
%struct.Configuration = type <{ i8, [3 x i8], i32, i8, i8, i8, [5 x i8], %"class.std::__cxx11::basic_string", i8, [3 x i8], i32, i32, i32, i8, [3 x i8], i32, i64, i64, i64, i64, i32, i8, [3 x i8], i32, i32, i32, i32, i8, i8, [2 x i8], i32, i8, [3 x i8], i32, i8, i8, i8, i8, i8, [3 x i8], i32, i32, i32, i8, i8, i8, i8, i32, i32, %"class.std::__cxx11::basic_string", i32, i32, i32, i8, i8, [2 x i8], i32, i32, i32, i8, i8, i8, i8, i32, i8, i8, [2 x i8] }>
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }

@.str.22 = external hidden unnamed_addr constant [34 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

declare i32 @printf(ptr noundef, ...) #1

declare ptr @ups_strerror(i32 noundef) #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN15UpscaleDatabase16do_cursor_insertEPmP9ups_key_tP12ups_record_t(ptr noundef nonnull align 8 dereferenceable(712) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #2 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  store i32 0, ptr %9, align 4, !tbaa !9
  %12 = getelementptr inbounds %class.Database, ptr %11, i32 0, i32 2
  %13 = load ptr, ptr %12, align 8, !tbaa !11
  %14 = getelementptr inbounds %struct.Configuration, ptr %13, i32 0, i32 31
  %15 = load i8, ptr %14, align 8, !tbaa !13, !range !19, !noundef !20
  %16 = trunc i8 %15 to i1
  br i1 %16, label %17, label %20

17:                                               ; preds = %4
  %18 = load i32, ptr %9, align 4, !tbaa !9
  %19 = or i32 %18, 1
  store i32 %19, ptr %9, align 4, !tbaa !9
  br label %20

20:                                               ; preds = %17, %4
  %21 = getelementptr inbounds %class.Database, ptr %11, i32 0, i32 2
  %22 = load ptr, ptr %21, align 8, !tbaa !11
  %23 = getelementptr inbounds %struct.Configuration, ptr %22, i32 0, i32 30
  %24 = load i32, ptr %23, align 4, !tbaa !21
  %25 = icmp eq i32 %24, 1
  br i1 %25, label %26, label %29

26:                                               ; preds = %20
  %27 = load i32, ptr %9, align 4, !tbaa !9
  %28 = or i32 %27, 18
  store i32 %28, ptr %9, align 4, !tbaa !9
  br label %39

29:                                               ; preds = %20
  %30 = getelementptr inbounds %class.Database, ptr %11, i32 0, i32 2
  %31 = load ptr, ptr %30, align 8, !tbaa !11
  %32 = getelementptr inbounds %struct.Configuration, ptr %31, i32 0, i32 30
  %33 = load i32, ptr %32, align 4, !tbaa !21
  %34 = icmp eq i32 %33, 2
  br i1 %34, label %35, label %38

35:                                               ; preds = %29
  %36 = load i32, ptr %9, align 4, !tbaa !9
  %37 = or i32 %36, 34
  store i32 %37, ptr %9, align 4, !tbaa !9
  br label %38

38:                                               ; preds = %35, %29
  br label %39

39:                                               ; preds = %38, %26
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #3
  %40 = load ptr, ptr %6, align 8, !tbaa !5
  %41 = load ptr, ptr %7, align 8, !tbaa !5
  %42 = load ptr, ptr %8, align 8, !tbaa !5
  %43 = load i32, ptr %9, align 4, !tbaa !9
  %44 = call i32 @ups_cursor_insert(ptr noundef %40, ptr noundef %41, ptr noundef %42, i32 noundef %43)
  store i32 %44, ptr %10, align 4, !tbaa !9
  %45 = load i32, ptr %10, align 4, !tbaa !9
  %46 = icmp ne i32 %45, 0
  br i1 %46, label %47, label %60

47:                                               ; preds = %39
  br label %48

48:                                               ; preds = %47
  %49 = getelementptr inbounds %class.Database, ptr %11, i32 0, i32 2
  %50 = load ptr, ptr %49, align 8, !tbaa !11
  %51 = getelementptr inbounds %struct.Configuration, ptr %50, i32 0, i32 2
  %52 = load i32, ptr %51, align 4, !tbaa !22
  %53 = icmp ne i32 %52, 0
  br i1 %53, label %54, label %59

54:                                               ; preds = %48
  %55 = load i32, ptr %10, align 4, !tbaa !9
  %56 = load i32, ptr %10, align 4, !tbaa !9
  %57 = call ptr @ups_strerror(i32 noundef %56)
  %58 = call i32 (ptr, ...) @printf(ptr noundef @.str.22, i32 noundef %55, ptr noundef %57)
  br label %59

59:                                               ; preds = %54, %48
  br label %60

60:                                               ; preds = %59, %39
  %61 = load i32, ptr %10, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  ret i32 %61
}

declare i32 @ups_cursor_insert(ptr noundef, ptr noundef, ptr noundef, i32 noundef) #1

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { "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 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !6, i64 16}
!12 = !{!"_ZTS8Database", !10, i64 8, !6, i64 16}
!13 = !{!14, !15, i64 136}
!14 = !{!"_ZTS13Configuration", !15, i64 0, !10, i64 4, !15, i64 8, !15, i64 9, !15, i64 10, !16, i64 16, !15, i64 48, !10, i64 52, !10, i64 56, !10, i64 60, !15, i64 64, !10, i64 68, !18, i64 72, !18, i64 80, !18, i64 88, !18, i64 96, !10, i64 104, !15, i64 108, !10, i64 112, !10, i64 116, !10, i64 120, !10, i64 124, !15, i64 128, !15, i64 129, !10, i64 132, !15, i64 136, !10, i64 140, !15, i64 144, !15, i64 145, !15, i64 146, !15, i64 147, !15, i64 148, !10, i64 152, !10, i64 156, !10, i64 160, !15, i64 164, !15, i64 165, !15, i64 166, !10, i64 168, !10, i64 172, !16, i64 176, !10, i64 208, !10, i64 212, !10, i64 216, !15, i64 220, !15, i64 221, !10, i64 224, !10, i64 228, !10, i64 232, !15, i64 236, !15, i64 237, !15, i64 238, !15, i64 239, !10, i64 240, !15, i64 244, !15, i64 245}
!15 = !{!"bool", !7, i64 0}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !18, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!"long", !7, i64 0}
!19 = !{i8 0, i8 2}
!20 = !{}
!21 = !{!14, !10, i64 132}
!22 = !{!14, !10, 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.22 = external hidden unnamed_addr constant [34 x i8], align 1

; Function Attrs: nofree nounwind
declare noundef i32 @printf(ptr nocapture noundef readonly, ...) local_unnamed_addr #0

declare ptr @ups_strerror(i32 noundef) local_unnamed_addr #1

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_ZN15UpscaleDatabase16do_cursor_insertEPmP9ups_key_tP12ups_record_t(ptr nocapture noundef nonnull readonly align 8 dereferenceable(712) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #2 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %7 = getelementptr inbounds i8, ptr %6, i64 136
  %8 = load i8, ptr %7, align 8, !tbaa !11, !range !17, !noundef !18
  %spec.select = zext nneg i8 %8 to i32
  %9 = getelementptr inbounds i8, ptr %6, i64 132
  %10 = load i32, ptr %9, align 4, !tbaa !19
  switch i32 %10, label %15 [
    i32 1, label %11
    i32 2, label %13
  ]

11:                                               ; preds = %4
  %12 = or disjoint i32 %spec.select, 18
  br label %15

13:                                               ; preds = %4
  %14 = or disjoint i32 %spec.select, 34
  br label %15

15:                                               ; preds = %4, %13, %11
  %.1 = phi i32 [ %12, %11 ], [ %14, %13 ], [ %spec.select, %4 ]
  %16 = tail call i32 @ups_cursor_insert(ptr noundef %1, ptr noundef %2, ptr noundef %3, i32 noundef %.1)
  %.not = icmp eq i32 %16, 0
  br i1 %.not, label %24, label %17

17:                                               ; preds = %15
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %18, i64 4
  %20 = load i32, ptr %19, align 4, !tbaa !20
  %.not13 = icmp eq i32 %20, 0
  br i1 %.not13, label %24, label %21

21:                                               ; preds = %17
  %22 = tail call ptr @ups_strerror(i32 noundef %16)
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.22, i32 noundef %16, ptr noundef %22)
  br label %24

24:                                               ; preds = %17, %21, %15
  ret i32 %16
}

declare i32 @ups_cursor_insert(ptr noundef, ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

attributes #0 = { nofree 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 = { "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 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, !10, i64 16}
!6 = !{!"_ZTS8Database", !7, i64 8, !10, i64 16}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!12, !13, i64 136}
!12 = !{!"_ZTS13Configuration", !13, i64 0, !7, i64 4, !13, i64 8, !13, i64 9, !13, i64 10, !14, i64 16, !13, i64 48, !7, i64 52, !7, i64 56, !7, i64 60, !13, i64 64, !7, i64 68, !16, i64 72, !16, i64 80, !16, i64 88, !16, i64 96, !7, i64 104, !13, i64 108, !7, i64 112, !7, i64 116, !7, i64 120, !7, i64 124, !13, i64 128, !13, i64 129, !7, i64 132, !13, i64 136, !7, i64 140, !13, i64 144, !13, i64 145, !13, i64 146, !13, i64 147, !13, i64 148, !7, i64 152, !7, i64 156, !7, i64 160, !13, i64 164, !13, i64 165, !13, i64 166, !7, i64 168, !7, i64 172, !14, i64 176, !7, i64 208, !7, i64 212, !7, i64 216, !13, i64 220, !13, i64 221, !7, i64 224, !7, i64 228, !7, i64 232, !13, i64 236, !13, i64 237, !13, i64 238, !13, i64 239, !7, i64 240, !13, i64 244, !13, i64 245}
!13 = !{!"bool", !8, i64 0}
!14 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !15, i64 0, !16, i64 8, !8, i64 16}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !10, i64 0}
!16 = !{!"long", !8, i64 0}
!17 = !{i8 0, i8 2}
!18 = !{}
!19 = !{!12, !7, i64 132}
!20 = !{!12, !7, i64 4}


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