; LLVM IR from holzschu/ios_system :: curl/curl/docs/examples (imap-store)

; 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 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@stderr = external global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 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 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 4, ptr %3) #4
  store i32 0, ptr %3, align 4, !tbaa !5
  %4 = call ptr @curl_easy_init()
  store ptr %4, ptr %2, align 8, !tbaa !9
  %5 = load ptr, ptr %2, align 8, !tbaa !9
  %6 = icmp ne ptr %5, null
  br i1 %6, label %7, label %40

7:                                                ; preds = %0
  %8 = load ptr, ptr %2, align 8, !tbaa !9
  %9 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %8, i32 noundef 10173, ptr noundef @.str)
  %10 = load ptr, ptr %2, align 8, !tbaa !9
  %11 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %10, i32 noundef 10174, ptr noundef @.str.1)
  %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.2)
  %14 = load ptr, ptr %2, align 8, !tbaa !9
  %15 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %14, i32 noundef 10036, ptr noundef @.str.3)
  %16 = load ptr, ptr %2, align 8, !tbaa !9
  %17 = call i32 @curl_easy_perform(ptr noundef %16)
  store i32 %17, ptr %3, align 4, !tbaa !5
  %18 = load i32, ptr %3, align 4, !tbaa !5
  %19 = icmp ne i32 %18, 0
  br i1 %19, label %20, label %25

20:                                               ; preds = %7
  %21 = load ptr, ptr @stderr, align 8, !tbaa !9
  %22 = load i32, ptr %3, align 4, !tbaa !5
  %23 = call ptr @curl_easy_strerror(i32 noundef %22)
  %24 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %21, ptr noundef @.str.4, ptr noundef %23) #4
  br label %38

25:                                               ; preds = %7
  %26 = load ptr, ptr %2, align 8, !tbaa !9
  %27 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %26, i32 noundef 10036, ptr noundef @.str.5)
  %28 = load ptr, ptr %2, align 8, !tbaa !9
  %29 = call i32 @curl_easy_perform(ptr noundef %28)
  store i32 %29, ptr %3, align 4, !tbaa !5
  %30 = load i32, ptr %3, align 4, !tbaa !5
  %31 = icmp ne i32 %30, 0
  br i1 %31, label %32, label %37

32:                                               ; preds = %25
  %33 = load ptr, ptr @stderr, align 8, !tbaa !9
  %34 = load i32, ptr %3, align 4, !tbaa !5
  %35 = call ptr @curl_easy_strerror(i32 noundef %34)
  %36 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef @.str.4, ptr noundef %35) #4
  br label %37

37:                                               ; preds = %32, %25
  br label %38

38:                                               ; preds = %37, %20
  %39 = load ptr, ptr %2, align 8, !tbaa !9
  call void @curl_easy_cleanup(ptr noundef %39)
  br label %40

40:                                               ; preds = %38, %0
  %41 = load i32, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #4
  ret i32 %41
}

; 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 i32 @curl_easy_perform(ptr noundef) #2

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

declare ptr @curl_easy_strerror(i32 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

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}


; 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 [5 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [30 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [24 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.4 = external hidden unnamed_addr constant [32 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [8 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = tail call ptr @curl_easy_init() #3
  %.not = icmp eq ptr %1, null
  br i1 %.not, label %15, label %2

2:                                                ; preds = %0
  %3 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %1, i32 noundef 10173, ptr noundef nonnull @.str) #3
  %4 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %1, i32 noundef 10174, ptr noundef nonnull @.str.1) #3
  %5 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %1, i32 noundef 10002, ptr noundef nonnull @.str.2) #3
  %6 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %1, i32 noundef 10036, ptr noundef nonnull @.str.3) #3
  %7 = tail call i32 @curl_easy_perform(ptr noundef nonnull %1) #3
  %.not17 = icmp eq i32 %7, 0
  br i1 %.not17, label %8, label %.sink.split

8:                                                ; preds = %2
  %9 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %1, i32 noundef 10036, ptr noundef nonnull @.str.5) #3
  %10 = tail call i32 @curl_easy_perform(ptr noundef nonnull %1) #3
  %.not18 = icmp eq i32 %10, 0
  br i1 %.not18, label %14, label %.sink.split

.sink.split:                                      ; preds = %8, %2
  %.sink20 = phi i32 [ %7, %2 ], [ %10, %8 ]
  %11 = load ptr, ptr @stderr, align 8, !tbaa !5
  %12 = tail call ptr @curl_easy_strerror(i32 noundef %.sink20) #3
  %13 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %11, ptr noundef nonnull @.str.4, ptr noundef %12) #4
  br label %14

14:                                               ; preds = %.sink.split, %8
  %.0 = phi i32 [ 0, %8 ], [ %.sink20, %.sink.split ]
  tail call void @curl_easy_cleanup(ptr noundef nonnull %1) #3
  br label %15

15:                                               ; preds = %14, %0
  %.1 = phi i32 [ %.0, %14 ], [ 0, %0 ]
  ret i32 %.1
}

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

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

declare ptr @curl_easy_strerror(i32 noundef) local_unnamed_addr #1

declare void @curl_easy_cleanup(ptr noundef) local_unnamed_addr #1

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 = { "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 = { 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 = { nounwind }
attributes #4 = { 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"}


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