; 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"

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

declare ptr @curl_easy_init() #1

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

declare i32 @curl_easy_perform(ptr noundef) #1

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

declare void @curl_easy_cleanup(ptr noundef) #1

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

; Function Attrs: nounwind uwtable
define dso_local i32 @http_get_file_shared(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca i32, align 4
  %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 ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i64, align 8
  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
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #3
  %13 = call ptr @curl_easy_init()
  store ptr %13, ptr %8, align 8, !tbaa !5
  %14 = load ptr, ptr %8, align 8, !tbaa !5
  %15 = icmp ne ptr %14, null
  br i1 %15, label %17, label %16

16:                                               ; preds = %3
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %60

17:                                               ; preds = %3
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #3
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = call noalias ptr @fopen(ptr noundef %18, ptr noundef @.str.1)
  store ptr %19, ptr %10, align 8, !tbaa !5
  %20 = load ptr, ptr %10, align 8, !tbaa !5
  %21 = icmp ne ptr %20, null
  br i1 %21, label %23, label %22

22:                                               ; preds = %17
  store i32 -1, ptr %4, align 4
  store i32 1, ptr %9, align 4
  br label %59

23:                                               ; preds = %17
  %24 = load ptr, ptr %7, align 8, !tbaa !5
  %25 = icmp ne ptr %24, null
  br i1 %25, label %26, label %30

26:                                               ; preds = %23
  %27 = load ptr, ptr %8, align 8, !tbaa !5
  %28 = load ptr, ptr %7, align 8, !tbaa !5
  %29 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %27, i32 noundef 10100, ptr noundef %28)
  br label %30

30:                                               ; preds = %26, %23
  %31 = load ptr, ptr %8, align 8, !tbaa !5
  %32 = load ptr, ptr %5, align 8, !tbaa !5
  %33 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %31, i32 noundef 10002, ptr noundef %32)
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  %35 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %34, i32 noundef 80, i32 noundef 1)
  %36 = load ptr, ptr %8, align 8, !tbaa !5
  %37 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %36, i32 noundef 52, i32 noundef 1)
  %38 = load ptr, ptr %8, align 8, !tbaa !5
  %39 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %38, i32 noundef 20011, ptr noundef @http_get_file_cb)
  %40 = load ptr, ptr %8, align 8, !tbaa !5
  %41 = load ptr, ptr %10, align 8, !tbaa !5
  %42 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %40, i32 noundef 10001, ptr noundef %41)
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #3
  %43 = load ptr, ptr %8, align 8, !tbaa !5
  %44 = call i32 @curl_easy_perform(ptr noundef %43)
  store i32 %44, ptr %11, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %12) #3
  %45 = load ptr, ptr %8, align 8, !tbaa !5
  %46 = call i32 (ptr, i32, ...) @curl_easy_getinfo(ptr noundef %45, i32 noundef 2097154, ptr noundef %12)
  %47 = load ptr, ptr %8, align 8, !tbaa !5
  call void @curl_easy_cleanup(ptr noundef %47)
  %48 = load ptr, ptr %10, align 8, !tbaa !5
  %49 = call i32 @fclose(ptr noundef %48)
  %50 = load i64, ptr %12, align 8, !tbaa !11
  %51 = icmp eq i64 200, %50
  br i1 %51, label %52, label %55

52:                                               ; preds = %30
  %53 = load i32, ptr %11, align 4, !tbaa !9
  %54 = icmp ne i32 42, %53
  br label %55

55:                                               ; preds = %52, %30
  %56 = phi i1 [ false, %30 ], [ %54, %52 ]
  %57 = zext i1 %56 to i64
  %58 = select i1 %56, i32 0, i32 -1
  store i32 %58, ptr %4, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 8, ptr %12) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #3
  br label %59

59:                                               ; preds = %55, %22
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #3
  br label %60

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

declare noalias ptr @fopen(ptr noundef, ptr noundef) #1

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

declare i32 @fclose(ptr 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 = { 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 #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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"long", !7, 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"

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

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

declare ptr @curl_easy_init() local_unnamed_addr #1

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

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: mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nounwind uwtable
define dso_local range(i32 -1, 1) i32 @http_get_file_shared(ptr noundef %0, ptr nocapture noundef readonly %1, ptr noundef %2) local_unnamed_addr #2 {
  %4 = alloca i64, align 8
  %5 = tail call ptr @curl_easy_init() #4
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %24, label %6

6:                                                ; preds = %3
  %7 = tail call noalias ptr @fopen(ptr noundef %1, ptr noundef nonnull @.str.1)
  %.not21 = icmp eq ptr %7, null
  br i1 %.not21, label %24, label %8

8:                                                ; preds = %6
  %.not22 = icmp eq ptr %2, null
  br i1 %.not22, label %11, label %9

9:                                                ; preds = %8
  %10 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %5, i32 noundef 10100, ptr noundef nonnull %2) #4
  br label %11

11:                                               ; preds = %9, %8
  %12 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %5, i32 noundef 10002, ptr noundef %0) #4
  %13 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %5, i32 noundef 80, i32 noundef 1) #4
  %14 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %5, i32 noundef 52, i32 noundef 1) #4
  %15 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %5, i32 noundef 20011, ptr noundef nonnull @http_get_file_cb) #4
  %16 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %5, i32 noundef 10001, ptr noundef nonnull %7) #4
  %17 = tail call i32 @curl_easy_perform(ptr noundef nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #4
  %18 = call i32 (ptr, i32, ...) @curl_easy_getinfo(ptr noundef nonnull %5, i32 noundef 2097154, ptr noundef nonnull %4) #4
  call void @curl_easy_cleanup(ptr noundef nonnull %5) #4
  %19 = call i32 @fclose(ptr noundef nonnull %7)
  %20 = load i64, ptr %4, align 8, !tbaa !5
  %21 = icmp ne i64 %20, 200
  %22 = icmp eq i32 %17, 42
  %.not25 = select i1 %21, i1 true, i1 %22
  %23 = sext i1 %.not25 to i32
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #4
  br label %24

24:                                               ; preds = %11, %6, %3
  %.1 = phi i32 [ -1, %3 ], [ %23, %11 ], [ -1, %6 ]
  ret i32 %.1
}

; Function Attrs: nofree nounwind
declare noalias noundef ptr @fopen(ptr nocapture noundef readonly, ptr nocapture noundef readonly) local_unnamed_addr #3

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

; Function Attrs: nofree nounwind
declare noundef i32 @fclose(ptr nocapture noundef) local_unnamed_addr #3

attributes #0 = { mustprogress 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 = { 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 #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 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}


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