; LLVM IR from clibs/clib :: deps/http-get (http-get)

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

@.str = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local ptr @http_get_shared(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #5
  %8 = call ptr @curl_easy_init()
  store ptr %8, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #5
  %9 = call noalias ptr @malloc(i64 noundef 32) #6
  store ptr %9, ptr %6, align 8, !tbaa !5
  %10 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.memset.p0.i64(ptr align 8 %10, i8 0, i64 32, i1 false)
  %11 = load ptr, ptr %4, align 8, !tbaa !5
  %12 = icmp ne ptr %11, null
  br i1 %12, label %13, label %17

13:                                               ; preds = %2
  %14 = load ptr, ptr %5, align 8, !tbaa !5
  %15 = load ptr, ptr %4, align 8, !tbaa !5
  %16 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %14, i32 noundef 10100, ptr noundef %15)
  br label %17

17:                                               ; preds = %13, %2
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  %19 = load ptr, ptr %3, align 8, !tbaa !5
  %20 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %18, i32 noundef 10002, ptr noundef %19)
  %21 = load ptr, ptr %5, align 8, !tbaa !5
  %22 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %21, i32 noundef 80, i32 noundef 1)
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %23, i32 noundef 52, i32 noundef 1)
  %25 = load ptr, ptr %5, align 8, !tbaa !5
  %26 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %25, i32 noundef 20011, ptr noundef @http_get_cb)
  %27 = load ptr, ptr %5, align 8, !tbaa !5
  %28 = load ptr, ptr %6, align 8, !tbaa !5
  %29 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %27, i32 noundef 10001, ptr noundef %28)
  %30 = load ptr, ptr %5, align 8, !tbaa !5
  %31 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %30, i32 noundef 10018, ptr noundef @.str)
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call i32 @curl_easy_perform(ptr noundef %32)
  store i32 %33, ptr %7, align 4, !tbaa !9
  %34 = load ptr, ptr %5, align 8, !tbaa !5
  %35 = load ptr, ptr %6, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.http_get_response_t, ptr %35, i32 0, i32 2
  %37 = call i32 (ptr, i32, ...) @curl_easy_getinfo(ptr noundef %34, i32 noundef 2097154, ptr noundef %36)
  %38 = load ptr, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %struct.http_get_response_t, ptr %38, i32 0, i32 2
  %40 = load i64, ptr %39, align 8, !tbaa !11
  %41 = icmp eq i64 200, %40
  br i1 %41, label %42, label %45

42:                                               ; preds = %17
  %43 = load i32, ptr %7, align 4, !tbaa !9
  %44 = icmp ne i32 42, %43
  br label %45

45:                                               ; preds = %42, %17
  %46 = phi i1 [ false, %17 ], [ %44, %42 ]
  %47 = zext i1 %46 to i64
  %48 = select i1 %46, i32 1, i32 0
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.http_get_response_t, ptr %49, i32 0, i32 3
  store i32 %48, ptr %50, align 8, !tbaa !14
  %51 = load ptr, ptr %5, align 8, !tbaa !5
  call void @curl_easy_cleanup(ptr noundef %51)
  %52 = load ptr, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #5
  ret ptr %52
}

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

declare ptr @curl_easy_init() #2

; Function Attrs: nounwind allocsize(0)
declare noalias ptr @malloc(i64 noundef) #3

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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

; Function Attrs: nounwind uwtable
declare hidden i64 @http_get_cb(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #0

declare i32 @curl_easy_perform(ptr noundef) #2

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

declare void @curl_easy_cleanup(ptr 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 = { 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 allocsize(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 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { nounwind }
attributes #6 = { nounwind allocsize(0) }

!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 = !{!"int", !7, i64 0}
!11 = !{!12, !13, i64 16}
!12 = !{!"", !6, i64 0, !13, i64 8, !13, i64 16, !10, i64 24}
!13 = !{!"long", !7, i64 0}
!14 = !{!12, !10, i64 24}


; 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 [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef ptr @http_get_shared(ptr noundef %0, ptr noundef %1) local_unnamed_addr #0 {
  %3 = tail call ptr @curl_easy_init() #3
  %calloc = tail call dereferenceable_or_null(32) ptr @calloc(i64 1, i64 32)
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %6, label %4

4:                                                ; preds = %2
  %5 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %3, i32 noundef 10100, ptr noundef nonnull %1) #3
  br label %6

6:                                                ; preds = %4, %2
  %7 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %3, i32 noundef 10002, ptr noundef %0) #3
  %8 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %3, i32 noundef 80, i32 noundef 1) #3
  %9 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %3, i32 noundef 52, i32 noundef 1) #3
  %10 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %3, i32 noundef 20011, ptr noundef nonnull @http_get_cb) #3
  %11 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %3, i32 noundef 10001, ptr noundef nonnull %calloc) #3
  %12 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %3, i32 noundef 10018, ptr noundef nonnull @.str) #3
  %13 = tail call i32 @curl_easy_perform(ptr noundef %3) #3
  %14 = getelementptr inbounds i8, ptr %calloc, i64 16
  %15 = tail call i32 (ptr, i32, ...) @curl_easy_getinfo(ptr noundef %3, i32 noundef 2097154, ptr noundef nonnull %14) #3
  %16 = load i64, ptr %14, align 8, !tbaa !5
  %17 = icmp eq i64 %16, 200
  %18 = icmp ne i32 %13, 42
  %19 = select i1 %17, i1 %18, i1 false
  %20 = zext i1 %19 to i32
  %21 = getelementptr inbounds i8, ptr %calloc, i64 24
  store i32 %20, ptr %21, align 8, !tbaa !12
  tail call void @curl_easy_cleanup(ptr noundef %3) #3
  ret ptr %calloc
}

declare ptr @curl_easy_init() local_unnamed_addr #1

declare i32 @curl_easy_setopt(ptr noundef, i32 noundef, ...) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare hidden i64 @http_get_cb(ptr noundef, i64 noundef, i64 noundef, ptr noundef) #0

declare i32 @curl_easy_perform(ptr noundef) local_unnamed_addr #1

declare i32 @curl_easy_getinfo(ptr noundef, i32 noundef, ...) local_unnamed_addr #1

declare void @curl_easy_cleanup(ptr noundef) local_unnamed_addr #1

; Function Attrs: nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite)
declare noalias noundef ptr @calloc(i64 noundef, i64 noundef) local_unnamed_addr #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 = { nofree nounwind willreturn allockind("alloc,zeroed") allocsize(0,1) memory(inaccessiblemem: readwrite) "alloc-family"="malloc" }
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 16}
!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, !11, i64 24}


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