; LLVM IR from clibs/clib :: src/common (clib-release-info)

; 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.debug_t = type { ptr, i32, i32, ptr }
%struct.http_get_response_t = type { ptr, i64, i64, i32 }

@debugger = external hidden global %struct.debug_t, align 8
@.str = external hidden unnamed_addr constant [18 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @clib_release_get_latest_tag() #0 {
  %1 = alloca ptr, align 8
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = call i32 @debug_init(ptr noundef @debugger, ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 8, ptr %1) #4
  %6 = call ptr @http_get(ptr noundef @.str.1)
  store ptr %6, ptr %1, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  store ptr null, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store ptr null, ptr %4, align 8, !tbaa !5
  %7 = load ptr, ptr %1, align 8, !tbaa !5
  %8 = getelementptr inbounds %struct.http_get_response_t, ptr %7, i32 0, i32 3
  %9 = load i32, ptr %8, align 8, !tbaa !9
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %0
  call void (ptr, ptr, ...) @debug(ptr noundef @debugger, ptr noundef @.str.2)
  br label %32

12:                                               ; preds = %0
  %13 = load ptr, ptr %1, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.http_get_response_t, ptr %13, i32 0, i32 0
  %15 = load ptr, ptr %14, align 8, !tbaa !13
  %16 = call ptr @json_parse_string(ptr noundef %15)
  store ptr %16, ptr %2, align 8, !tbaa !5
  %17 = icmp ne ptr %16, null
  br i1 %17, label %19, label %18

18:                                               ; preds = %12
  call void (ptr, ptr, ...) @debug(ptr noundef @debugger, ptr noundef @.str.3)
  br label %32

19:                                               ; preds = %12
  %20 = load ptr, ptr %2, align 8, !tbaa !5
  %21 = call ptr @json_value_get_object(ptr noundef %20)
  store ptr %21, ptr %3, align 8, !tbaa !5
  %22 = icmp ne ptr %21, null
  br i1 %22, label %24, label %23

23:                                               ; preds = %19
  call void (ptr, ptr, ...) @debug(ptr noundef @debugger, ptr noundef @.str.4)
  br label %32

24:                                               ; preds = %19
  %25 = load ptr, ptr %3, align 8, !tbaa !5
  %26 = call ptr @json_object_get_string(ptr noundef %25, ptr noundef @.str.5)
  %27 = call ptr @strdup(ptr noundef %26) #4
  store ptr %27, ptr %4, align 8, !tbaa !5
  %28 = load ptr, ptr %4, align 8, !tbaa !5
  %29 = icmp ne ptr %28, null
  br i1 %29, label %31, label %30

30:                                               ; preds = %24
  call void (ptr, ptr, ...) @debug(ptr noundef @debugger, ptr noundef @.str.6)
  br label %32

31:                                               ; preds = %24
  br label %32

32:                                               ; preds = %31, %30, %23, %18, %11
  %33 = load ptr, ptr %2, align 8, !tbaa !5
  %34 = icmp ne ptr %33, null
  br i1 %34, label %35, label %37

35:                                               ; preds = %32
  %36 = load ptr, ptr %2, align 8, !tbaa !5
  call void @json_value_free(ptr noundef %36)
  br label %37

37:                                               ; preds = %35, %32
  %38 = load ptr, ptr %1, align 8, !tbaa !5
  call void @http_get_free(ptr noundef %38)
  %39 = load ptr, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %1) #4
  ret ptr %39
}

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

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

declare ptr @http_get(ptr noundef) #1

declare void @debug(ptr noundef, ptr noundef, ...) #1

declare ptr @json_parse_string(ptr noundef) #1

declare ptr @json_value_get_object(ptr noundef) #1

; Function Attrs: nounwind
declare ptr @strdup(ptr noundef) #3

declare ptr @json_object_get_string(ptr noundef, ptr noundef) #1

declare void @json_value_free(ptr noundef) #1

declare void @http_get_free(ptr noundef) #1

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #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 = { "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 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 = { 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, !12, i64 24}
!10 = !{!"", !6, i64 0, !11, i64 8, !11, i64 16, !12, i64 24}
!11 = !{!"long", !7, i64 0}
!12 = !{!"int", !7, i64 0}
!13 = !{!10, !6, 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"

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

@debugger = external hidden global %struct.debug_t, align 8
@.str = external hidden unnamed_addr constant [18 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [56 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [31 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [38 x i8], align 1
@.str.4 = external hidden unnamed_addr constant [45 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [24 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noalias ptr @clib_release_get_latest_tag() local_unnamed_addr #0 {
  %1 = tail call i32 @debug_init(ptr noundef nonnull @debugger, ptr noundef nonnull @.str) #3
  %2 = tail call ptr @http_get(ptr noundef nonnull @.str.1) #3
  %3 = getelementptr inbounds i8, ptr %2, i64 24
  %4 = load i32, ptr %3, align 8, !tbaa !5
  %.not = icmp eq i32 %4, 0
  br i1 %.not, label %5, label %6

5:                                                ; preds = %0
  tail call void (ptr, ptr, ...) @debug(ptr noundef nonnull @debugger, ptr noundef nonnull @.str.2) #3
  br label %16

6:                                                ; preds = %0
  %7 = load ptr, ptr %2, align 8, !tbaa !12
  %8 = tail call ptr @json_parse_string(ptr noundef %7) #3
  %.not14 = icmp eq ptr %8, null
  br i1 %.not14, label %9, label %10

9:                                                ; preds = %6
  tail call void (ptr, ptr, ...) @debug(ptr noundef nonnull @debugger, ptr noundef nonnull @.str.3) #3
  br label %16

10:                                               ; preds = %6
  %11 = tail call ptr @json_value_get_object(ptr noundef nonnull %8) #3
  %.not15 = icmp eq ptr %11, null
  br i1 %.not15, label %.sink.split, label %12

12:                                               ; preds = %10
  %13 = tail call ptr @json_object_get_string(ptr noundef nonnull %11, ptr noundef nonnull @.str.5) #3
  %14 = tail call ptr @strdup(ptr noundef %13) #3
  %.not16 = icmp eq ptr %14, null
  br i1 %.not16, label %.sink.split, label %15

.sink.split:                                      ; preds = %12, %10
  %.str.6.sink = phi ptr [ @.str.4, %10 ], [ @.str.6, %12 ]
  tail call void (ptr, ptr, ...) @debug(ptr noundef nonnull @debugger, ptr noundef nonnull %.str.6.sink) #3
  br label %15

15:                                               ; preds = %.sink.split, %12
  %.0.ph = phi ptr [ %14, %12 ], [ null, %.sink.split ]
  tail call void @json_value_free(ptr noundef nonnull %8) #3
  br label %16

16:                                               ; preds = %5, %9, %15
  %.023 = phi ptr [ %.0.ph, %15 ], [ null, %9 ], [ null, %5 ]
  tail call void @http_get_free(ptr noundef nonnull %2) #3
  ret ptr %.023
}

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

declare ptr @http_get(ptr noundef) local_unnamed_addr #1

declare void @debug(ptr noundef, ptr noundef, ...) local_unnamed_addr #1

declare ptr @json_parse_string(ptr noundef) local_unnamed_addr #1

declare ptr @json_value_get_object(ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite)
declare noalias ptr @strdup(ptr nocapture noundef readonly) local_unnamed_addr #2

declare ptr @json_object_get_string(ptr noundef, ptr noundef) local_unnamed_addr #1

declare void @json_value_free(ptr noundef) local_unnamed_addr #1

declare void @http_get_free(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 = { mustprogress nofree nounwind willreturn memory(argmem: readwrite, inaccessiblemem: readwrite) "alloc-family"="malloc" "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, !11, i64 24}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 16, !11, 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 = !{!"int", !8, i64 0}
!12 = !{!6, !7, i64 0}


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