; LLVM IR from holzschu/ios_system :: curl/curl/docs/examples (smtp-mime)

; 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 [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@headers_text = external hidden global [7 x ptr], align 16
@inline_html = external hidden constant [197 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [10 x i8], align 1
@inline_text = external hidden constant [157 x i8], align 16
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@stderr = external global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [32 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
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca ptr, align 8
  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
  %11 = call ptr @curl_easy_init()
  store ptr %11, ptr %2, align 8, !tbaa !9
  %12 = load ptr, ptr %2, align 8, !tbaa !9
  %13 = icmp ne ptr %12, null
  br i1 %13, label %14, label %88

14:                                               ; preds = %0
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #4
  store ptr null, ptr %4, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #4
  store ptr null, ptr %5, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #4
  store ptr null, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #4
  %15 = load ptr, ptr %2, align 8, !tbaa !9
  %16 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %15, i32 noundef 10002, ptr noundef @.str)
  %17 = load ptr, ptr %2, align 8, !tbaa !9
  %18 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %17, i32 noundef 10186, ptr noundef @.str.1)
  %19 = load ptr, ptr %5, align 8, !tbaa !9
  %20 = call ptr @curl_slist_append(ptr noundef %19, ptr noundef @.str.2)
  store ptr %20, ptr %5, align 8, !tbaa !9
  %21 = load ptr, ptr %5, align 8, !tbaa !9
  %22 = call ptr @curl_slist_append(ptr noundef %21, ptr noundef @.str.3)
  store ptr %22, ptr %5, align 8, !tbaa !9
  %23 = load ptr, ptr %2, align 8, !tbaa !9
  %24 = load ptr, ptr %5, align 8, !tbaa !9
  %25 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %23, i32 noundef 10187, ptr noundef %24)
  store ptr @headers_text, ptr %10, align 8, !tbaa !9
  br label %26

26:                                               ; preds = %35, %14
  %27 = load ptr, ptr %10, align 8, !tbaa !9
  %28 = load ptr, ptr %27, align 8, !tbaa !9
  %29 = icmp ne ptr %28, null
  br i1 %29, label %30, label %38

30:                                               ; preds = %26
  %31 = load ptr, ptr %4, align 8, !tbaa !9
  %32 = load ptr, ptr %10, align 8, !tbaa !9
  %33 = load ptr, ptr %32, align 8, !tbaa !9
  %34 = call ptr @curl_slist_append(ptr noundef %31, ptr noundef %33)
  store ptr %34, ptr %4, align 8, !tbaa !9
  br label %35

35:                                               ; preds = %30
  %36 = load ptr, ptr %10, align 8, !tbaa !9
  %37 = getelementptr inbounds ptr, ptr %36, i32 1
  store ptr %37, ptr %10, align 8, !tbaa !9
  br label %26, !llvm.loop !11

38:                                               ; preds = %26
  %39 = load ptr, ptr %2, align 8, !tbaa !9
  %40 = load ptr, ptr %4, align 8, !tbaa !9
  %41 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %39, i32 noundef 10023, ptr noundef %40)
  %42 = load ptr, ptr %2, align 8, !tbaa !9
  %43 = call ptr @curl_mime_init(ptr noundef %42)
  store ptr %43, ptr %7, align 8, !tbaa !9
  %44 = load ptr, ptr %2, align 8, !tbaa !9
  %45 = call ptr @curl_mime_init(ptr noundef %44)
  store ptr %45, ptr %8, align 8, !tbaa !9
  %46 = load ptr, ptr %8, align 8, !tbaa !9
  %47 = call ptr @curl_mime_addpart(ptr noundef %46)
  store ptr %47, ptr %9, align 8, !tbaa !9
  %48 = load ptr, ptr %9, align 8, !tbaa !9
  %49 = call i32 @curl_mime_data(ptr noundef %48, ptr noundef @inline_html, i64 noundef -1)
  %50 = load ptr, ptr %9, align 8, !tbaa !9
  %51 = call i32 @curl_mime_type(ptr noundef %50, ptr noundef @.str.4)
  %52 = load ptr, ptr %8, align 8, !tbaa !9
  %53 = call ptr @curl_mime_addpart(ptr noundef %52)
  store ptr %53, ptr %9, align 8, !tbaa !9
  %54 = load ptr, ptr %9, align 8, !tbaa !9
  %55 = call i32 @curl_mime_data(ptr noundef %54, ptr noundef @inline_text, i64 noundef -1)
  %56 = load ptr, ptr %7, align 8, !tbaa !9
  %57 = call ptr @curl_mime_addpart(ptr noundef %56)
  store ptr %57, ptr %9, align 8, !tbaa !9
  %58 = load ptr, ptr %9, align 8, !tbaa !9
  %59 = load ptr, ptr %8, align 8, !tbaa !9
  %60 = call i32 @curl_mime_subparts(ptr noundef %58, ptr noundef %59)
  %61 = load ptr, ptr %9, align 8, !tbaa !9
  %62 = call i32 @curl_mime_type(ptr noundef %61, ptr noundef @.str.5)
  %63 = call ptr @curl_slist_append(ptr noundef null, ptr noundef @.str.6)
  store ptr %63, ptr %6, align 8, !tbaa !9
  %64 = load ptr, ptr %9, align 8, !tbaa !9
  %65 = load ptr, ptr %6, align 8, !tbaa !9
  %66 = call i32 @curl_mime_headers(ptr noundef %64, ptr noundef %65, i32 noundef 1)
  %67 = load ptr, ptr %7, align 8, !tbaa !9
  %68 = call ptr @curl_mime_addpart(ptr noundef %67)
  store ptr %68, ptr %9, align 8, !tbaa !9
  %69 = load ptr, ptr %9, align 8, !tbaa !9
  %70 = call i32 @curl_mime_filedata(ptr noundef %69, ptr noundef @.str.7)
  %71 = load ptr, ptr %2, align 8, !tbaa !9
  %72 = load ptr, ptr %7, align 8, !tbaa !9
  %73 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %71, i32 noundef 10269, ptr noundef %72)
  %74 = load ptr, ptr %2, align 8, !tbaa !9
  %75 = call i32 @curl_easy_perform(ptr noundef %74)
  store i32 %75, ptr %3, align 4, !tbaa !5
  %76 = load i32, ptr %3, align 4, !tbaa !5
  %77 = icmp ne i32 %76, 0
  br i1 %77, label %78, label %83

78:                                               ; preds = %38
  %79 = load ptr, ptr @stderr, align 8, !tbaa !9
  %80 = load i32, ptr %3, align 4, !tbaa !5
  %81 = call ptr @curl_easy_strerror(i32 noundef %80)
  %82 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %79, ptr noundef @.str.8, ptr noundef %81) #4
  br label %83

83:                                               ; preds = %78, %38
  %84 = load ptr, ptr %5, align 8, !tbaa !9
  call void @curl_slist_free_all(ptr noundef %84)
  %85 = load ptr, ptr %4, align 8, !tbaa !9
  call void @curl_slist_free_all(ptr noundef %85)
  %86 = load ptr, ptr %2, align 8, !tbaa !9
  call void @curl_easy_cleanup(ptr noundef %86)
  %87 = load ptr, ptr %7, align 8, !tbaa !9
  call void @curl_mime_free(ptr noundef %87)
  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 8, 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
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #4
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #4
  br label %88

88:                                               ; preds = %83, %0
  %89 = 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 %89
}

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

declare ptr @curl_mime_init(ptr noundef) #2

declare ptr @curl_mime_addpart(ptr noundef) #2

declare i32 @curl_mime_data(ptr noundef, ptr noundef, i64 noundef) #2

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

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

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

declare i32 @curl_mime_filedata(ptr noundef, ptr 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_slist_free_all(ptr noundef) #2

declare void @curl_easy_cleanup(ptr noundef) #2

declare void @curl_mime_free(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}
!11 = distinct !{!11, !12}
!12 = !{!"llvm.loop.mustprogress"}


; 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 [24 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [21 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.3 = external hidden unnamed_addr constant [19 x i8], align 1
@headers_text = external hidden local_unnamed_addr global [7 x ptr], align 16
@inline_html = external hidden constant [197 x i8], align 16
@.str.4 = external hidden unnamed_addr constant [10 x i8], align 1
@inline_text = external hidden constant [157 x i8], align 16
@.str.5 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [28 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [12 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.8 = external hidden unnamed_addr constant [32 x i8], align 1

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

2:                                                ; preds = %0
  %3 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %1, i32 noundef 10002, ptr noundef nonnull @.str) #3
  %4 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %1, i32 noundef 10186, ptr noundef nonnull @.str.1) #3
  %5 = tail call ptr @curl_slist_append(ptr noundef null, ptr noundef nonnull @.str.2) #3
  %6 = tail call ptr @curl_slist_append(ptr noundef %5, ptr noundef nonnull @.str.3) #3
  %7 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %1, i32 noundef 10187, ptr noundef %6) #3
  %8 = load ptr, ptr @headers_text, align 16, !tbaa !5
  %.not4244 = icmp eq ptr %8, null
  br i1 %.not4244, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %2, %.lr.ph
  %9 = phi ptr [ %12, %.lr.ph ], [ %8, %2 ]
  %.046 = phi ptr [ %11, %.lr.ph ], [ @headers_text, %2 ]
  %.03845 = phi ptr [ %10, %.lr.ph ], [ null, %2 ]
  %10 = tail call ptr @curl_slist_append(ptr noundef %.03845, ptr noundef nonnull %9) #3
  %11 = getelementptr inbounds i8, ptr %.046, i64 8
  %12 = load ptr, ptr %11, align 8, !tbaa !5
  %.not42 = icmp eq ptr %12, null
  br i1 %.not42, label %._crit_edge, label %.lr.ph, !llvm.loop !9

._crit_edge:                                      ; preds = %.lr.ph, %2
  %.038.lcssa = phi ptr [ null, %2 ], [ %10, %.lr.ph ]
  %13 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %1, i32 noundef 10023, ptr noundef %.038.lcssa) #3
  %14 = tail call ptr @curl_mime_init(ptr noundef nonnull %1) #3
  %15 = tail call ptr @curl_mime_init(ptr noundef nonnull %1) #3
  %16 = tail call ptr @curl_mime_addpart(ptr noundef %15) #3
  %17 = tail call i32 @curl_mime_data(ptr noundef %16, ptr noundef nonnull @inline_html, i64 noundef -1) #3
  %18 = tail call i32 @curl_mime_type(ptr noundef %16, ptr noundef nonnull @.str.4) #3
  %19 = tail call ptr @curl_mime_addpart(ptr noundef %15) #3
  %20 = tail call i32 @curl_mime_data(ptr noundef %19, ptr noundef nonnull @inline_text, i64 noundef -1) #3
  %21 = tail call ptr @curl_mime_addpart(ptr noundef %14) #3
  %22 = tail call i32 @curl_mime_subparts(ptr noundef %21, ptr noundef %15) #3
  %23 = tail call i32 @curl_mime_type(ptr noundef %21, ptr noundef nonnull @.str.5) #3
  %24 = tail call ptr @curl_slist_append(ptr noundef null, ptr noundef nonnull @.str.6) #3
  %25 = tail call i32 @curl_mime_headers(ptr noundef %21, ptr noundef %24, i32 noundef 1) #3
  %26 = tail call ptr @curl_mime_addpart(ptr noundef %14) #3
  %27 = tail call i32 @curl_mime_filedata(ptr noundef %26, ptr noundef nonnull @.str.7) #3
  %28 = tail call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %1, i32 noundef 10269, ptr noundef %14) #3
  %29 = tail call i32 @curl_easy_perform(ptr noundef nonnull %1) #3
  %.not43 = icmp eq i32 %29, 0
  br i1 %.not43, label %34, label %30

30:                                               ; preds = %._crit_edge
  %31 = load ptr, ptr @stderr, align 8, !tbaa !5
  %32 = tail call ptr @curl_easy_strerror(i32 noundef %29) #3
  %33 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %31, ptr noundef nonnull @.str.8, ptr noundef %32) #4
  br label %34

34:                                               ; preds = %30, %._crit_edge
  tail call void @curl_slist_free_all(ptr noundef %6) #3
  tail call void @curl_slist_free_all(ptr noundef %.038.lcssa) #3
  tail call void @curl_easy_cleanup(ptr noundef nonnull %1) #3
  tail call void @curl_mime_free(ptr noundef %14) #3
  br label %35

35:                                               ; preds = %34, %0
  %.037 = phi i32 [ %29, %34 ], [ 0, %0 ]
  ret i32 %.037
}

declare ptr @curl_easy_init() local_unnamed_addr #1

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

declare ptr @curl_slist_append(ptr noundef, ptr noundef) local_unnamed_addr #1

declare ptr @curl_mime_init(ptr noundef) local_unnamed_addr #1

declare ptr @curl_mime_addpart(ptr noundef) local_unnamed_addr #1

declare i32 @curl_mime_data(ptr noundef, ptr noundef, i64 noundef) local_unnamed_addr #1

declare i32 @curl_mime_type(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @curl_mime_subparts(ptr noundef, ptr noundef) local_unnamed_addr #1

declare i32 @curl_mime_headers(ptr noundef, ptr noundef, i32 noundef) local_unnamed_addr #1

declare i32 @curl_mime_filedata(ptr noundef, ptr 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_slist_free_all(ptr noundef) local_unnamed_addr #1

declare void @curl_easy_cleanup(ptr noundef) local_unnamed_addr #1

declare void @curl_mime_free(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"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,SROAPass,SimplifyCFGPass,TailCallElimPass