; LLVM IR from gulrak/filesystem :: test (impl_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"

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3ghc10filesystem6detail10appendUTF8ERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1) #0 {
  %3 = alloca ptr, align 8
  %4 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  store i32 %1, ptr %4, align 4, !tbaa !9
  %5 = load i32, ptr %4, align 4, !tbaa !9
  %6 = icmp ule i32 %5, 127
  br i1 %6, label %7, label %11

7:                                                ; preds = %2
  %8 = load ptr, ptr %3, align 8, !tbaa !5
  %9 = load i32, ptr %4, align 4, !tbaa !9
  %10 = trunc i32 %9 to i8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %8, i8 noundef signext %10)
  br label %91

11:                                               ; preds = %2
  %12 = load i32, ptr %4, align 4, !tbaa !9
  %13 = icmp uge i32 %12, 128
  br i1 %13, label %14, label %28

14:                                               ; preds = %11
  %15 = load i32, ptr %4, align 4, !tbaa !9
  %16 = icmp ule i32 %15, 2047
  br i1 %16, label %17, label %28

17:                                               ; preds = %14
  %18 = load ptr, ptr %3, align 8, !tbaa !5
  %19 = load i32, ptr %4, align 4, !tbaa !9
  %20 = lshr i32 %19, 6
  %21 = add i32 %20, 192
  %22 = trunc i32 %21 to i8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %18, i8 noundef signext %22)
  %23 = load ptr, ptr %3, align 8, !tbaa !5
  %24 = load i32, ptr %4, align 4, !tbaa !9
  %25 = and i32 %24, 63
  %26 = add i32 %25, 128
  %27 = trunc i32 %26 to i8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %23, i8 noundef signext %27)
  br label %90

28:                                               ; preds = %14, %11
  %29 = load i32, ptr %4, align 4, !tbaa !9
  %30 = icmp uge i32 %29, 2048
  br i1 %30, label %31, label %34

31:                                               ; preds = %28
  %32 = load i32, ptr %4, align 4, !tbaa !9
  %33 = icmp ule i32 %32, 55295
  br i1 %33, label %40, label %34

34:                                               ; preds = %31, %28
  %35 = load i32, ptr %4, align 4, !tbaa !9
  %36 = icmp uge i32 %35, 57344
  br i1 %36, label %37, label %57

37:                                               ; preds = %34
  %38 = load i32, ptr %4, align 4, !tbaa !9
  %39 = icmp ule i32 %38, 65535
  br i1 %39, label %40, label %57

40:                                               ; preds = %37, %31
  %41 = load ptr, ptr %3, align 8, !tbaa !5
  %42 = load i32, ptr %4, align 4, !tbaa !9
  %43 = lshr i32 %42, 12
  %44 = add i32 %43, 224
  %45 = trunc i32 %44 to i8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %41, i8 noundef signext %45)
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = load i32, ptr %4, align 4, !tbaa !9
  %48 = and i32 %47, 4095
  %49 = lshr i32 %48, 6
  %50 = add i32 %49, 128
  %51 = trunc i32 %50 to i8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %46, i8 noundef signext %51)
  %52 = load ptr, ptr %3, align 8, !tbaa !5
  %53 = load i32, ptr %4, align 4, !tbaa !9
  %54 = and i32 %53, 63
  %55 = add i32 %54, 128
  %56 = trunc i32 %55 to i8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %52, i8 noundef signext %56)
  br label %89

57:                                               ; preds = %37, %34
  %58 = load i32, ptr %4, align 4, !tbaa !9
  %59 = icmp uge i32 %58, 65536
  br i1 %59, label %60, label %86

60:                                               ; preds = %57
  %61 = load i32, ptr %4, align 4, !tbaa !9
  %62 = icmp ule i32 %61, 1114111
  br i1 %62, label %63, label %86

63:                                               ; preds = %60
  %64 = load ptr, ptr %3, align 8, !tbaa !5
  %65 = load i32, ptr %4, align 4, !tbaa !9
  %66 = lshr i32 %65, 18
  %67 = add i32 %66, 240
  %68 = trunc i32 %67 to i8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %64, i8 noundef signext %68)
  %69 = load ptr, ptr %3, align 8, !tbaa !5
  %70 = load i32, ptr %4, align 4, !tbaa !9
  %71 = and i32 %70, 262143
  %72 = lshr i32 %71, 12
  %73 = add i32 %72, 128
  %74 = trunc i32 %73 to i8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %69, i8 noundef signext %74)
  %75 = load ptr, ptr %3, align 8, !tbaa !5
  %76 = load i32, ptr %4, align 4, !tbaa !9
  %77 = and i32 %76, 4095
  %78 = lshr i32 %77, 6
  %79 = add i32 %78, 128
  %80 = trunc i32 %79 to i8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %75, i8 noundef signext %80)
  %81 = load ptr, ptr %3, align 8, !tbaa !5
  %82 = load i32, ptr %4, align 4, !tbaa !9
  %83 = and i32 %82, 63
  %84 = add i32 %83, 128
  %85 = trunc i32 %84 to i8
  call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %81, i8 noundef signext %85)
  br label %88

86:                                               ; preds = %60, %57
  %87 = load ptr, ptr %3, align 8, !tbaa !5
  call void @_ZN3ghc10filesystem6detail10appendUTF8ERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj(ptr noundef nonnull align 8 dereferenceable(32) %87, i32 noundef 65533)
  br label %88

88:                                               ; preds = %86, %63
  br label %89

89:                                               ; preds = %88, %40
  br label %90

90:                                               ; preds = %89, %17
  br label %91

91:                                               ; preds = %90, %7
  ret void
}

; Function Attrs: mustprogress uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) #0 align 2

attributes #0 = { mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"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"

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3ghc10filesystem6detail10appendUTF8ERNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj(ptr noundef nonnull align 8 dereferenceable(32) %0, i32 noundef %1) local_unnamed_addr #0 {
  %3 = icmp ult i32 %1, 128
  br i1 %3, label %4, label %6

4:                                                ; preds = %2
  %5 = trunc nuw nsw i32 %1 to i8
  br label %47

6:                                                ; preds = %2
  %7 = icmp ult i32 %1, 2048
  br i1 %7, label %8, label %15

8:                                                ; preds = %6
  %9 = lshr i32 %1, 6
  %10 = trunc nuw i32 %9 to i8
  %11 = or disjoint i8 %10, -64
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext %11)
  %12 = trunc i32 %1 to i8
  %13 = and i8 %12, 63
  %14 = or disjoint i8 %13, -128
  br label %47

15:                                               ; preds = %6
  %16 = icmp ult i32 %1, 55296
  %17 = and i32 %1, -8192
  %or.cond5 = icmp eq i32 %17, 57344
  %or.cond = or i1 %16, %or.cond5
  br i1 %or.cond, label %18, label %29

18:                                               ; preds = %15
  %19 = lshr i32 %1, 12
  %20 = trunc nuw i32 %19 to i8
  %21 = or disjoint i8 %20, -32
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext %21)
  %22 = lshr i32 %1, 6
  %23 = trunc i32 %22 to i8
  %24 = and i8 %23, 63
  %25 = or disjoint i8 %24, -128
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext %25)
  %26 = trunc i32 %1 to i8
  %27 = and i8 %26, 63
  %28 = or disjoint i8 %27, -128
  br label %47

29:                                               ; preds = %15
  %30 = add i32 %1, -65536
  %or.cond7 = icmp ult i32 %30, 1048576
  br i1 %or.cond7, label %31, label %46

31:                                               ; preds = %29
  %32 = lshr i32 %1, 18
  %33 = trunc nuw i32 %32 to i8
  %34 = or disjoint i8 %33, -16
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext %34)
  %35 = lshr i32 %1, 12
  %36 = trunc i32 %35 to i8
  %37 = and i8 %36, 63
  %38 = or disjoint i8 %37, -128
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext %38)
  %39 = lshr i32 %1, 6
  %40 = trunc i32 %39 to i8
  %41 = and i8 %40, 63
  %42 = or disjoint i8 %41, -128
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext %42)
  %43 = trunc i32 %1 to i8
  %44 = and i8 %43, 63
  %45 = or disjoint i8 %44, -128
  br label %47

46:                                               ; preds = %29
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext -17)
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext -65)
  br label %47

47:                                               ; preds = %8, %31, %46, %18, %4
  %.sink = phi i8 [ %14, %8 ], [ %45, %31 ], [ -67, %46 ], [ %28, %18 ], [ %5, %4 ]
  tail call void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32) %0, i8 noundef signext %.sink)
  ret void
}

; Function Attrs: mustprogress uwtable
declare void @_ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE9push_backEc(ptr noundef nonnull align 8 dereferenceable(32), i8 noundef signext) local_unnamed_addr #0 align 2

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


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InlinerPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass