; LLVM IR from apigee/apib :: third_party/http_parser (test)

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

%struct.url_test = type { ptr, ptr, i32, %struct.http_parser_url, i32 }
%struct.http_parser_url = type { i16, i16, [7 x %struct.anon] }
%struct.anon = type { i16, i16 }

@url_tests = external dso_local constant [46 x %struct.url_test], align 16
@.str.292 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.293 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.294 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.295 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @abort() #1

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #2

declare i32 @http_parser_parse_url(ptr noundef, i64 noundef, i32 noundef, ptr noundef) #3

; Function Attrs: nounwind willreturn memory(read)
declare i64 @strlen(ptr noundef) #4

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

; Function Attrs: nounwind uwtable
declare dso_local void @dump_url(ptr noundef, ptr noundef) #5

; Function Attrs: nounwind uwtable
define dso_local void @test_parse_url() #5 {
  %1 = alloca %struct.http_parser_url, align 2
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  call void @llvm.lifetime.start.p0(i64 32, ptr %1) #6
  call void @llvm.lifetime.start.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #6
  store i32 0, ptr %3, align 4, !tbaa !5
  br label %5

5:                                                ; preds = %86, %0
  %6 = load i32, ptr %3, align 4, !tbaa !5
  %7 = zext i32 %6 to i64
  %8 = icmp ult i64 %7, 46
  br i1 %8, label %9, label %89

9:                                                ; preds = %5
  %10 = load i32, ptr %3, align 4, !tbaa !5
  %11 = zext i32 %10 to i64
  %12 = getelementptr inbounds [46 x %struct.url_test], ptr @url_tests, i64 0, i64 %11
  store ptr %12, ptr %2, align 8, !tbaa !9
  call void @llvm.memset.p0.i64(ptr align 2 %1, i8 0, i64 32, i1 false)
  %13 = load ptr, ptr %2, align 8, !tbaa !9
  %14 = getelementptr inbounds %struct.url_test, ptr %13, i32 0, i32 1
  %15 = load ptr, ptr %14, align 8, !tbaa !11
  %16 = load ptr, ptr %2, align 8, !tbaa !9
  %17 = getelementptr inbounds %struct.url_test, ptr %16, i32 0, i32 1
  %18 = load ptr, ptr %17, align 8, !tbaa !11
  %19 = icmp ne ptr %18, null
  br i1 %19, label %20, label %25

20:                                               ; preds = %9
  %21 = load ptr, ptr %2, align 8, !tbaa !9
  %22 = getelementptr inbounds %struct.url_test, ptr %21, i32 0, i32 1
  %23 = load ptr, ptr %22, align 8, !tbaa !11
  %24 = call i64 @strlen(ptr noundef %23) #7
  br label %26

25:                                               ; preds = %9
  br label %26

26:                                               ; preds = %25, %20
  %27 = phi i64 [ %24, %20 ], [ 0, %25 ]
  %28 = load ptr, ptr %2, align 8, !tbaa !9
  %29 = getelementptr inbounds %struct.url_test, ptr %28, i32 0, i32 2
  %30 = load i32, ptr %29, align 8, !tbaa !15
  %31 = call i32 @http_parser_parse_url(ptr noundef %15, i64 noundef %27, i32 noundef %30, ptr noundef %1)
  store i32 %31, ptr %4, align 4, !tbaa !5
  %32 = load ptr, ptr %2, align 8, !tbaa !9
  %33 = getelementptr inbounds %struct.url_test, ptr %32, i32 0, i32 4
  %34 = load i32, ptr %33, align 4, !tbaa !16
  %35 = icmp eq i32 %34, 0
  br i1 %35, label %36, label %72

36:                                               ; preds = %26
  %37 = load i32, ptr %4, align 4, !tbaa !5
  %38 = icmp ne i32 %37, 0
  br i1 %38, label %39, label %48

39:                                               ; preds = %36
  %40 = load ptr, ptr %2, align 8, !tbaa !9
  %41 = getelementptr inbounds %struct.url_test, ptr %40, i32 0, i32 1
  %42 = load ptr, ptr %41, align 8, !tbaa !11
  %43 = load ptr, ptr %2, align 8, !tbaa !9
  %44 = getelementptr inbounds %struct.url_test, ptr %43, i32 0, i32 0
  %45 = load ptr, ptr %44, align 8, !tbaa !17
  %46 = load i32, ptr %4, align 4, !tbaa !5
  %47 = call i32 (ptr, ...) @printf(ptr noundef @.str.292, ptr noundef %42, ptr noundef %45, i32 noundef %46)
  call void @abort() #8
  unreachable

48:                                               ; preds = %36
  %49 = load ptr, ptr %2, align 8, !tbaa !9
  %50 = getelementptr inbounds %struct.url_test, ptr %49, i32 0, i32 3
  %51 = call i32 @memcmp(ptr noundef %1, ptr noundef %50, i64 noundef 32) #7
  %52 = icmp ne i32 %51, 0
  br i1 %52, label %53, label %71

53:                                               ; preds = %48
  %54 = load ptr, ptr %2, align 8, !tbaa !9
  %55 = getelementptr inbounds %struct.url_test, ptr %54, i32 0, i32 1
  %56 = load ptr, ptr %55, align 8, !tbaa !11
  %57 = load ptr, ptr %2, align 8, !tbaa !9
  %58 = getelementptr inbounds %struct.url_test, ptr %57, i32 0, i32 0
  %59 = load ptr, ptr %58, align 8, !tbaa !17
  %60 = call i32 (ptr, ...) @printf(ptr noundef @.str.293, ptr noundef %56, ptr noundef %59)
  %61 = call i32 (ptr, ...) @printf(ptr noundef @.str.294)
  %62 = load ptr, ptr %2, align 8, !tbaa !9
  %63 = getelementptr inbounds %struct.url_test, ptr %62, i32 0, i32 1
  %64 = load ptr, ptr %63, align 8, !tbaa !11
  %65 = load ptr, ptr %2, align 8, !tbaa !9
  %66 = getelementptr inbounds %struct.url_test, ptr %65, i32 0, i32 3
  call void @dump_url(ptr noundef %64, ptr noundef %66)
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.295)
  %68 = load ptr, ptr %2, align 8, !tbaa !9
  %69 = getelementptr inbounds %struct.url_test, ptr %68, i32 0, i32 1
  %70 = load ptr, ptr %69, align 8, !tbaa !11
  call void @dump_url(ptr noundef %70, ptr noundef %1)
  call void @abort() #8
  unreachable

71:                                               ; preds = %48
  br label %85

72:                                               ; preds = %26
  %73 = load i32, ptr %4, align 4, !tbaa !5
  %74 = icmp eq i32 %73, 0
  br i1 %74, label %75, label %84

75:                                               ; preds = %72
  %76 = load ptr, ptr %2, align 8, !tbaa !9
  %77 = getelementptr inbounds %struct.url_test, ptr %76, i32 0, i32 1
  %78 = load ptr, ptr %77, align 8, !tbaa !11
  %79 = load ptr, ptr %2, align 8, !tbaa !9
  %80 = getelementptr inbounds %struct.url_test, ptr %79, i32 0, i32 0
  %81 = load ptr, ptr %80, align 8, !tbaa !17
  %82 = load i32, ptr %4, align 4, !tbaa !5
  %83 = call i32 (ptr, ...) @printf(ptr noundef @.str.292, ptr noundef %78, ptr noundef %81, i32 noundef %82)
  call void @abort() #8
  unreachable

84:                                               ; preds = %72
  br label %85

85:                                               ; preds = %84, %71
  br label %86

86:                                               ; preds = %85
  %87 = load i32, ptr %3, align 4, !tbaa !5
  %88 = add i32 %87, 1
  store i32 %88, ptr %3, align 4, !tbaa !5
  br label %5, !llvm.loop !18

89:                                               ; preds = %5
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #6
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #6
  call void @llvm.lifetime.end.p0(i64 8, ptr %2) #6
  call void @llvm.lifetime.end.p0(i64 32, ptr %1) #6
  ret void
}

; Function Attrs: nounwind willreturn memory(read)
declare i32 @memcmp(ptr noundef, ptr noundef, i64 noundef) #4

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 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 #5 = { 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 #6 = { nounwind }
attributes #7 = { nounwind willreturn memory(read) }
attributes #8 = { noreturn 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 = !{!12, !10, i64 8}
!12 = !{!"url_test", !10, i64 0, !10, i64 8, !6, i64 16, !13, i64 20, !6, i64 52}
!13 = !{!"http_parser_url", !14, i64 0, !14, i64 2, !7, i64 4}
!14 = !{!"short", !7, i64 0}
!15 = !{!12, !6, i64 16}
!16 = !{!12, !6, i64 52}
!17 = !{!12, !10, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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"

%struct.url_test = type { ptr, ptr, i32, %struct.http_parser_url, i32 }
%struct.http_parser_url = type { i16, i16, [7 x %struct.anon] }
%struct.anon = type { i16, i16 }

@url_tests = external dso_local constant [46 x %struct.url_test], align 16
@.str.292 = external hidden unnamed_addr constant [74 x i8], align 1
@.str.293 = external hidden unnamed_addr constant [50 x i8], align 1
@.str.294 = external hidden unnamed_addr constant [25 x i8], align 1
@.str.295 = external hidden unnamed_addr constant [25 x i8], align 1

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

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

; Function Attrs: noreturn nounwind
declare void @abort() local_unnamed_addr #1

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

declare i32 @http_parser_parse_url(ptr noundef, i64 noundef, i32 noundef, ptr noundef) local_unnamed_addr #3

; Function Attrs: mustprogress nofree nounwind willreturn memory(argmem: read)
declare i64 @strlen(ptr nocapture noundef) local_unnamed_addr #4

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

; Function Attrs: nounwind uwtable
declare dso_local void @dump_url(ptr noundef, ptr noundef) local_unnamed_addr #6

; Function Attrs: nounwind uwtable
define dso_local void @test_parse_url() local_unnamed_addr #6 {
  %1 = alloca %struct.http_parser_url, align 2
  call void @llvm.lifetime.start.p0(i64 32, ptr nonnull %1) #8
  br label %2

2:                                                ; preds = %0, %31
  %indvars.iv = phi i64 [ 0, %0 ], [ %indvars.iv.next, %31 ]
  %3 = getelementptr inbounds [46 x %struct.url_test], ptr @url_tests, i64 0, i64 %indvars.iv
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 2 dereferenceable(32) %1, i8 0, i64 32, i1 false)
  %4 = getelementptr inbounds i8, ptr %3, i64 8
  %5 = load ptr, ptr %4, align 8, !tbaa !5
  %.not = icmp eq ptr %5, null
  br i1 %.not, label %8, label %6

6:                                                ; preds = %2
  %7 = call i64 @strlen(ptr noundef nonnull dereferenceable(1) %5) #9
  br label %8

8:                                                ; preds = %2, %6
  %9 = phi i64 [ %7, %6 ], [ 0, %2 ]
  %10 = getelementptr inbounds i8, ptr %3, i64 16
  %11 = load i32, ptr %10, align 8, !tbaa !13
  %12 = call i32 @http_parser_parse_url(ptr noundef %5, i64 noundef %9, i32 noundef %11, ptr noundef nonnull %1) #8
  %13 = getelementptr inbounds i8, ptr %3, i64 52
  %14 = load i32, ptr %13, align 4, !tbaa !14
  %15 = icmp eq i32 %14, 0
  %.not24 = icmp eq i32 %12, 0
  br i1 %15, label %16, label %27

16:                                               ; preds = %8
  br i1 %.not24, label %20, label %17

17:                                               ; preds = %16
  %18 = load ptr, ptr %3, align 8, !tbaa !15
  %19 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.292, ptr noundef %5, ptr noundef %18, i32 noundef %12)
  call void @abort() #10
  unreachable

20:                                               ; preds = %16
  %21 = getelementptr inbounds i8, ptr %3, i64 20
  %bcmp = call i32 @bcmp(ptr noundef nonnull dereferenceable(32) %1, ptr noundef nonnull dereferenceable(32) %21, i64 32)
  %.not25 = icmp eq i32 %bcmp, 0
  br i1 %.not25, label %31, label %22

22:                                               ; preds = %20
  %23 = load ptr, ptr %3, align 8, !tbaa !15
  %24 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.293, ptr noundef %5, ptr noundef %23)
  %25 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.294)
  call void @dump_url(ptr noundef %5, ptr noundef nonnull %21)
  %26 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.295)
  call void @dump_url(ptr noundef %5, ptr noundef nonnull %1)
  call void @abort() #10
  unreachable

27:                                               ; preds = %8
  br i1 %.not24, label %28, label %31

28:                                               ; preds = %27
  %29 = load ptr, ptr %3, align 8, !tbaa !15
  %30 = call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.292, ptr noundef %5, ptr noundef %29, i32 noundef 0)
  call void @abort() #10
  unreachable

31:                                               ; preds = %20, %27
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, 46
  br i1 %exitcond.not, label %32, label %2, !llvm.loop !16

32:                                               ; preds = %31
  call void @llvm.lifetime.end.p0(i64 32, ptr nonnull %1) #8
  ret void
}

; Function Attrs: nofree nounwind willreturn memory(argmem: read)
declare i32 @bcmp(ptr nocapture, ptr nocapture, i64) local_unnamed_addr #7

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { noreturn 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 #2 = { mustprogress nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #3 = { "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 = { 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 #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 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 #7 = { nofree nounwind willreturn memory(argmem: read) }
attributes #8 = { nounwind }
attributes #9 = { nounwind willreturn memory(read) }
attributes #10 = { noreturn 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, !7, i64 8}
!6 = !{!"url_test", !7, i64 0, !7, i64 8, !10, i64 16, !11, i64 20, !10, i64 52}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!"http_parser_url", !12, i64 0, !12, i64 2, !8, i64 4}
!12 = !{!"short", !8, i64 0}
!13 = !{!6, !10, i64 16}
!14 = !{!6, !10, i64 52}
!15 = !{!6, !7, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,LCSSAPass,LoopRotatePass,LoopUnrollPass,SROAPass,SimplifyCFGPass