; LLVM IR from buaazp/zimg :: deps/libevhtp (evhtp)

; 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.evhtp_connection_s = type { ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, ptr, %struct.timeval, %struct.timeval, i32, i8, i8, i8, ptr, i64, i64, i64, i32, i8, i8, ptr, %struct.anon.0 }
%struct.timeval = type { i64, i64 }
%struct.anon.0 = type { ptr, ptr }
%struct.evhtp_s = type { ptr, ptr, ptr, ptr, ptr, i32, i64, i64, i32, ptr, ptr, ptr, ptr, ptr, %struct.evhtp_defaults_s, %struct.timeval, %struct.timeval, %struct.anon.2, %struct.anon.3, %struct.anon.4 }
%struct.evhtp_defaults_s = type { ptr, ptr, ptr, ptr, ptr, ptr }
%struct.anon.2 = type { ptr, ptr }
%struct.anon.3 = type { ptr, ptr }
%struct.anon.4 = type { ptr, ptr }

; Function Attrs: nounwind uwtable
define dso_local void @evhtp_connection_set_max_body_size(ptr noundef %0, i64 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i64 %1, ptr %4, align 8, !tbaa !9
  %5 = load i64, ptr %4, align 8, !tbaa !9
  %6 = icmp eq i64 %5, 0
  br i1 %6, label %7, label %15

7:                                                ; preds = %2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = getelementptr inbounds %struct.evhtp_connection_s, ptr %8, i32 0, i32 0
  %10 = load ptr, ptr %9, align 8, !tbaa !11
  %11 = getelementptr inbounds %struct.evhtp_s, ptr %10, i32 0, i32 6
  %12 = load i64, ptr %11, align 8, !tbaa !16
  %13 = load ptr, ptr %3, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.evhtp_connection_s, ptr %13, i32 0, i32 16
  store i64 %12, ptr %14, align 8, !tbaa !19
  br label %19

15:                                               ; preds = %2
  %16 = load i64, ptr %4, align 8, !tbaa !9
  %17 = load ptr, ptr %3, align 8, !tbaa !5
  %18 = getelementptr inbounds %struct.evhtp_connection_s, ptr %17, i32 0, i32 16
  store i64 %16, ptr %18, align 8, !tbaa !19
  br label %19

19:                                               ; preds = %15, %7
  ret void
}

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

!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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !6, i64 0}
!12 = !{!"evhtp_connection_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40, !6, i64 48, !6, i64 56, !6, i64 64, !13, i64 72, !13, i64 88, !14, i64 104, !7, i64 108, !7, i64 109, !7, i64 110, !6, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !14, i64 144, !7, i64 148, !7, i64 149, !6, i64 152, !15, i64 160}
!13 = !{!"timeval", !10, i64 0, !10, i64 8}
!14 = !{!"int", !7, i64 0}
!15 = !{!"", !6, i64 0, !6, i64 8}
!16 = !{!17, !10, i64 48}
!17 = !{!"evhtp_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !14, i64 40, !10, i64 48, !10, i64 56, !14, i64 64, !6, i64 72, !6, i64 80, !6, i64 88, !6, i64 96, !6, i64 104, !18, i64 112, !13, i64 160, !13, i64 176, !15, i64 192, !15, i64 208, !15, i64 224}
!18 = !{!"evhtp_defaults_s", !6, i64 0, !6, i64 8, !6, i64 16, !6, i64 24, !6, i64 32, !6, i64 40}
!19 = !{!12, !10, i64 120}


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

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) uwtable
define dso_local void @evhtp_connection_set_max_body_size(ptr nocapture noundef %0, i64 noundef %1) local_unnamed_addr #0 {
  %3 = icmp eq i64 %1, 0
  br i1 %3, label %4, label %8

4:                                                ; preds = %2
  %5 = load ptr, ptr %0, align 8, !tbaa !5
  %6 = getelementptr inbounds i8, ptr %5, i64 48
  %7 = load i64, ptr %6, align 8, !tbaa !14
  br label %8

8:                                                ; preds = %2, %4
  %.sink = phi i64 [ %7, %4 ], [ %1, %2 ]
  %9 = getelementptr inbounds i8, ptr %0, i64 120
  store i64 %.sink, ptr %9, align 8
  ret void
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(read, argmem: readwrite, inaccessiblemem: none) 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" }

!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 = !{!"evhtp_connection_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40, !7, i64 48, !7, i64 56, !7, i64 64, !10, i64 72, !10, i64 88, !12, i64 104, !8, i64 108, !8, i64 109, !8, i64 110, !7, i64 112, !11, i64 120, !11, i64 128, !11, i64 136, !12, i64 144, !8, i64 148, !8, i64 149, !7, i64 152, !13, i64 160}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"timeval", !11, i64 0, !11, i64 8}
!11 = !{!"long", !8, i64 0}
!12 = !{!"int", !8, i64 0}
!13 = !{!"", !7, i64 0, !7, i64 8}
!14 = !{!15, !11, i64 48}
!15 = !{!"evhtp_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !12, i64 40, !11, i64 48, !11, i64 56, !12, i64 64, !7, i64 72, !7, i64 80, !7, i64 88, !7, i64 96, !7, i64 104, !16, i64 112, !10, i64 160, !10, i64 176, !13, i64 192, !13, i64 208, !13, i64 224}
!16 = !{!"evhtp_defaults_s", !7, i64 0, !7, i64 8, !7, i64 16, !7, i64 24, !7, i64 32, !7, i64 40}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,InstCombinePass,JumpThreadingPass,MergedLoadStoreMotionPass,PostOrderFunctionAttrsPass,SROAPass