; LLVM IR from holzschu/ios_system :: curl/curl/docs/examples (ftpgetinfo)

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

@__const.main.ftpurl = external hidden unnamed_addr constant [59 x i8], align 16
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1
@stderr = external global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @main() #0 {
  %1 = alloca i32, align 4
  %2 = alloca [59 x i8], align 16
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  %5 = alloca i64, align 8
  %6 = alloca i64, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i64, align 8
  store i32 0, ptr %1, align 4
  call void @llvm.lifetime.start.p0(i64 59, ptr %2) #6
  call void @llvm.memcpy.p0.p0.i64(ptr align 16 %2, ptr align 16 @__const.main.ftpurl, i64 59, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %5) #6
  store i64 -1, ptr %5, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #6
  store i64 0, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #6
  %9 = getelementptr inbounds [59 x i8], ptr %2, i64 0, i64 0
  %10 = call ptr @strrchr(ptr noundef %9, i32 noundef 47) #7
  %11 = getelementptr inbounds i8, ptr %10, i64 1
  store ptr %11, ptr %7, align 8, !tbaa !9
  %12 = call i32 @curl_global_init(i64 noundef 3)
  %13 = call ptr @curl_easy_init()
  store ptr %13, ptr %3, align 8, !tbaa !9
  %14 = load ptr, ptr %3, align 8, !tbaa !9
  %15 = icmp ne ptr %14, null
  br i1 %15, label %16, label %64

16:                                               ; preds = %0
  %17 = load ptr, ptr %3, align 8, !tbaa !9
  %18 = getelementptr inbounds [59 x i8], ptr %2, i64 0, i64 0
  %19 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %17, i32 noundef 10002, ptr noundef %18)
  %20 = load ptr, ptr %3, align 8, !tbaa !9
  %21 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %20, i32 noundef 44, i64 noundef 1)
  %22 = load ptr, ptr %3, align 8, !tbaa !9
  %23 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %22, i32 noundef 69, i64 noundef 1)
  %24 = load ptr, ptr %3, align 8, !tbaa !9
  %25 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %24, i32 noundef 20079, ptr noundef @throw_away)
  %26 = load ptr, ptr %3, align 8, !tbaa !9
  %27 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef %26, i32 noundef 42, i64 noundef 0)
  %28 = load ptr, ptr %3, align 8, !tbaa !9
  %29 = call i32 @curl_easy_perform(ptr noundef %28)
  store i32 %29, ptr %4, align 4, !tbaa !11
  %30 = load i32, ptr %4, align 4, !tbaa !11
  %31 = icmp eq i32 0, %30
  br i1 %31, label %32, label %58

32:                                               ; preds = %16
  %33 = load ptr, ptr %3, align 8, !tbaa !9
  %34 = call i32 (ptr, i32, ...) @curl_easy_getinfo(ptr noundef %33, i32 noundef 2097166, ptr noundef %5)
  store i32 %34, ptr %4, align 4, !tbaa !11
  %35 = load i32, ptr %4, align 4, !tbaa !11
  %36 = icmp eq i32 0, %35
  br i1 %36, label %37, label %45

37:                                               ; preds = %32
  %38 = load i64, ptr %5, align 8, !tbaa !5
  %39 = icmp sge i64 %38, 0
  br i1 %39, label %40, label %45

40:                                               ; preds = %37
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #6
  %41 = load i64, ptr %5, align 8, !tbaa !5
  store i64 %41, ptr %8, align 8, !tbaa !5
  %42 = load ptr, ptr %7, align 8, !tbaa !9
  %43 = call ptr @ctime(ptr noundef %8) #6
  %44 = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef %42, ptr noundef %43)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #6
  br label %45

45:                                               ; preds = %40, %37, %32
  %46 = load ptr, ptr %3, align 8, !tbaa !9
  %47 = call i32 (ptr, i32, ...) @curl_easy_getinfo(ptr noundef %46, i32 noundef 6291471, ptr noundef %6)
  store i32 %47, ptr %4, align 4, !tbaa !11
  %48 = load i32, ptr %4, align 4, !tbaa !11
  %49 = icmp eq i32 0, %48
  br i1 %49, label %50, label %57

50:                                               ; preds = %45
  %51 = load i64, ptr %6, align 8, !tbaa !5
  %52 = icmp sgt i64 %51, 0
  br i1 %52, label %53, label %57

53:                                               ; preds = %50
  %54 = load ptr, ptr %7, align 8, !tbaa !9
  %55 = load i64, ptr %6, align 8, !tbaa !5
  %56 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, ptr noundef %54, i64 noundef %55)
  br label %57

57:                                               ; preds = %53, %50, %45
  br label %62

58:                                               ; preds = %16
  %59 = load ptr, ptr @stderr, align 8, !tbaa !9
  %60 = load i32, ptr %4, align 4, !tbaa !11
  %61 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %59, ptr noundef @.str.2, i32 noundef %60) #6
  br label %62

62:                                               ; preds = %58, %57
  %63 = load ptr, ptr %3, align 8, !tbaa !9
  call void @curl_easy_cleanup(ptr noundef %63)
  br label %64

64:                                               ; preds = %62, %0
  call void @curl_global_cleanup()
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %5) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 59, ptr %2) #6
  ret i32 0
}

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

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: nounwind willreturn memory(read)
declare ptr @strrchr(ptr noundef, i32 noundef) #3

declare i32 @curl_global_init(i64 noundef) #4

declare ptr @curl_easy_init() #4

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

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

declare i32 @curl_easy_perform(ptr noundef) #4

declare i32 @curl_easy_getinfo(ptr noundef, i32 noundef, ...) #4

declare i32 @printf(ptr noundef, ...) #4

; Function Attrs: nounwind
declare ptr @ctime(ptr noundef) #5

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

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

declare void @curl_easy_cleanup(ptr noundef) #4

declare void @curl_global_cleanup() #4

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { nounwind willreturn memory(read) "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 = { "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 "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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }

!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 = !{!"long", !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, !12, i64 0}
!12 = !{!"int", !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"

@__const.main.ftpurl = external hidden unnamed_addr constant [59 x i8], align 16
@.str = external hidden unnamed_addr constant [16 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.2 = external hidden unnamed_addr constant [17 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @main() local_unnamed_addr #0 {
  %1 = alloca [59 x i8], align 16
  %2 = alloca i64, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 59, ptr nonnull %1) #7
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 16 dereferenceable(59) %1, ptr noundef nonnull align 16 dereferenceable(59) @__const.main.ftpurl, i64 59, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #7
  store i64 -1, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  store i64 0, ptr %3, align 8, !tbaa !5
  %5 = call ptr @strrchr(ptr noundef nonnull dereferenceable(1) %1, i32 noundef 47) #8
  %6 = getelementptr inbounds i8, ptr %5, i64 1
  %7 = tail call i32 @curl_global_init(i64 noundef 3) #7
  %8 = tail call ptr @curl_easy_init() #7
  %.not = icmp eq ptr %8, null
  br i1 %.not, label %36, label %9

9:                                                ; preds = %0
  %10 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %8, i32 noundef 10002, ptr noundef nonnull %1) #7
  %11 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %8, i32 noundef 44, i64 noundef 1) #7
  %12 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %8, i32 noundef 69, i64 noundef 1) #7
  %13 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %8, i32 noundef 20079, ptr noundef nonnull @throw_away) #7
  %14 = call i32 (ptr, i32, ...) @curl_easy_setopt(ptr noundef nonnull %8, i32 noundef 42, i64 noundef 0) #7
  %15 = call i32 @curl_easy_perform(ptr noundef nonnull %8) #7
  %16 = icmp eq i32 %15, 0
  br i1 %16, label %17, label %32

17:                                               ; preds = %9
  %18 = call i32 (ptr, i32, ...) @curl_easy_getinfo(ptr noundef nonnull %8, i32 noundef 2097166, ptr noundef nonnull %2) #7
  %19 = icmp eq i32 %18, 0
  %20 = load i64, ptr %2, align 8
  %21 = icmp sgt i64 %20, -1
  %or.cond = select i1 %19, i1 %21, i1 false
  br i1 %or.cond, label %22, label %25

22:                                               ; preds = %17
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %4) #7
  store i64 %20, ptr %4, align 8, !tbaa !5
  %23 = call ptr @ctime(ptr noundef nonnull %4) #7
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, ptr noundef nonnull %6, ptr noundef %23)
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %4) #7
  br label %25

25:                                               ; preds = %22, %17
  %26 = call i32 (ptr, i32, ...) @curl_easy_getinfo(ptr noundef nonnull %8, i32 noundef 6291471, ptr noundef nonnull %3) #7
  %27 = icmp eq i32 %26, 0
  %28 = load i64, ptr %3, align 8
  %29 = icmp sgt i64 %28, 0
  %or.cond3 = select i1 %27, i1 %29, i1 false
  br i1 %or.cond3, label %30, label %35

30:                                               ; preds = %25
  %31 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, ptr noundef nonnull %6, i64 noundef %28)
  br label %35

32:                                               ; preds = %9
  %33 = load ptr, ptr @stderr, align 8, !tbaa !9
  %34 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %33, ptr noundef nonnull @.str.2, i32 noundef %15) #9
  br label %35

35:                                               ; preds = %25, %30, %32
  call void @curl_easy_cleanup(ptr noundef nonnull %8) #7
  br label %36

36:                                               ; preds = %35, %0
  call void @curl_global_cleanup() #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #7
  call void @llvm.lifetime.end.p0(i64 59, ptr nonnull %1) #7
  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

; Function Attrs: mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #2

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare ptr @strrchr(ptr noundef, i32 noundef) local_unnamed_addr #3

declare i32 @curl_global_init(i64 noundef) local_unnamed_addr #4

declare ptr @curl_easy_init() local_unnamed_addr #4

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

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

declare i32 @curl_easy_perform(ptr noundef) local_unnamed_addr #4

declare i32 @curl_easy_getinfo(ptr noundef, i32 noundef, ...) local_unnamed_addr #4

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

; Function Attrs: nounwind
declare ptr @ctime(ptr noundef) local_unnamed_addr #6

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

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

declare void @curl_easy_cleanup(ptr noundef) local_unnamed_addr #4

declare void @curl_global_cleanup() local_unnamed_addr #4

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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { mustprogress nofree nounwind willreturn memory(argmem: read) "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 = { "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 = { 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 #6 = { 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 #7 = { nounwind }
attributes #8 = { nounwind willreturn memory(read) }
attributes #9 = { 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 = !{!"long", !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}


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