; LLVM IR from holzschu/ios_system :: curl/curl/tests/http/clients (h2-serverpush)

; 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.CURLMsg = type { i32, ptr, %union.anon }
%union.anon = type { ptr }

@stderr = external global ptr, align 8
@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1

; 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 ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca i32, align 4
  %14 = alloca i32, align 4
  %15 = alloca ptr, align 8
  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) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  store i32 1, ptr %8, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = icmp ne i32 %16, 2
  br i1 %17, label %18, label %21

18:                                               ; preds = %2
  %19 = load ptr, ptr @stderr, align 8, !tbaa !9
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef @.str) #4
  store i32 2, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %91

21:                                               ; preds = %2
  %22 = load ptr, ptr %5, align 8, !tbaa !9
  %23 = getelementptr inbounds ptr, ptr %22, i64 1
  %24 = load ptr, ptr %23, align 8, !tbaa !9
  store ptr %24, ptr %10, align 8, !tbaa !9
  %25 = call ptr @curl_multi_init()
  store ptr %25, ptr %7, align 8, !tbaa !9
  %26 = load ptr, ptr %7, align 8, !tbaa !9
  %27 = call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %26, i32 noundef 3, i64 noundef 2)
  %28 = load ptr, ptr %7, align 8, !tbaa !9
  %29 = call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %28, i32 noundef 20014, ptr noundef @server_push_callback)
  %30 = load ptr, ptr %7, align 8, !tbaa !9
  %31 = call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %30, i32 noundef 10015, ptr noundef %8)
  %32 = call ptr @curl_easy_init()
  store ptr %32, ptr %6, align 8, !tbaa !9
  %33 = load ptr, ptr %6, align 8, !tbaa !9
  %34 = load ptr, ptr %10, align 8, !tbaa !9
  %35 = call i32 @setup(ptr noundef %33, ptr noundef %34)
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %40

37:                                               ; preds = %21
  %38 = load ptr, ptr @stderr, align 8, !tbaa !9
  %39 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %38, ptr noundef @.str.1) #4
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %91

40:                                               ; preds = %21
  %41 = load ptr, ptr %7, align 8, !tbaa !9
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = call i32 @curl_multi_add_handle(ptr noundef %41, ptr noundef %42)
  br label %44

44:                                               ; preds = %85, %40
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %45 = load ptr, ptr %7, align 8, !tbaa !9
  %46 = call i32 @curl_multi_perform(ptr noundef %45, ptr noundef %12)
  store i32 %46, ptr %13, align 4, !tbaa !5
  %47 = load i32, ptr %12, align 4, !tbaa !5
  %48 = icmp ne i32 %47, 0
  br i1 %48, label %49, label %52

49:                                               ; preds = %44
  %50 = load ptr, ptr %7, align 8, !tbaa !9
  %51 = call i32 @curl_multi_poll(ptr noundef %50, ptr noundef null, i32 noundef 0, i32 noundef 1000, ptr noundef null)
  store i32 %51, ptr %13, align 4, !tbaa !5
  br label %52

52:                                               ; preds = %49, %44
  %53 = load i32, ptr %13, align 4, !tbaa !5
  %54 = icmp ne i32 %53, 0
  br i1 %54, label %55, label %56

55:                                               ; preds = %52
  store i32 2, ptr %11, align 4
  br label %82

56:                                               ; preds = %52
  br label %57

57:                                               ; preds = %78, %56
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  store i32 0, ptr %14, align 4, !tbaa !5
  %58 = load ptr, ptr %7, align 8, !tbaa !9
  %59 = call ptr @curl_multi_info_read(ptr noundef %58, ptr noundef %14)
  store ptr %59, ptr %9, align 8, !tbaa !9
  %60 = load ptr, ptr %9, align 8, !tbaa !9
  %61 = icmp ne ptr %60, null
  br i1 %61, label %62, label %77

62:                                               ; preds = %57
  %63 = load ptr, ptr %9, align 8, !tbaa !9
  %64 = getelementptr inbounds %struct.CURLMsg, ptr %63, i32 0, i32 0
  %65 = load i32, ptr %64, align 8, !tbaa !11
  %66 = icmp eq i32 %65, 1
  br i1 %66, label %67, label %77

67:                                               ; preds = %62
  call void @llvm.lifetime.start.p0(i64 8, ptr %15) #4
  %68 = load ptr, ptr %9, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct.CURLMsg, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !13
  store ptr %70, ptr %15, align 8, !tbaa !9
  %71 = load i32, ptr %8, align 4, !tbaa !5
  %72 = add nsw i32 %71, -1
  store i32 %72, ptr %8, align 4, !tbaa !5
  %73 = load ptr, ptr %7, align 8, !tbaa !9
  %74 = load ptr, ptr %15, align 8, !tbaa !9
  %75 = call i32 @curl_multi_remove_handle(ptr noundef %73, ptr noundef %74)
  %76 = load ptr, ptr %15, align 8, !tbaa !9
  call void @curl_easy_cleanup(ptr noundef %76)
  call void @llvm.lifetime.end.p0(i64 8, ptr %15) #4
  br label %77

77:                                               ; preds = %67, %62, %57
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %78

78:                                               ; preds = %77
  %79 = load ptr, ptr %9, align 8, !tbaa !9
  %80 = icmp ne ptr %79, null
  br i1 %80, label %57, label %81, !llvm.loop !14

81:                                               ; preds = %78
  store i32 0, ptr %11, align 4
  br label %82

82:                                               ; preds = %81, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %83 = load i32, ptr %11, align 4
  switch i32 %83, label %93 [
    i32 0, label %84
    i32 2, label %88
  ]

84:                                               ; preds = %82
  br label %85

85:                                               ; preds = %84
  %86 = load i32, ptr %8, align 4, !tbaa !5
  %87 = icmp ne i32 %86, 0
  br i1 %87, label %44, label %88, !llvm.loop !16

88:                                               ; preds = %85, %82
  %89 = load ptr, ptr %7, align 8, !tbaa !9
  %90 = call i32 @curl_multi_cleanup(ptr noundef %89)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %91

91:                                               ; preds = %88, %37, %18
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %92 = load i32, ptr %3, align 4
  ret i32 %92

93:                                               ; preds = %82
  unreachable
}

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #2

declare ptr @curl_multi_init() #3

declare i32 @curl_multi_setopt(ptr noundef, i32 noundef, ...) #3

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

declare ptr @curl_easy_init() #3

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

declare i32 @curl_multi_add_handle(ptr noundef, ptr noundef) #3

declare i32 @curl_multi_perform(ptr noundef, ptr noundef) #3

declare i32 @curl_multi_poll(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) #3

declare ptr @curl_multi_info_read(ptr noundef, ptr noundef) #3

declare i32 @curl_multi_remove_handle(ptr noundef, ptr noundef) #3

declare void @curl_easy_cleanup(ptr noundef) #3

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

declare i32 @curl_multi_cleanup(ptr noundef) #3

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 = { 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 = { "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/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"CURLMsg", !6, i64 0, !10, i64 8, !7, i64 16}
!13 = !{!12, !10, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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

@stderr = external local_unnamed_addr global ptr, align 8
@.str = external hidden unnamed_addr constant [22 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 3) i32 @main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %3) #4
  store i32 1, ptr %3, align 4, !tbaa !5
  %.not = icmp eq i32 %0, 2
  br i1 %.not, label %9, label %6

6:                                                ; preds = %2
  %7 = load ptr, ptr @stderr, align 8, !tbaa !9
  %8 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str) #5
  br label %43

9:                                                ; preds = %2
  %10 = getelementptr inbounds i8, ptr %1, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !9
  %12 = tail call ptr @curl_multi_init() #4
  %13 = tail call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %12, i32 noundef 3, i64 noundef 2) #4
  %14 = tail call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %12, i32 noundef 20014, ptr noundef nonnull @server_push_callback) #4
  %15 = call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %12, i32 noundef 10015, ptr noundef nonnull %3) #4
  %16 = call ptr @curl_easy_init() #4
  %17 = call i32 @setup(ptr noundef %16, ptr noundef %11)
  %.not25 = icmp eq i32 %17, 0
  br i1 %.not25, label %21, label %18

18:                                               ; preds = %9
  %19 = load ptr, ptr @stderr, align 8, !tbaa !9
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.1) #5
  br label %43

21:                                               ; preds = %9
  %22 = call i32 @curl_multi_add_handle(ptr noundef %12, ptr noundef %16) #4
  br label %23

23:                                               ; preds = %._crit_edge, %21
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %4) #4
  %24 = call i32 @curl_multi_perform(ptr noundef %12, ptr noundef nonnull %4) #4
  %25 = load i32, ptr %4, align 4, !tbaa !5
  %.not26 = icmp eq i32 %25, 0
  br i1 %.not26, label %28, label %26

26:                                               ; preds = %23
  %27 = call i32 @curl_multi_poll(ptr noundef %12, ptr noundef null, i32 noundef 0, i32 noundef 1000, ptr noundef null) #4
  br label %28

28:                                               ; preds = %26, %23
  %.022 = phi i32 [ %27, %26 ], [ %24, %23 ]
  %.not27 = icmp eq i32 %.022, 0
  br i1 %.not27, label %.preheader, label %.thread

.preheader:                                       ; preds = %28
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  %29 = call ptr @curl_multi_info_read(ptr noundef %12, ptr noundef nonnull %5) #4
  %.not2834 = icmp eq ptr %29, null
  br i1 %.not2834, label %._crit_edge, label %.lr.ph

.thread:                                          ; preds = %28
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  br label %.loopexit

.lr.ph:                                           ; preds = %.preheader, %39
  %30 = phi ptr [ %40, %39 ], [ %29, %.preheader ]
  %31 = load i32, ptr %30, align 8, !tbaa !11
  %32 = icmp eq i32 %31, 1
  br i1 %32, label %33, label %39

33:                                               ; preds = %.lr.ph
  %34 = getelementptr inbounds i8, ptr %30, i64 8
  %35 = load ptr, ptr %34, align 8, !tbaa !13
  %36 = load i32, ptr %3, align 4, !tbaa !5
  %37 = add nsw i32 %36, -1
  store i32 %37, ptr %3, align 4, !tbaa !5
  %38 = call i32 @curl_multi_remove_handle(ptr noundef %12, ptr noundef %35) #4
  call void @curl_easy_cleanup(ptr noundef %35) #4
  br label %39

39:                                               ; preds = %33, %.lr.ph
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %5) #4
  store i32 0, ptr %5, align 4, !tbaa !5
  %40 = call ptr @curl_multi_info_read(ptr noundef %12, ptr noundef nonnull %5) #4
  %.not28 = icmp eq ptr %40, null
  br i1 %.not28, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %39, %.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %5) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %4) #4
  %41 = load i32, ptr %3, align 4
  %.not29 = icmp eq i32 %41, 0
  br i1 %.not29, label %.loopexit, label %23, !llvm.loop !16

.loopexit:                                        ; preds = %._crit_edge, %.thread
  %42 = call i32 @curl_multi_cleanup(ptr noundef %12) #4
  br label %43

43:                                               ; preds = %.loopexit, %18, %6
  %.0 = phi i32 [ 2, %6 ], [ 1, %18 ], [ 0, %.loopexit ]
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %3) #4
  ret i32 %.0
}

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

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

declare ptr @curl_multi_init() local_unnamed_addr #3

declare i32 @curl_multi_setopt(ptr noundef, i32 noundef, ...) local_unnamed_addr #3

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

declare ptr @curl_easy_init() local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden i32 @setup(ptr noundef, ptr noundef) local_unnamed_addr #0

declare i32 @curl_multi_add_handle(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @curl_multi_perform(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @curl_multi_poll(ptr noundef, ptr noundef, i32 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

declare ptr @curl_multi_info_read(ptr noundef, ptr noundef) local_unnamed_addr #3

declare i32 @curl_multi_remove_handle(ptr noundef, ptr noundef) local_unnamed_addr #3

declare void @curl_easy_cleanup(ptr noundef) local_unnamed_addr #3

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

declare i32 @curl_multi_cleanup(ptr noundef) local_unnamed_addr #3

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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = { "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 }
attributes #5 = { cold 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 0}
!12 = !{!"CURLMsg", !6, i64 0, !10, i64 8, !7, i64 16}
!13 = !{!12, !10, i64 8}
!14 = distinct !{!14, !15}
!15 = !{!"llvm.loop.mustprogress"}
!16 = distinct !{!16, !15}


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