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

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

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@_ZL4opts = external hidden global [2 x %struct.option_t], align 16
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr noundef %1) #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca ptr, align 8
  %6 = alloca i32, align 4
  %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
  store i32 0, ptr %3, align 4
  store i32 %0, ptr %4, align 4, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  store ptr null, ptr %8, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %12 = load i32, ptr %4, align 4, !tbaa !5
  %13 = load ptr, ptr %5, align 8, !tbaa !9
  call void @getopts_init(i32 noundef %12, ptr noundef %13, ptr noundef @.str)
  br label %14

14:                                               ; preds = %33, %2
  %15 = call i32 @getopts(ptr noundef @_ZL4opts, ptr noundef %7)
  store i32 %15, ptr %6, align 4, !tbaa !5
  %16 = icmp ne i32 %15, 0
  br i1 %16, label %17, label %34

17:                                               ; preds = %14
  %18 = load i32, ptr %6, align 4, !tbaa !5
  switch i32 %18, label %30 [
    i32 -5, label %19
    i32 1, label %26
  ]

19:                                               ; preds = %17
  %20 = load ptr, ptr %8, align 8, !tbaa !9
  %21 = icmp ne ptr %20, null
  br i1 %21, label %22, label %24

22:                                               ; preds = %19
  %23 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %74

24:                                               ; preds = %19
  %25 = load ptr, ptr %7, align 8, !tbaa !9
  store ptr %25, ptr %8, align 8, !tbaa !9
  br label %33

26:                                               ; preds = %17
  call void @print_banner(ptr noundef @.str)
  %27 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  %28 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %74

30:                                               ; preds = %17
  %31 = load ptr, ptr %7, align 8, !tbaa !9
  %32 = call i32 (ptr, ...) @printf(ptr noundef @.str.5, ptr noundef %31)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %74

33:                                               ; preds = %24
  br label %14, !llvm.loop !11

34:                                               ; preds = %14
  %35 = load ptr, ptr %8, align 8, !tbaa !9
  %36 = icmp ne ptr %35, null
  br i1 %36, label %39, label %37

37:                                               ; preds = %34
  %38 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %74

39:                                               ; preds = %34
  %40 = load ptr, ptr %8, align 8, !tbaa !9
  %41 = call i32 @ups_env_open(ptr noundef %10, ptr noundef %40, i32 noundef 131072, ptr noundef null)
  store i32 %41, ptr %9, align 4, !tbaa !5
  %42 = load i32, ptr %9, align 4, !tbaa !5
  %43 = icmp eq i32 %42, -21
  br i1 %43, label %44, label %47

44:                                               ; preds = %39
  %45 = load ptr, ptr %8, align 8, !tbaa !9
  %46 = call i32 (ptr, ...) @printf(ptr noundef @.str.7, ptr noundef %45)
  store i32 -1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %74

47:                                               ; preds = %39
  %48 = load i32, ptr %9, align 4, !tbaa !5
  %49 = icmp eq i32 %48, 0
  br i1 %49, label %50, label %53

50:                                               ; preds = %47
  %51 = load ptr, ptr %8, align 8, !tbaa !9
  %52 = call i32 (ptr, ...) @printf(ptr noundef @.str.8, ptr noundef %51)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %74

53:                                               ; preds = %47
  %54 = load i32, ptr %9, align 4, !tbaa !5
  %55 = icmp ne i32 %54, -28
  br i1 %55, label %56, label %58

56:                                               ; preds = %53
  %57 = load i32, ptr %9, align 4, !tbaa !5
  call void @_ZL5errorPKci(ptr noundef @.str.9, i32 noundef %57)
  br label %58

58:                                               ; preds = %56, %53
  br label %59

59:                                               ; preds = %58
  %60 = load ptr, ptr %8, align 8, !tbaa !9
  %61 = call i32 @ups_env_open(ptr noundef %10, ptr noundef %60, i32 noundef 196608, ptr noundef null)
  store i32 %61, ptr %9, align 4, !tbaa !5
  %62 = load i32, ptr %9, align 4, !tbaa !5
  %63 = icmp ne i32 %62, 0
  br i1 %63, label %64, label %66

64:                                               ; preds = %59
  %65 = load i32, ptr %9, align 4, !tbaa !5
  call void @_ZL5errorPKci(ptr noundef @.str.9, i32 noundef %65)
  br label %66

66:                                               ; preds = %64, %59
  %67 = load ptr, ptr %10, align 8, !tbaa !9
  %68 = call i32 @ups_env_close(ptr noundef %67, i32 noundef 0)
  store i32 %68, ptr %9, align 4, !tbaa !5
  %69 = load i32, ptr %9, align 4, !tbaa !5
  %70 = icmp ne i32 %69, 0
  br i1 %70, label %71, label %73

71:                                               ; preds = %66
  %72 = load i32, ptr %9, align 4, !tbaa !5
  call void @_ZL5errorPKci(ptr noundef @.str.10, i32 noundef %72)
  br label %73

73:                                               ; preds = %71, %66
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %74

74:                                               ; preds = %73, %50, %44, %37, %30, %26, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #4
  %75 = load i32, ptr %3, align 4
  ret i32 %75
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare void @getopts_init(i32 noundef, ptr noundef, ptr noundef) #2

declare i32 @getopts(ptr noundef, ptr noundef) #2

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

declare void @print_banner(ptr noundef) #2

declare i32 @ups_env_open(ptr noundef, ptr noundef, i32 noundef, ptr noundef) #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL5errorPKci(ptr noundef, i32 noundef) #3

declare i32 @ups_env_close(ptr noundef, i32 noundef) #2

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { mustprogress norecurse 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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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"

%struct.option_t = type { i32, ptr, ptr, ptr, i32 }

@.str = external hidden unnamed_addr constant [12 x i8], align 1
@_ZL4opts = external hidden global [2 x %struct.option_t], align 16
@.str.1 = external hidden unnamed_addr constant [61 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [23 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [47 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [70 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [60 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [42 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [14 x i8], align 1

; Function Attrs: mustprogress norecurse uwtable
define dso_local noundef range(i32 -1, 1) i32 @main(i32 noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #5
  tail call void @getopts_init(i32 noundef %0, ptr noundef %1, ptr noundef nonnull @.str)
  br label %5

5:                                                ; preds = %10, %2
  %.0 = phi ptr [ null, %2 ], [ %11, %10 ]
  %6 = call i32 @getopts(ptr noundef nonnull @_ZL4opts, ptr noundef nonnull %3)
  switch i32 %6, label %16 [
    i32 0, label %19
    i32 -5, label %7
    i32 1, label %12
  ]

7:                                                ; preds = %5
  %.not26 = icmp eq ptr %.0, null
  br i1 %.not26, label %10, label %8

8:                                                ; preds = %7
  %9 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  br label %36

10:                                               ; preds = %7
  %11 = load ptr, ptr %3, align 8, !tbaa !5
  br label %5, !llvm.loop !9

12:                                               ; preds = %5
  call void @print_banner(ptr noundef nonnull @.str)
  %13 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  %14 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  %15 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %36

16:                                               ; preds = %5
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5, ptr noundef %17)
  br label %36

19:                                               ; preds = %5
  %.not22 = icmp eq ptr %.0, null
  br i1 %.not22, label %20, label %22

20:                                               ; preds = %19
  %21 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  br label %36

22:                                               ; preds = %19
  %23 = call i32 @ups_env_open(ptr noundef nonnull %4, ptr noundef nonnull %.0, i32 noundef 131072, ptr noundef null)
  switch i32 %23, label %28 [
    i32 -21, label %24
    i32 0, label %26
    i32 -28, label %29
  ]

24:                                               ; preds = %22
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.7, ptr noundef nonnull %.0)
  br label %36

26:                                               ; preds = %22
  %27 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.8, ptr noundef nonnull %.0)
  br label %36

28:                                               ; preds = %22
  call void @_ZL5errorPKci(ptr noundef nonnull @.str.9, i32 noundef %23)
  br label %29

29:                                               ; preds = %22, %28
  %30 = call i32 @ups_env_open(ptr noundef nonnull %4, ptr noundef nonnull %.0, i32 noundef 196608, ptr noundef null)
  %.not24 = icmp eq i32 %30, 0
  br i1 %.not24, label %32, label %31

31:                                               ; preds = %29
  call void @_ZL5errorPKci(ptr noundef nonnull @.str.9, i32 noundef %30)
  br label %32

32:                                               ; preds = %31, %29
  %33 = load ptr, ptr %4, align 8, !tbaa !5
  %34 = call i32 @ups_env_close(ptr noundef %33, i32 noundef 0)
  %.not25 = icmp eq i32 %34, 0
  br i1 %.not25, label %36, label %35

35:                                               ; preds = %32
  call void @_ZL5errorPKci(ptr noundef nonnull @.str.10, i32 noundef %34)
  br label %36

36:                                               ; preds = %32, %35, %26, %24, %20, %16, %12, %8
  %.017 = phi i32 [ -1, %16 ], [ 0, %12 ], [ -1, %8 ], [ -1, %24 ], [ 0, %26 ], [ -1, %20 ], [ 0, %35 ], [ 0, %32 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #5
  ret i32 %.017
}

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

declare void @getopts_init(i32 noundef, ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @getopts(ptr noundef, ptr noundef) local_unnamed_addr #2

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

declare void @print_banner(ptr noundef) local_unnamed_addr #2

declare i32 @ups_env_open(ptr noundef, ptr noundef, i32 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: mustprogress uwtable
declare hidden void @_ZL5errorPKci(ptr noundef, i32 noundef) local_unnamed_addr #4

declare i32 @ups_env_close(ptr noundef, i32 noundef) local_unnamed_addr #2

; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

attributes #0 = { mustprogress norecurse 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { 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 #4 = { 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 #5 = { 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 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass