; LLVM IR from ihucos/plash :: pull:url (pull_url_main)

; 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 [29 x i8], align 1
@stderr = external global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@constinit = external hidden constant [3 x ptr], align 8
@.str.4 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local i32 @pull_url_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 ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca ptr, align 8
  %9 = alloca [3 x ptr], align 8
  %10 = alloca [8 x ptr], align 8
  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 8, ptr %6) #5
  %11 = load ptr, ptr %5, align 8, !tbaa !9
  %12 = getelementptr inbounds ptr, ptr %11, i64 1
  %13 = load ptr, ptr %12, align 8, !tbaa !9
  store ptr %13, ptr %6, align 8, !tbaa !9
  %14 = load ptr, ptr %6, align 8, !tbaa !9
  %15 = icmp eq ptr %14, null
  br i1 %15, label %16, label %19

16:                                               ; preds = %2
  %17 = load ptr, ptr @stderr, align 8, !tbaa !9
  %18 = call i32 @fputs(ptr noundef @.str, ptr noundef %17)
  store i32 1, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %44

19:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #5
  store ptr null, ptr %8, align 8, !tbaa !9
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %9, ptr align 8 @constinit, i64 24, i1 false), !tbaa.struct !11
  %20 = getelementptr inbounds [3 x ptr], ptr %9, i64 0, i64 0
  %21 = call ptr @pl_check_output(ptr noundef %20)
  %22 = call ptr @pl_firstline(ptr noundef %21)
  %23 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef %8, ptr noundef @.str.1, ptr noundef %22) #5
  %24 = icmp ne i32 %23, -1
  br i1 %24, label %28, label %25

25:                                               ; preds = %19
  %26 = call i32 (ptr, ...) @pl_fatal(ptr noundef @.str.4)
  %27 = icmp ne i32 %26, 0
  br label %28

28:                                               ; preds = %25, %19
  %29 = phi i1 [ true, %19 ], [ %27, %25 ]
  %30 = zext i1 %29 to i32
  store ptr @.str.5, ptr %10, align 8, !tbaa !9
  %31 = getelementptr inbounds ptr, ptr %10, i64 1
  store ptr @.str.6, ptr %31, align 8, !tbaa !9
  %32 = getelementptr inbounds ptr, ptr %10, i64 2
  store ptr @.str.7, ptr %32, align 8, !tbaa !9
  %33 = getelementptr inbounds ptr, ptr %10, i64 3
  store ptr @.str.8, ptr %33, align 8, !tbaa !9
  %34 = getelementptr inbounds ptr, ptr %10, i64 4
  store ptr @.str.9, ptr %34, align 8, !tbaa !9
  %35 = getelementptr inbounds ptr, ptr %10, i64 5
  %36 = load ptr, ptr %8, align 8, !tbaa !9
  store ptr %36, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds ptr, ptr %10, i64 6
  %38 = load ptr, ptr %6, align 8, !tbaa !9
  store ptr %38, ptr %37, align 8, !tbaa !9
  %39 = getelementptr inbounds ptr, ptr %10, i64 7
  store ptr null, ptr %39, align 8, !tbaa !9
  %40 = getelementptr inbounds [8 x ptr], ptr %10, i64 0, i64 0
  call void @_pl_run(ptr noundef %40)
  %41 = load ptr, ptr %8, align 8, !tbaa !9
  %42 = call i32 (ptr, ptr, ...) @execlp(ptr noundef @.str.2, ptr noundef @.str.10, ptr noundef @.str.11, ptr noundef %41, ptr noundef null) #5
  %43 = call i32 (ptr, ...) @pl_fatal(ptr noundef @.str.12)
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #5
  store i32 0, ptr %7, align 4
  br label %44

44:                                               ; preds = %28, %16
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #5
  %45 = load i32, ptr %7, align 4
  switch i32 %45, label %48 [
    i32 0, label %46
    i32 1, label %46
  ]

46:                                               ; preds = %44, %44
  %47 = load i32, ptr %3, align 4
  ret i32 %47

48:                                               ; preds = %44
  unreachable
}

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

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

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

declare ptr @pl_firstline(ptr noundef) #2

declare ptr @pl_check_output(ptr noundef) #2

; 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) #4

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

declare void @_pl_run(ptr noundef) #2

; Function Attrs: nounwind
declare i32 @execlp(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

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 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #5 = { 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 = !{i64 0, i64 24, !12}
!12 = !{!7, !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 [29 x i8], align 1
@stderr = external local_unnamed_addr global ptr, align 8
@.str.1 = external hidden unnamed_addr constant [10 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [15 x i8], align 1
@constinit = external hidden local_unnamed_addr constant [3 x ptr], align 8
@.str.4 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.5 = external hidden unnamed_addr constant [5 x i8], align 1
@.str.6 = external hidden unnamed_addr constant [15 x i8], align 1
@.str.7 = external hidden unnamed_addr constant [7 x i8], align 1
@.str.8 = external hidden unnamed_addr constant [11 x i8], align 1
@.str.9 = external hidden unnamed_addr constant [9 x i8], align 1
@.str.10 = external hidden unnamed_addr constant [6 x i8], align 1
@.str.11 = external hidden unnamed_addr constant [13 x i8], align 1
@.str.12 = external hidden unnamed_addr constant [7 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local noundef i32 @pull_url_main(i32 noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = alloca ptr, align 8
  %4 = alloca [3 x ptr], align 8
  %5 = alloca [8 x ptr], align 8
  %6 = getelementptr inbounds i8, ptr %1, i64 8
  %7 = load ptr, ptr %6, align 8, !tbaa !5
  %8 = icmp eq ptr %7, null
  br i1 %8, label %9, label %12

9:                                                ; preds = %2
  %10 = load ptr, ptr @stderr, align 8, !tbaa !5
  %11 = tail call i32 @fputs(ptr noundef nonnull @.str, ptr noundef %10) #6
  br label %30

12:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %3) #7
  store ptr null, ptr %3, align 8, !tbaa !5
  call void @llvm.memcpy.p0.p0.i64(ptr noundef nonnull align 8 dereferenceable(24) %4, ptr noundef nonnull align 8 dereferenceable(24) @constinit, i64 24, i1 false), !tbaa.struct !9
  %13 = call ptr @pl_check_output(ptr noundef nonnull %4) #7
  %14 = call ptr @pl_firstline(ptr noundef %13) #7
  %15 = call i32 (ptr, ptr, ...) @asprintf(ptr noundef nonnull %3, ptr noundef nonnull @.str.1, ptr noundef %14) #7
  %.not = icmp eq i32 %15, -1
  br i1 %.not, label %16, label %18

16:                                               ; preds = %12
  %17 = call i32 (ptr, ...) @pl_fatal(ptr noundef nonnull @.str.4) #7
  br label %18

18:                                               ; preds = %16, %12
  store ptr @.str.5, ptr %5, align 8, !tbaa !5
  %19 = getelementptr inbounds i8, ptr %5, i64 8
  store ptr @.str.6, ptr %19, align 8, !tbaa !5
  %20 = getelementptr inbounds i8, ptr %5, i64 16
  store ptr @.str.7, ptr %20, align 8, !tbaa !5
  %21 = getelementptr inbounds i8, ptr %5, i64 24
  store ptr @.str.8, ptr %21, align 8, !tbaa !5
  %22 = getelementptr inbounds i8, ptr %5, i64 32
  store ptr @.str.9, ptr %22, align 8, !tbaa !5
  %23 = getelementptr inbounds i8, ptr %5, i64 40
  %24 = load ptr, ptr %3, align 8, !tbaa !5
  store ptr %24, ptr %23, align 8, !tbaa !5
  %25 = getelementptr inbounds i8, ptr %5, i64 48
  store ptr %7, ptr %25, align 8, !tbaa !5
  %26 = getelementptr inbounds i8, ptr %5, i64 56
  store ptr null, ptr %26, align 8, !tbaa !5
  call void @_pl_run(ptr noundef nonnull %5) #7
  %27 = load ptr, ptr %3, align 8, !tbaa !5
  %28 = call i32 (ptr, ptr, ...) @execlp(ptr noundef nonnull @.str.2, ptr noundef nonnull @.str.10, ptr noundef nonnull @.str.11, ptr noundef %27, ptr noundef null) #7
  %29 = call i32 (ptr, ...) @pl_fatal(ptr noundef nonnull @.str.12) #7
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %3) #7
  br label %30

30:                                               ; preds = %18, %9
  ret i32 1
}

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

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

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

declare ptr @pl_firstline(ptr noundef) local_unnamed_addr #4

declare ptr @pl_check_output(ptr noundef) local_unnamed_addr #4

; 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) #5

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

declare void @_pl_run(ptr noundef) local_unnamed_addr #4

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

; Function Attrs: mustprogress 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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 "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 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #6 = { cold }
attributes #7 = { 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 = !{i64 0, i64 24, !10}
!10 = !{!7, !7, i64 0}


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