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

; 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.http_parser_url = type { i16, i16, [7 x %struct.anon] }
%struct.anon = type { i16, i16 }

@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: nounwind uwtable
define dso_local void @dump_url(ptr noundef %0, ptr noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store ptr %1, ptr %4, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %6 = load ptr, ptr %4, align 8, !tbaa !5
  %7 = getelementptr inbounds %struct.http_parser_url, ptr %6, i32 0, i32 0
  %8 = load i16, ptr %7, align 2, !tbaa !9
  %9 = zext i16 %8 to i32
  %10 = load ptr, ptr %4, align 8, !tbaa !5
  %11 = getelementptr inbounds %struct.http_parser_url, ptr %10, i32 0, i32 1
  %12 = load i16, ptr %11, align 2, !tbaa !12
  %13 = zext i16 %12 to i32
  %14 = call i32 (ptr, ...) @printf(ptr noundef @.str, i32 noundef %9, i32 noundef %13)
  store i32 0, ptr %5, align 4, !tbaa !13
  br label %15

15:                                               ; preds = %68, %2
  %16 = load i32, ptr %5, align 4, !tbaa !13
  %17 = icmp ult i32 %16, 7
  br i1 %17, label %18, label %71

18:                                               ; preds = %15
  %19 = load ptr, ptr %4, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.http_parser_url, ptr %19, i32 0, i32 0
  %21 = load i16, ptr %20, align 2, !tbaa !9
  %22 = zext i16 %21 to i32
  %23 = load i32, ptr %5, align 4, !tbaa !13
  %24 = shl i32 1, %23
  %25 = and i32 %22, %24
  %26 = icmp eq i32 %25, 0
  br i1 %26, label %27, label %30

27:                                               ; preds = %18
  %28 = load i32, ptr %5, align 4, !tbaa !13
  %29 = call i32 (ptr, ...) @printf(ptr noundef @.str.1, i32 noundef %28)
  br label %68

30:                                               ; preds = %18
  %31 = load i32, ptr %5, align 4, !tbaa !13
  %32 = load ptr, ptr %4, align 8, !tbaa !5
  %33 = getelementptr inbounds %struct.http_parser_url, ptr %32, i32 0, i32 2
  %34 = load i32, ptr %5, align 4, !tbaa !13
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds [7 x %struct.anon], ptr %33, i64 0, i64 %35
  %37 = getelementptr inbounds %struct.anon, ptr %36, i32 0, i32 0
  %38 = load i16, ptr %37, align 2, !tbaa !15
  %39 = zext i16 %38 to i32
  %40 = load ptr, ptr %4, align 8, !tbaa !5
  %41 = getelementptr inbounds %struct.http_parser_url, ptr %40, i32 0, i32 2
  %42 = load i32, ptr %5, align 4, !tbaa !13
  %43 = zext i32 %42 to i64
  %44 = getelementptr inbounds [7 x %struct.anon], ptr %41, i64 0, i64 %43
  %45 = getelementptr inbounds %struct.anon, ptr %44, i32 0, i32 1
  %46 = load i16, ptr %45, align 2, !tbaa !17
  %47 = zext i16 %46 to i32
  %48 = load ptr, ptr %4, align 8, !tbaa !5
  %49 = getelementptr inbounds %struct.http_parser_url, ptr %48, i32 0, i32 2
  %50 = load i32, ptr %5, align 4, !tbaa !13
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds [7 x %struct.anon], ptr %49, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.anon, ptr %52, i32 0, i32 1
  %54 = load i16, ptr %53, align 2, !tbaa !17
  %55 = zext i16 %54 to i32
  %56 = load ptr, ptr %3, align 8, !tbaa !5
  %57 = load ptr, ptr %4, align 8, !tbaa !5
  %58 = getelementptr inbounds %struct.http_parser_url, ptr %57, i32 0, i32 2
  %59 = load i32, ptr %5, align 4, !tbaa !13
  %60 = zext i32 %59 to i64
  %61 = getelementptr inbounds [7 x %struct.anon], ptr %58, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.anon, ptr %61, i32 0, i32 0
  %63 = load i16, ptr %62, align 2, !tbaa !15
  %64 = zext i16 %63 to i32
  %65 = sext i32 %64 to i64
  %66 = getelementptr inbounds i8, ptr %56, i64 %65
  %67 = call i32 (ptr, ...) @printf(ptr noundef @.str.2, i32 noundef %31, i32 noundef %39, i32 noundef %47, i32 noundef %55, ptr noundef %66)
  br label %68

68:                                               ; preds = %30, %27
  %69 = load i32, ptr %5, align 4, !tbaa !13
  %70 = add i32 %69, 1
  store i32 %70, ptr %5, align 4, !tbaa !13
  br label %15, !llvm.loop !18

71:                                               ; preds = %15
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  ret void
}

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

declare i32 @printf(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 }

!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 = !{!10, !11, i64 0}
!10 = !{!"http_parser_url", !11, i64 0, !11, i64 2, !7, i64 4}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !11, i64 2}
!13 = !{!14, !14, i64 0}
!14 = !{!"int", !7, i64 0}
!15 = !{!16, !11, i64 0}
!16 = !{!"", !11, i64 0, !11, i64 2}
!17 = !{!16, !11, i64 2}
!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"

@.str = external hidden unnamed_addr constant [28 x i8], align 1
@.str.1 = external hidden unnamed_addr constant [24 x i8], align 1
@.str.2 = external hidden unnamed_addr constant [47 x i8], align 1

; Function Attrs: nofree nounwind uwtable
define dso_local void @dump_url(ptr noundef %0, ptr nocapture noundef readonly %1) local_unnamed_addr #0 {
  %3 = load i16, ptr %1, align 2, !tbaa !5
  %4 = zext i16 %3 to i32
  %5 = getelementptr inbounds i8, ptr %1, i64 2
  %6 = load i16, ptr %5, align 2, !tbaa !10
  %7 = zext i16 %6 to i32
  %8 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str, i32 noundef %4, i32 noundef %7)
  %9 = load i16, ptr %1, align 2, !tbaa !5
  %10 = and i16 %9, 1
  %11 = icmp eq i16 %10, 0
  br i1 %11, label %12, label %14

12:                                               ; preds = %2
  %13 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 0)
  br label %24

14:                                               ; preds = %2
  %15 = getelementptr inbounds i8, ptr %1, i64 4
  %16 = load i16, ptr %15, align 2, !tbaa !11
  %17 = zext i16 %16 to i32
  %18 = getelementptr inbounds i8, ptr %1, i64 6
  %19 = load i16, ptr %18, align 2, !tbaa !13
  %20 = zext i16 %19 to i32
  %21 = zext i16 %16 to i64
  %22 = getelementptr inbounds i8, ptr %0, i64 %21
  %23 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 0, i32 noundef %17, i32 noundef %20, i32 noundef %20, ptr noundef %22)
  br label %24

24:                                               ; preds = %14, %12
  %25 = load i16, ptr %1, align 2, !tbaa !5
  %26 = and i16 %25, 2
  %27 = icmp eq i16 %26, 0
  br i1 %27, label %38, label %28

28:                                               ; preds = %24
  %29 = getelementptr inbounds i8, ptr %1, i64 8
  %30 = load i16, ptr %29, align 2, !tbaa !11
  %31 = zext i16 %30 to i32
  %32 = getelementptr inbounds i8, ptr %1, i64 10
  %33 = load i16, ptr %32, align 2, !tbaa !13
  %34 = zext i16 %33 to i32
  %35 = zext i16 %30 to i64
  %36 = getelementptr inbounds i8, ptr %0, i64 %35
  %37 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 1, i32 noundef %31, i32 noundef %34, i32 noundef %34, ptr noundef %36)
  br label %40

38:                                               ; preds = %24
  %39 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 1)
  br label %40

40:                                               ; preds = %38, %28
  %41 = load i16, ptr %1, align 2, !tbaa !5
  %42 = and i16 %41, 4
  %43 = icmp eq i16 %42, 0
  br i1 %43, label %54, label %44

44:                                               ; preds = %40
  %45 = getelementptr inbounds i8, ptr %1, i64 12
  %46 = load i16, ptr %45, align 2, !tbaa !11
  %47 = zext i16 %46 to i32
  %48 = getelementptr inbounds i8, ptr %1, i64 14
  %49 = load i16, ptr %48, align 2, !tbaa !13
  %50 = zext i16 %49 to i32
  %51 = zext i16 %46 to i64
  %52 = getelementptr inbounds i8, ptr %0, i64 %51
  %53 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 2, i32 noundef %47, i32 noundef %50, i32 noundef %50, ptr noundef %52)
  br label %56

54:                                               ; preds = %40
  %55 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 2)
  br label %56

56:                                               ; preds = %54, %44
  %57 = load i16, ptr %1, align 2, !tbaa !5
  %58 = and i16 %57, 8
  %59 = icmp eq i16 %58, 0
  br i1 %59, label %70, label %60

60:                                               ; preds = %56
  %61 = getelementptr inbounds i8, ptr %1, i64 16
  %62 = load i16, ptr %61, align 2, !tbaa !11
  %63 = zext i16 %62 to i32
  %64 = getelementptr inbounds i8, ptr %1, i64 18
  %65 = load i16, ptr %64, align 2, !tbaa !13
  %66 = zext i16 %65 to i32
  %67 = zext i16 %62 to i64
  %68 = getelementptr inbounds i8, ptr %0, i64 %67
  %69 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 3, i32 noundef %63, i32 noundef %66, i32 noundef %66, ptr noundef %68)
  br label %72

70:                                               ; preds = %56
  %71 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 3)
  br label %72

72:                                               ; preds = %70, %60
  %73 = load i16, ptr %1, align 2, !tbaa !5
  %74 = and i16 %73, 16
  %75 = icmp eq i16 %74, 0
  br i1 %75, label %86, label %76

76:                                               ; preds = %72
  %77 = getelementptr inbounds i8, ptr %1, i64 20
  %78 = load i16, ptr %77, align 2, !tbaa !11
  %79 = zext i16 %78 to i32
  %80 = getelementptr inbounds i8, ptr %1, i64 22
  %81 = load i16, ptr %80, align 2, !tbaa !13
  %82 = zext i16 %81 to i32
  %83 = zext i16 %78 to i64
  %84 = getelementptr inbounds i8, ptr %0, i64 %83
  %85 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 4, i32 noundef %79, i32 noundef %82, i32 noundef %82, ptr noundef %84)
  br label %88

86:                                               ; preds = %72
  %87 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 4)
  br label %88

88:                                               ; preds = %86, %76
  %89 = load i16, ptr %1, align 2, !tbaa !5
  %90 = and i16 %89, 32
  %91 = icmp eq i16 %90, 0
  br i1 %91, label %102, label %92

92:                                               ; preds = %88
  %93 = getelementptr inbounds i8, ptr %1, i64 24
  %94 = load i16, ptr %93, align 2, !tbaa !11
  %95 = zext i16 %94 to i32
  %96 = getelementptr inbounds i8, ptr %1, i64 26
  %97 = load i16, ptr %96, align 2, !tbaa !13
  %98 = zext i16 %97 to i32
  %99 = zext i16 %94 to i64
  %100 = getelementptr inbounds i8, ptr %0, i64 %99
  %101 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 5, i32 noundef %95, i32 noundef %98, i32 noundef %98, ptr noundef %100)
  br label %104

102:                                              ; preds = %88
  %103 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 5)
  br label %104

104:                                              ; preds = %102, %92
  %105 = load i16, ptr %1, align 2, !tbaa !5
  %106 = and i16 %105, 64
  %107 = icmp eq i16 %106, 0
  br i1 %107, label %118, label %108

108:                                              ; preds = %104
  %109 = getelementptr inbounds i8, ptr %1, i64 28
  %110 = load i16, ptr %109, align 2, !tbaa !11
  %111 = zext i16 %110 to i32
  %112 = getelementptr inbounds i8, ptr %1, i64 30
  %113 = load i16, ptr %112, align 2, !tbaa !13
  %114 = zext i16 %113 to i32
  %115 = zext i16 %110 to i64
  %116 = getelementptr inbounds i8, ptr %0, i64 %115
  %117 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.2, i32 noundef 6, i32 noundef %111, i32 noundef %114, i32 noundef %114, ptr noundef %116)
  br label %120

118:                                              ; preds = %104
  %119 = tail call i32 (ptr, ...) @printf(ptr noundef nonnull dereferenceable(1) @.str.1, i32 noundef 6)
  br label %120

120:                                              ; preds = %118, %108
  ret void
}

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

attributes #0 = { nofree 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 = { 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" }

!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 0}
!6 = !{!"http_parser_url", !7, i64 0, !7, i64 2, !8, i64 4}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!6, !7, i64 2}
!11 = !{!12, !7, i64 0}
!12 = !{!"", !7, i64 0, !7, i64 2}
!13 = !{!12, !7, i64 2}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LICMPass,LoopRotatePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,TailCallElimPass