; LLVM IR from mkobos/lbfgsb_wrapper :: raw_wrapper (test_prog)

; 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.lbfgsb = type { i32, i32, ptr, ptr, ptr, ptr, double, ptr, double, double, ptr, ptr, [61 x i8], i32, [60 x i8], [4 x i32], [44 x i32], [29 x double] }

@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local double @fun(double noundef) #0

; Function Attrs: nounwind uwtable
declare dso_local double @df(double noundef) #0

; Function Attrs: nounwind uwtable
define dso_local 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 ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = 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 8, ptr %6) #3
  %11 = call ptr @lbfgsb_create(i32 noundef 1, i32 noundef 5)
  store ptr %11, ptr %6, align 8, !tbaa !9
  %12 = load ptr, ptr %6, align 8, !tbaa !9
  %13 = getelementptr inbounds %struct.lbfgsb, ptr %12, i32 0, i32 13
  store i32 1, ptr %13, align 8, !tbaa !11
  %14 = load ptr, ptr %6, align 8, !tbaa !9
  %15 = getelementptr inbounds %struct.lbfgsb, ptr %14, i32 0, i32 2
  %16 = load ptr, ptr %15, align 8, !tbaa !14
  %17 = getelementptr inbounds double, ptr %16, i64 0
  store double 4.000000e+01, ptr %17, align 8, !tbaa !15
  %18 = load ptr, ptr %6, align 8, !tbaa !9
  %19 = getelementptr inbounds %struct.lbfgsb, ptr %18, i32 0, i32 3
  %20 = load ptr, ptr %19, align 8, !tbaa !16
  %21 = getelementptr inbounds double, ptr %20, i64 0
  store double -1.000000e+02, ptr %21, align 8, !tbaa !15
  %22 = load ptr, ptr %6, align 8, !tbaa !9
  %23 = getelementptr inbounds %struct.lbfgsb, ptr %22, i32 0, i32 4
  %24 = load ptr, ptr %23, align 8, !tbaa !17
  %25 = getelementptr inbounds double, ptr %24, i64 0
  store double 1.000000e+02, ptr %25, align 8, !tbaa !15
  %26 = load ptr, ptr %6, align 8, !tbaa !9
  %27 = getelementptr inbounds %struct.lbfgsb, ptr %26, i32 0, i32 5
  %28 = load ptr, ptr %27, align 8, !tbaa !18
  %29 = getelementptr inbounds i32, ptr %28, i64 0
  store i32 2, ptr %29, align 4, !tbaa !5
  %30 = load ptr, ptr %6, align 8, !tbaa !9
  call void @lbfgsb_set_task(ptr noundef %30, i32 noundef 5)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  store i32 0, ptr %7, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  store i32 100, ptr %8, align 4, !tbaa !5
  br label %31

31:                                               ; preds = %101, %2
  br label %32

32:                                               ; preds = %31
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = load i32, ptr %8, align 4, !tbaa !5
  %35 = icmp eq i32 %33, %34
  br i1 %35, label %36, label %39

36:                                               ; preds = %32
  %37 = load ptr, ptr %6, align 8, !tbaa !9
  call void @lbfgsb_set_task(ptr noundef %37, i32 noundef 6)
  %38 = load ptr, ptr %6, align 8, !tbaa !9
  call void @lbfgsb_step(ptr noundef %38)
  br label %102

39:                                               ; preds = %32
  %40 = load ptr, ptr %6, align 8, !tbaa !9
  call void @lbfgsb_step(ptr noundef %40)
  %41 = load i32, ptr %7, align 4, !tbaa !5
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = getelementptr inbounds %struct.lbfgsb, ptr %42, i32 0, i32 2
  %44 = load ptr, ptr %43, align 8, !tbaa !14
  %45 = getelementptr inbounds double, ptr %44, i64 0
  %46 = load double, ptr %45, align 8, !tbaa !15
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %41, double noundef %46)
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #3
  %48 = load ptr, ptr %6, align 8, !tbaa !9
  %49 = call i32 @lbfgsb_get_task(ptr noundef %48)
  store i32 %49, ptr %9, align 4, !tbaa !5
  %50 = load i32, ptr %9, align 4, !tbaa !5
  %51 = icmp eq i32 %50, 0
  br i1 %51, label %52, label %72

52:                                               ; preds = %39
  %53 = call i32 (ptr, ...) @printf(ptr noundef @.str.1)
  %54 = load ptr, ptr %6, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.lbfgsb, ptr %54, i32 0, i32 2
  %56 = load ptr, ptr %55, align 8, !tbaa !14
  %57 = getelementptr inbounds double, ptr %56, i64 0
  %58 = load double, ptr %57, align 8, !tbaa !15
  %59 = call double @fun(double noundef %58)
  %60 = load ptr, ptr %6, align 8, !tbaa !9
  %61 = getelementptr inbounds %struct.lbfgsb, ptr %60, i32 0, i32 6
  store double %59, ptr %61, align 8, !tbaa !19
  %62 = load ptr, ptr %6, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.lbfgsb, ptr %62, i32 0, i32 2
  %64 = load ptr, ptr %63, align 8, !tbaa !14
  %65 = getelementptr inbounds double, ptr %64, i64 0
  %66 = load double, ptr %65, align 8, !tbaa !15
  %67 = call double @df(double noundef %66)
  %68 = load ptr, ptr %6, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct.lbfgsb, ptr %68, i32 0, i32 7
  %70 = load ptr, ptr %69, align 8, !tbaa !20
  %71 = getelementptr inbounds double, ptr %70, i64 0
  store double %67, ptr %71, align 8, !tbaa !15
  br label %96

72:                                               ; preds = %39
  %73 = load i32, ptr %9, align 4, !tbaa !5
  %74 = icmp eq i32 %73, 1
  br i1 %74, label %75, label %77

75:                                               ; preds = %72
  %76 = call i32 (ptr, ...) @printf(ptr noundef @.str.2)
  br label %95

77:                                               ; preds = %72
  %78 = load i32, ptr %9, align 4, !tbaa !5
  %79 = icmp eq i32 %78, 2
  br i1 %79, label %80, label %82

80:                                               ; preds = %77
  %81 = call i32 (ptr, ...) @printf(ptr noundef @.str.3)
  store i32 3, ptr %10, align 4
  br label %99

82:                                               ; preds = %77
  %83 = load i32, ptr %9, align 4, !tbaa !5
  %84 = icmp eq i32 %83, 3
  br i1 %84, label %85, label %87

85:                                               ; preds = %82
  %86 = call i32 (ptr, ...) @printf(ptr noundef @.str.4)
  store i32 3, ptr %10, align 4
  br label %99

87:                                               ; preds = %82
  %88 = load i32, ptr %9, align 4, !tbaa !5
  %89 = icmp eq i32 %88, 4
  br i1 %89, label %90, label %92

90:                                               ; preds = %87
  %91 = call i32 (ptr, ...) @printf(ptr noundef @.str.5)
  store i32 3, ptr %10, align 4
  br label %99

92:                                               ; preds = %87
  br label %93

93:                                               ; preds = %92
  br label %94

94:                                               ; preds = %93
  br label %95

95:                                               ; preds = %94, %75
  br label %96

96:                                               ; preds = %95, %52
  %97 = load i32, ptr %7, align 4, !tbaa !5
  %98 = add nsw i32 %97, 1
  store i32 %98, ptr %7, align 4, !tbaa !5
  store i32 0, ptr %10, align 4
  br label %99

99:                                               ; preds = %96, %90, %85, %80
  call void @llvm.lifetime.end.p0(i64 4, ptr %9) #3
  %100 = load i32, ptr %10, align 4
  switch i32 %100, label %106 [
    i32 0, label %101
    i32 3, label %102
  ]

101:                                              ; preds = %99
  br label %31

102:                                              ; preds = %99, %36
  %103 = call i32 (ptr, ...) @printf(ptr noundef @.str.6)
  %104 = load ptr, ptr %6, align 8, !tbaa !9
  call void @lbfgsb_delete(ptr noundef %104)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %10, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %105 = load i32, ptr %3, align 4
  ret i32 %105

106:                                              ; preds = %99
  unreachable
}

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

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

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

declare void @lbfgsb_step(ptr noundef) #2

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

declare i32 @lbfgsb_get_task(ptr noundef) #2

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

declare void @lbfgsb_delete(ptr noundef) #2

attributes #0 = { 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 = { 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 = { 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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 152}
!12 = !{!"lbfgsb", !6, i64 0, !6, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !13, i64 40, !10, i64 48, !13, i64 56, !13, i64 64, !10, i64 72, !10, i64 80, !7, i64 88, !6, i64 152, !7, i64 156, !7, i64 216, !7, i64 232, !7, i64 408}
!13 = !{!"double", !7, i64 0}
!14 = !{!12, !10, i64 8}
!15 = !{!13, !13, i64 0}
!16 = !{!12, !10, i64 16}
!17 = !{!12, !10, i64 24}
!18 = !{!12, !10, i64 32}
!19 = !{!12, !13, i64 40}
!20 = !{!12, !10, i64 48}


; 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 [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [14 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [17 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [19 x i8], align 1

; Function Attrs: nounwind uwtable
declare dso_local double @fun(double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
declare dso_local double @df(double noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = tail call ptr @lbfgsb_create(i32 noundef 1, i32 noundef 5) #3
  %4 = getelementptr inbounds i8, ptr %3, i64 152
  store i32 1, ptr %4, align 8, !tbaa !5
  %5 = getelementptr inbounds i8, ptr %3, i64 8
  %6 = load ptr, ptr %5, align 8, !tbaa !12
  store double 4.000000e+01, ptr %6, align 8, !tbaa !13
  %7 = getelementptr inbounds i8, ptr %3, i64 16
  %8 = load ptr, ptr %7, align 8, !tbaa !14
  store double -1.000000e+02, ptr %8, align 8, !tbaa !13
  %9 = getelementptr inbounds i8, ptr %3, i64 24
  %10 = load ptr, ptr %9, align 8, !tbaa !15
  store double 1.000000e+02, ptr %10, align 8, !tbaa !13
  %11 = getelementptr inbounds i8, ptr %3, i64 32
  %12 = load ptr, ptr %11, align 8, !tbaa !16
  store i32 2, ptr %12, align 4, !tbaa !17
  tail call void @lbfgsb_set_task(ptr noundef %3, i32 noundef 5) #3
  %13 = getelementptr inbounds i8, ptr %3, i64 40
  %14 = getelementptr inbounds i8, ptr %3, i64 48
  br label %16

15:                                               ; preds = %38
  tail call void @lbfgsb_set_task(ptr noundef nonnull %3, i32 noundef 6) #3
  tail call void @lbfgsb_step(ptr noundef nonnull %3) #3
  br label %.thread

16:                                               ; preds = %2, %38
  %.02631 = phi i32 [ 0, %2 ], [ %39, %38 ]
  tail call void @lbfgsb_step(ptr noundef nonnull %3) #3
  %17 = load ptr, ptr %5, align 8, !tbaa !12
  %18 = load double, ptr %17, align 8, !tbaa !13
  %19 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %.02631, double noundef %18)
  %20 = tail call i32 @lbfgsb_get_task(ptr noundef nonnull %3) #3
  switch i32 %20, label %38 [
    i32 0, label %21
    i32 1, label %30
    i32 2, label %32
    i32 3, label %34
    i32 4, label %36
  ]

21:                                               ; preds = %16
  %22 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1)
  %23 = load ptr, ptr %5, align 8, !tbaa !12
  %24 = load double, ptr %23, align 8, !tbaa !13
  %25 = tail call double @fun(double noundef %24)
  store double %25, ptr %13, align 8, !tbaa !18
  %26 = load ptr, ptr %5, align 8, !tbaa !12
  %27 = load double, ptr %26, align 8, !tbaa !13
  %28 = tail call double @df(double noundef %27)
  %29 = load ptr, ptr %14, align 8, !tbaa !19
  store double %28, ptr %29, align 8, !tbaa !13
  br label %38

30:                                               ; preds = %16
  %31 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2)
  br label %38

32:                                               ; preds = %16
  %33 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.3)
  br label %.thread

34:                                               ; preds = %16
  %35 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.4)
  br label %.thread

36:                                               ; preds = %16
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.5)
  br label %.thread

38:                                               ; preds = %21, %30, %16
  %39 = add nuw nsw i32 %.02631, 1
  %40 = icmp eq i32 %39, 100
  br i1 %40, label %15, label %16

.thread:                                          ; preds = %36, %34, %32, %15
  %41 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.6)
  tail call void @lbfgsb_delete(ptr noundef nonnull %3) #3
  ret i32 0
}

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

declare void @lbfgsb_set_task(ptr noundef, i32 noundef) local_unnamed_addr #1

declare void @lbfgsb_step(ptr noundef) local_unnamed_addr #1

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

declare i32 @lbfgsb_get_task(ptr noundef) local_unnamed_addr #1

declare void @lbfgsb_delete(ptr noundef) local_unnamed_addr #1

attributes #0 = { 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 = { "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 = { 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 #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, !7, i64 152}
!6 = !{!"lbfgsb", !7, i64 0, !7, i64 4, !10, i64 8, !10, i64 16, !10, i64 24, !10, i64 32, !11, i64 40, !10, i64 48, !11, i64 56, !11, i64 64, !10, i64 72, !10, i64 80, !8, i64 88, !7, i64 152, !8, i64 156, !8, i64 216, !8, i64 232, !8, i64 408}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!"double", !8, i64 0}
!12 = !{!6, !10, i64 8}
!13 = !{!11, !11, i64 0}
!14 = !{!6, !10, i64 16}
!15 = !{!6, !10, i64 24}
!16 = !{!6, !10, i64 32}
!17 = !{!7, !7, i64 0}
!18 = !{!6, !11, i64 40}
!19 = !{!6, !10, i64 48}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass