; LLVM IR from holzschu/ios_system :: curl/curl/docs/examples (threaded-ssl)

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

@urls = external dso_local constant [4 x ptr], align 16
@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [22 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 [4 x i64], align 16
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  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 32, ptr %6) #4
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #4
  %9 = load i32, ptr %4, align 4, !tbaa !5
  %10 = load ptr, ptr %5, align 8, !tbaa !9
  %11 = call i32 @curl_global_init(i64 noundef 3)
  call void @init_locks()
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %12

12:                                               ; preds = %40, %2
  %13 = load i32, ptr %7, align 4, !tbaa !5
  %14 = icmp slt i32 %13, 4
  br i1 %14, label %15, label %43

15:                                               ; preds = %12
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #4
  %16 = load i32, ptr %7, align 4, !tbaa !5
  %17 = sext i32 %16 to i64
  %18 = getelementptr inbounds [4 x i64], ptr %6, i64 0, i64 %17
  %19 = load i32, ptr %7, align 4, !tbaa !5
  %20 = sext i32 %19 to i64
  %21 = getelementptr inbounds [4 x ptr], ptr @urls, i64 0, i64 %20
  %22 = load ptr, ptr %21, align 8, !tbaa !9
  %23 = call i32 @pthread_create(ptr noundef %18, ptr noundef null, ptr noundef @pull_one_url, ptr noundef %22) #4
  store i32 %23, ptr %8, align 4, !tbaa !5
  %24 = load i32, ptr %8, align 4, !tbaa !5
  %25 = icmp ne i32 0, %24
  br i1 %25, label %26, label %31

26:                                               ; preds = %15
  %27 = load ptr, ptr @stderr, align 8, !tbaa !9
  %28 = load i32, ptr %7, align 4, !tbaa !5
  %29 = load i32, ptr %8, align 4, !tbaa !5
  %30 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %27, ptr noundef @.str.4, i32 noundef %28, i32 noundef %29) #4
  br label %39

31:                                               ; preds = %15
  %32 = load ptr, ptr @stderr, align 8, !tbaa !9
  %33 = load i32, ptr %7, align 4, !tbaa !5
  %34 = load i32, ptr %7, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [4 x ptr], ptr @urls, i64 0, i64 %35
  %37 = load ptr, ptr %36, align 8, !tbaa !9
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %32, ptr noundef @.str.5, i32 noundef %33, ptr noundef %37) #4
  br label %39

39:                                               ; preds = %31, %26
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #4
  br label %40

40:                                               ; preds = %39
  %41 = load i32, ptr %7, align 4, !tbaa !5
  %42 = add nsw i32 %41, 1
  store i32 %42, ptr %7, align 4, !tbaa !5
  br label %12, !llvm.loop !11

43:                                               ; preds = %12
  store i32 0, ptr %7, align 4, !tbaa !5
  br label %44

44:                                               ; preds = %56, %43
  %45 = load i32, ptr %7, align 4, !tbaa !5
  %46 = icmp slt i32 %45, 4
  br i1 %46, label %47, label %59

47:                                               ; preds = %44
  %48 = load i32, ptr %7, align 4, !tbaa !5
  %49 = sext i32 %48 to i64
  %50 = getelementptr inbounds [4 x i64], ptr %6, i64 0, i64 %49
  %51 = load i64, ptr %50, align 8, !tbaa !13
  %52 = call i32 @pthread_join(i64 noundef %51, ptr noundef null)
  %53 = load ptr, ptr @stderr, align 8, !tbaa !9
  %54 = load i32, ptr %7, align 4, !tbaa !5
  %55 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %53, ptr noundef @.str.6, i32 noundef %54) #4
  br label %56

56:                                               ; preds = %47
  %57 = load i32, ptr %7, align 4, !tbaa !5
  %58 = add nsw i32 %57, 1
  store i32 %58, ptr %7, align 4, !tbaa !5
  br label %44, !llvm.loop !15

59:                                               ; preds = %44
  call void @kill_locks()
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #4
  call void @llvm.lifetime.end.p0(i64 32, ptr %6) #4
  ret i32 0
}

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

declare i32 @curl_global_init(i64 noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @init_locks() #0

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

; Function Attrs: nounwind uwtable
declare hidden ptr @pull_one_url(ptr noundef) #0

; 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 @pthread_join(i64 noundef, ptr noundef) #2

; Function Attrs: nounwind uwtable
declare hidden void @kill_locks() #0

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 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}
!13 = !{!14, !14, i64 0}
!14 = !{!"long", !7, i64 0}
!15 = distinct !{!15, !12}


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

@urls = external dso_local local_unnamed_addr constant [4 x ptr], align 16
@stderr = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [41 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [20 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [22 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main(i32 noundef %0, ptr nocapture noundef readnone %1) local_unnamed_addr #0 {
  %3 = alloca [4 x i64], align 16
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %3) #5
  %4 = tail call i32 @curl_global_init(i64 noundef 3) #5
  tail call void @init_locks()
  %5 = load ptr, ptr @urls, align 16, !tbaa !5
  %6 = call i32 @pthread_create(ptr noundef nonnull %3, ptr noundef null, ptr noundef nonnull @pull_one_url, ptr noundef %5) #5
  %.not = icmp eq i32 %6, 0
  %7 = load ptr, ptr @stderr, align 8, !tbaa !5
  br i1 %.not, label %10, label %8

8:                                                ; preds = %2
  %9 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.4, i32 noundef 0, i32 noundef %6) #6
  br label %12

10:                                               ; preds = %2
  %11 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %7, ptr noundef nonnull @.str.5, i32 noundef 0, ptr noundef %5) #6
  br label %12

12:                                               ; preds = %10, %8
  %13 = getelementptr inbounds i8, ptr %3, i64 8
  %14 = load ptr, ptr getelementptr inbounds (i8, ptr @urls, i64 8), align 8, !tbaa !5
  %15 = call i32 @pthread_create(ptr noundef nonnull %13, ptr noundef null, ptr noundef nonnull @pull_one_url, ptr noundef %14) #5
  %.not.1 = icmp eq i32 %15, 0
  %16 = load ptr, ptr @stderr, align 8, !tbaa !5
  br i1 %.not.1, label %19, label %17

17:                                               ; preds = %12
  %18 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.4, i32 noundef 1, i32 noundef %15) #6
  br label %21

19:                                               ; preds = %12
  %20 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %16, ptr noundef nonnull @.str.5, i32 noundef 1, ptr noundef %14) #6
  br label %21

21:                                               ; preds = %19, %17
  %22 = getelementptr inbounds i8, ptr %3, i64 16
  %23 = load ptr, ptr getelementptr inbounds (i8, ptr @urls, i64 16), align 16, !tbaa !5
  %24 = call i32 @pthread_create(ptr noundef nonnull %22, ptr noundef null, ptr noundef nonnull @pull_one_url, ptr noundef %23) #5
  %.not.2 = icmp eq i32 %24, 0
  %25 = load ptr, ptr @stderr, align 8, !tbaa !5
  br i1 %.not.2, label %28, label %26

26:                                               ; preds = %21
  %27 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.4, i32 noundef 2, i32 noundef %24) #6
  br label %30

28:                                               ; preds = %21
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %25, ptr noundef nonnull @.str.5, i32 noundef 2, ptr noundef %23) #6
  br label %30

30:                                               ; preds = %28, %26
  %31 = getelementptr inbounds i8, ptr %3, i64 24
  %32 = load ptr, ptr getelementptr inbounds (i8, ptr @urls, i64 24), align 8, !tbaa !5
  %33 = call i32 @pthread_create(ptr noundef nonnull %31, ptr noundef null, ptr noundef nonnull @pull_one_url, ptr noundef %32) #5
  %.not.3 = icmp eq i32 %33, 0
  %34 = load ptr, ptr @stderr, align 8, !tbaa !5
  br i1 %.not.3, label %37, label %35

35:                                               ; preds = %30
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.4, i32 noundef 3, i32 noundef %33) #6
  br label %.preheader.preheader

37:                                               ; preds = %30
  %38 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %34, ptr noundef nonnull @.str.5, i32 noundef 3, ptr noundef %32) #6
  br label %.preheader.preheader

.preheader.preheader:                             ; preds = %37, %35
  %39 = load i64, ptr %3, align 16, !tbaa !9
  %40 = call i32 @pthread_join(i64 noundef %39, ptr noundef null) #5
  %41 = load ptr, ptr @stderr, align 8, !tbaa !5
  %42 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %41, ptr noundef nonnull @.str.6, i32 noundef 0) #6
  %43 = load i64, ptr %13, align 8, !tbaa !9
  %44 = call i32 @pthread_join(i64 noundef %43, ptr noundef null) #5
  %45 = load ptr, ptr @stderr, align 8, !tbaa !5
  %46 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %45, ptr noundef nonnull @.str.6, i32 noundef 1) #6
  %47 = load i64, ptr %22, align 16, !tbaa !9
  %48 = call i32 @pthread_join(i64 noundef %47, ptr noundef null) #5
  %49 = load ptr, ptr @stderr, align 8, !tbaa !5
  %50 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %49, ptr noundef nonnull @.str.6, i32 noundef 2) #6
  %51 = load i64, ptr %31, align 8, !tbaa !9
  %52 = call i32 @pthread_join(i64 noundef %51, ptr noundef null) #5
  %53 = load ptr, ptr @stderr, align 8, !tbaa !5
  %54 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %53, ptr noundef nonnull @.str.6, i32 noundef 3) #6
  call void @kill_locks()
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %3) #5
  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 i32 @curl_global_init(i64 noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @init_locks() local_unnamed_addr #0

; Function Attrs: nounwind
declare i32 @pthread_create(ptr noundef, ptr noundef, ptr noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: nounwind uwtable
declare hidden ptr @pull_one_url(ptr noundef) #0

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

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

declare i32 @pthread_join(i64 noundef, ptr noundef) local_unnamed_addr #2

; Function Attrs: nounwind uwtable
declare hidden void @kill_locks() local_unnamed_addr #0

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 = { 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 = { 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 #5 = { nounwind }
attributes #6 = { 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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"long", !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,LoopRotatePass,LoopSimplifyPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass