; LLVM IR from holzschu/ios_system :: curl/curl/docs/examples (http2-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 }

@.str = external hidden unnamed_addr constant [34 x i8], align 1
@stderr = external global ptr, align 8
@.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
  store ptr @.str, ptr %10, align 8, !tbaa !9
  %16 = load i32, ptr %4, align 4, !tbaa !5
  %17 = icmp eq i32 %16, 2
  br i1 %17, label %18, label %22

18:                                               ; preds = %2
  %19 = load ptr, ptr %5, align 8, !tbaa !9
  %20 = getelementptr inbounds ptr, ptr %19, i64 1
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  store ptr %21, ptr %10, align 8, !tbaa !9
  br label %22

22:                                               ; preds = %18, %2
  %23 = call ptr @curl_multi_init()
  store ptr %23, ptr %7, align 8, !tbaa !9
  %24 = call ptr @curl_easy_init()
  store ptr %24, ptr %6, align 8, !tbaa !9
  %25 = load ptr, ptr %6, align 8, !tbaa !9
  %26 = load ptr, ptr %10, align 8, !tbaa !9
  %27 = call i32 @setup(ptr noundef %25, ptr noundef %26)
  %28 = icmp ne i32 %27, 0
  br i1 %28, label %29, label %32

29:                                               ; preds = %22
  %30 = load ptr, ptr @stderr, align 8, !tbaa !9
  %31 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %30, ptr noundef @.str.1) #4
  store i32 1, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %89

32:                                               ; preds = %22
  %33 = load ptr, ptr %7, align 8, !tbaa !9
  %34 = load ptr, ptr %6, align 8, !tbaa !9
  %35 = call i32 @curl_multi_add_handle(ptr noundef %33, ptr noundef %34)
  %36 = load ptr, ptr %7, align 8, !tbaa !9
  %37 = call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %36, i32 noundef 3, i64 noundef 2)
  %38 = load ptr, ptr %7, align 8, !tbaa !9
  %39 = call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %38, i32 noundef 20014, ptr noundef @server_push_callback)
  %40 = load ptr, ptr %7, align 8, !tbaa !9
  %41 = call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %40, i32 noundef 10015, ptr noundef %8)
  br label %42

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

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

50:                                               ; preds = %47, %42
  %51 = load i32, ptr %13, align 4, !tbaa !5
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %54

53:                                               ; preds = %50
  store i32 2, ptr %11, align 4
  br label %80

54:                                               ; preds = %50
  br label %55

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

60:                                               ; preds = %55
  %61 = load ptr, ptr %9, align 8, !tbaa !9
  %62 = getelementptr inbounds %struct.CURLMsg, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 8, !tbaa !11
  %64 = icmp eq i32 %63, 1
  br i1 %64, label %65, label %75

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

75:                                               ; preds = %65, %60, %55
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  br label %76

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

79:                                               ; preds = %76
  store i32 0, ptr %11, align 4
  br label %80

80:                                               ; preds = %79, %53
  call void @llvm.lifetime.end.p0(i64 4, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  %81 = load i32, ptr %11, align 4
  switch i32 %81, label %91 [
    i32 0, label %82
    i32 2, label %86
  ]

82:                                               ; preds = %80
  br label %83

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

86:                                               ; preds = %83, %80
  %87 = load ptr, ptr %7, align 8, !tbaa !9
  %88 = call i32 @curl_multi_cleanup(ptr noundef %87)
  store i32 0, ptr %3, align 4
  store i32 1, ptr %11, align 4
  br label %89

89:                                               ; preds = %86, %29
  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
  %90 = load i32, ptr %3, align 4
  ret i32 %90

91:                                               ; preds = %80
  unreachable
}

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

declare ptr @curl_multi_init() #2

declare ptr @curl_easy_init() #2

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

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

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

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

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

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

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

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

declare i32 @curl_multi_remove_handle(ptr noundef, ptr 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

declare i32 @curl_multi_cleanup(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 "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"

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

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) 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
  %6 = icmp eq i32 %0, 2
  br i1 %6, label %7, label %10

7:                                                ; preds = %2
  %8 = getelementptr inbounds i8, ptr %1, i64 8
  %9 = load ptr, ptr %8, align 8, !tbaa !9
  br label %10

10:                                               ; preds = %7, %2
  %.024 = phi ptr [ %9, %7 ], [ @.str, %2 ]
  %11 = tail call ptr @curl_multi_init() #4
  %12 = tail call ptr @curl_easy_init() #4
  %13 = tail call i32 @setup(ptr noundef %12, ptr noundef %.024)
  %.not = icmp eq i32 %13, 0
  br i1 %.not, label %17, label %14

14:                                               ; preds = %10
  %15 = load ptr, ptr @stderr, align 8, !tbaa !9
  %16 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %15, ptr noundef nonnull @.str.1) #5
  br label %42

17:                                               ; preds = %10
  %18 = tail call i32 @curl_multi_add_handle(ptr noundef %11, ptr noundef %12) #4
  %19 = tail call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %11, i32 noundef 3, i64 noundef 2) #4
  %20 = tail call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %11, i32 noundef 20014, ptr noundef nonnull @server_push_callback) #4
  %21 = call i32 (ptr, i32, ...) @curl_multi_setopt(ptr noundef %11, i32 noundef 10015, ptr noundef nonnull %3) #4
  br label %22

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

25:                                               ; preds = %22
  %26 = call i32 @curl_multi_poll(ptr noundef %11, ptr noundef null, i32 noundef 0, i32 noundef 1000, ptr noundef null) #4
  br label %27

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

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

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

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

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

38:                                               ; preds = %32, %.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
  %39 = call ptr @curl_multi_info_read(ptr noundef %11, ptr noundef nonnull %5) #4
  %.not28 = icmp eq ptr %39, null
  br i1 %.not28, label %._crit_edge, label %.lr.ph, !llvm.loop !14

._crit_edge:                                      ; preds = %38, %.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
  %40 = load i32, ptr %3, align 4
  %.not29 = icmp eq i32 %40, 0
  br i1 %.not29, label %.loopexit, label %22, !llvm.loop !16

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

42:                                               ; preds = %.loopexit, %14
  %.0 = phi i32 [ 1, %14 ], [ 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

declare ptr @curl_multi_init() local_unnamed_addr #2

declare ptr @curl_easy_init() local_unnamed_addr #2

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

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

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

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

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

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

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

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

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

declare void @curl_easy_cleanup(ptr noundef) local_unnamed_addr #2

; 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 #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 = { mustprogress 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 = { 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 }
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