; LLVM IR from holzschu/ios_system :: curl/curl/docs/examples (multi-double)

; 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 [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [18 x i8], align 1
@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca ptr, align 8
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #4
  store i32 1, ptr %5, align 4, !tbaa !5
  %10 = call ptr @curl_easy_init()
  store ptr %10, ptr %2, align 8, !tbaa !9
  %11 = call ptr @curl_easy_init()
  store ptr %11, ptr %3, align 8, !tbaa !9
  %12 = load ptr, ptr %2, align 8, !tbaa !9
  %13 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %12, i32 noundef 10002, ptr noundef @.str)
  %14 = load ptr, ptr %3, align 8, !tbaa !9
  %15 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %14, i32 noundef 10002, ptr noundef @.str.1)
  %16 = call ptr @curl_multi_init()
  store ptr %16, ptr %4, align 8, !tbaa !9
  %17 = load ptr, ptr %4, align 8, !tbaa !9
  %18 = load ptr, ptr %2, align 8, !tbaa !9
  %19 = call i32 @curl_multi_add_handle(ptr noundef %17, ptr noundef %18)
  %20 = load ptr, ptr %4, align 8, !tbaa !9
  %21 = load ptr, ptr %3, align 8, !tbaa !9
  %22 = call i32 @curl_multi_add_handle(ptr noundef %20, ptr noundef %21)
  br label %23

23:                                               ; preds = %60, %0
  %24 = load i32, ptr %5, align 4, !tbaa !5
  %25 = icmp ne i32 %24, 0
  br i1 %25, label %26, label %61

26:                                               ; preds = %23
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %27 = load ptr, ptr %4, align 8, !tbaa !9
  %28 = call i32 @curl_multi_perform(ptr noundef %27, ptr noundef %5)
  store i32 %28, ptr %8, align 4, !tbaa !5
  %29 = load i32, ptr %5, align 4, !tbaa !5
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %34

31:                                               ; preds = %26
  %32 = load ptr, ptr %4, align 8, !tbaa !9
  %33 = call i32 @curl_multi_poll(ptr noundef %32, ptr noundef null, i32 noundef 0, i32 noundef 1000, ptr noundef null)
  store i32 %33, ptr %8, align 4, !tbaa !5
  br label %34

34:                                               ; preds = %31, %26
  %35 = load i32, ptr %8, align 4, !tbaa !5
  %36 = icmp ne i32 %35, 0
  br i1 %36, label %37, label %38

37:                                               ; preds = %34
  store i32 3, ptr %9, align 4
  br label %58

38:                                               ; preds = %34
  br label %39

39:                                               ; preds = %54, %38
  %40 = load ptr, ptr %4, align 8, !tbaa !9
  %41 = call ptr @curl_multi_info_read(ptr noundef %40, ptr noundef %7)
  store ptr %41, ptr %6, align 8, !tbaa !9
  %42 = load ptr, ptr %6, align 8, !tbaa !9
  %43 = icmp ne ptr %42, null
  br i1 %43, label %44, label %53

44:                                               ; preds = %39
  %45 = load ptr, ptr %6, align 8, !tbaa !9
  %46 = getelementptr inbounds %struct.CURLMsg, ptr %45, i32 0, i32 0
  %47 = load i32, ptr %46, align 8, !tbaa !11
  %48 = icmp eq i32 %47, 1
  br i1 %48, label %49, label %52

49:                                               ; preds = %44
  %50 = load ptr, ptr @stderr, align 8, !tbaa !9
  %51 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %50, ptr noundef @.str.2) #4
  br label %52

52:                                               ; preds = %49, %44
  br label %53

53:                                               ; preds = %52, %39
  br label %54

54:                                               ; preds = %53
  %55 = load ptr, ptr %6, align 8, !tbaa !9
  %56 = icmp ne ptr %55, null
  br i1 %56, label %39, label %57, !llvm.loop !13

57:                                               ; preds = %54
  store i32 0, ptr %9, align 4
  br label %58

58:                                               ; preds = %57, %37
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #4
  %59 = load i32, ptr %9, align 4
  switch i32 %59, label %73 [
    i32 0, label %60
    i32 3, label %61
  ]

60:                                               ; preds = %58
  br label %23, !llvm.loop !15

61:                                               ; preds = %58, %23
  %62 = load ptr, ptr %4, align 8, !tbaa !9
  %63 = load ptr, ptr %2, align 8, !tbaa !9
  %64 = call i32 @curl_multi_remove_handle(ptr noundef %62, ptr noundef %63)
  %65 = load ptr, ptr %4, align 8, !tbaa !9
  %66 = load ptr, ptr %3, align 8, !tbaa !9
  %67 = call i32 @curl_multi_remove_handle(ptr noundef %65, ptr noundef %66)
  %68 = load ptr, ptr %4, align 8, !tbaa !9
  %69 = call i32 @curl_multi_cleanup(ptr noundef %68)
  %70 = load ptr, ptr %2, align 8, !tbaa !9
  call void @curl_easy_cleanup(ptr noundef %70)
  %71 = load ptr, ptr %3, align 8, !tbaa !9
  call void @curl_easy_cleanup(ptr noundef %71)
  store i32 0, ptr %1, align 4
  store i32 1, ptr %9, align 4
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #4
  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
  %72 = load i32, ptr %1, align 4
  ret i32 %72

73:                                               ; preds = %58
  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_easy_init() #2

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

declare ptr @curl_multi_init() #2

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

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

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, 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_remove_handle(ptr noundef, ptr noundef) #2

declare i32 @curl_multi_cleanup(ptr noundef) #2

declare void @curl_easy_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 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}
!15 = distinct !{!15, !14}


; 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 [25 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [18 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [20 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
.preheader30.preheader:
  %0 = alloca i32, align 4
  %1 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0) #4
  store i32 1, ptr %0, align 4, !tbaa !5
  %2 = tail call ptr @curl_easy_init() #4
  %3 = tail call ptr @curl_easy_init() #4
  %4 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %2, i32 noundef 10002, ptr noundef nonnull @.str) #4
  %5 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %3, i32 noundef 10002, ptr noundef nonnull @.str.1) #4
  %6 = tail call ptr @curl_multi_init() #4
  %7 = tail call i32 @curl_multi_add_handle(ptr noundef %6, ptr noundef %2) #4
  %8 = tail call i32 @curl_multi_add_handle(ptr noundef %6, ptr noundef %3) #4
  br label %.preheader30

.preheader30:                                     ; preds = %.preheader30.preheader, %.critedge
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %1) #4
  %9 = call i32 @curl_multi_perform(ptr noundef %6, ptr noundef nonnull %0) #4
  %10 = load i32, ptr %0, align 4, !tbaa !5
  %.not23 = icmp eq i32 %10, 0
  br i1 %.not23, label %13, label %11

11:                                               ; preds = %.preheader30
  %12 = call i32 @curl_multi_poll(ptr noundef %6, ptr noundef null, i32 noundef 0, i32 noundef 1000, ptr noundef null) #4
  br label %13

13:                                               ; preds = %11, %.preheader30
  %.021 = phi i32 [ %12, %11 ], [ %9, %.preheader30 ]
  %.not24 = icmp eq i32 %.021, 0
  br i1 %.not24, label %.preheader, label %.critedge.thread

.preheader:                                       ; preds = %13
  %14 = call ptr @curl_multi_info_read(ptr noundef %6, ptr noundef nonnull %1) #4
  %.not2531 = icmp eq ptr %14, null
  br i1 %.not2531, label %.critedge, label %.lr.ph

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

.lr.ph:                                           ; preds = %.preheader, %21
  %15 = phi ptr [ %22, %21 ], [ %14, %.preheader ]
  %16 = load i32, ptr %15, align 8, !tbaa !9
  %17 = icmp eq i32 %16, 1
  br i1 %17, label %18, label %21

18:                                               ; preds = %.lr.ph
  %19 = load ptr, ptr @stderr, align 8, !tbaa !12
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %19, ptr noundef nonnull @.str.2) #5
  br label %21

21:                                               ; preds = %18, %.lr.ph
  %22 = call ptr @curl_multi_info_read(ptr noundef %6, ptr noundef nonnull %1) #4
  %.not25 = icmp eq ptr %22, null
  br i1 %.not25, label %.critedge, label %.lr.ph, !llvm.loop !13

.critedge:                                        ; preds = %21, %.preheader
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %1) #4
  %23 = load i32, ptr %0, align 4
  %.not = icmp eq i32 %23, 0
  br i1 %.not, label %.loopexit, label %.preheader30

.loopexit:                                        ; preds = %.critedge, %.critedge.thread
  %24 = call i32 @curl_multi_remove_handle(ptr noundef %6, ptr noundef %2) #4
  %25 = call i32 @curl_multi_remove_handle(ptr noundef %6, ptr noundef %3) #4
  %26 = call i32 @curl_multi_cleanup(ptr noundef %6) #4
  call void @curl_easy_cleanup(ptr noundef %2) #4
  call void @curl_easy_cleanup(ptr noundef %3) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %0) #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_easy_init() local_unnamed_addr #2

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

declare ptr @curl_multi_init() local_unnamed_addr #2

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

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

; Function Attrs: nofree nounwind
declare noundef i32 @fprintf(ptr nocapture noundef, ptr nocapture noundef readonly, ...) 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_remove_handle(ptr noundef, ptr noundef) local_unnamed_addr #2

declare i32 @curl_multi_cleanup(ptr noundef) local_unnamed_addr #2

declare void @curl_easy_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, !6, i64 0}
!10 = !{!"CURLMsg", !6, i64 0, !11, i64 8, !7, i64 16}
!11 = !{!"any pointer", !7, i64 0}
!12 = !{!11, !11, i64 0}
!13 = distinct !{!13, !14}
!14 = !{!"llvm.loop.mustprogress"}


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