; LLVM IR from aap/pdp6 :: fe6 (fe)

; 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.Assembler = type { [4 x i64], i32, i64, i32, i32 }

@as = external dso_local global %struct.Assembler, align 8

; 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: nounwind uwtable
declare dso_local i32 @parse(ptr noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @resetexp() #1

; Function Attrs: nounwind uwtable
declare dso_local void @combine(i64 noundef) #1

; Function Attrs: nounwind uwtable
define dso_local i32 @endword(ptr noundef %0) #1 {
  %2 = alloca i32, align 4
  %3 = alloca ptr, align 8
  %4 = alloca i64, align 8
  %5 = alloca i32, align 4
  store ptr %0, ptr %3, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  %6 = call i32 @parse(ptr noundef %4)
  %7 = icmp ne i32 %6, 0
  br i1 %7, label %13, label %8

8:                                                ; preds = %1
  %9 = load i32, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 4), align 4, !tbaa !9
  %10 = icmp ne i32 %9, 0
  br i1 %10, label %12, label %11

11:                                               ; preds = %8
  store i32 0, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %83

12:                                               ; preds = %8
  store i64 0, ptr %4, align 8, !tbaa !13
  br label %13

13:                                               ; preds = %12, %1
  %14 = load i64, ptr %4, align 8, !tbaa !13
  call void @combine(i64 noundef %14)
  %15 = load i32, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 1), align 8, !tbaa !14
  %16 = and i32 %15, 12
  %17 = icmp ne i32 %16, 0
  br i1 %17, label %18, label %24

18:                                               ; preds = %13
  %19 = load i64, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 2), align 8, !tbaa !15
  %20 = load i64, ptr getelementptr inbounds ([4 x i64], ptr @as, i64 0, i64 3), align 8, !tbaa !13
  %21 = add i64 %20, %19
  store i64 %21, ptr getelementptr inbounds ([4 x i64], ptr @as, i64 0, i64 3), align 8, !tbaa !13
  %22 = load i32, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 1), align 8, !tbaa !14
  %23 = or i32 %22, 1
  store i32 %23, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 1), align 8, !tbaa !14
  br label %30

24:                                               ; preds = %13
  %25 = load i64, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 2), align 8, !tbaa !15
  %26 = load i64, ptr @as, align 8, !tbaa !13
  %27 = add i64 %26, %25
  store i64 %27, ptr @as, align 8, !tbaa !13
  %28 = load i32, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 1), align 8, !tbaa !14
  %29 = or i32 %28, 8
  store i32 %29, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 1), align 8, !tbaa !14
  br label %30

30:                                               ; preds = %24, %18
  %31 = load i64, ptr @as, align 8, !tbaa !13
  store i64 %31, ptr %4, align 8, !tbaa !13
  %32 = load i32, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 1), align 8, !tbaa !14
  %33 = and i32 %32, 4
  %34 = icmp ne i32 %33, 0
  br i1 %34, label %35, label %52

35:                                               ; preds = %30
  %36 = load i64, ptr %4, align 8, !tbaa !13
  %37 = and i64 %36, 60129542144
  %38 = icmp eq i64 %37, 60129542144
  br i1 %38, label %39, label %45

39:                                               ; preds = %35
  %40 = load i64, ptr getelementptr inbounds ([4 x i64], ptr @as, i64 0, i64 1), align 8, !tbaa !13
  %41 = and i64 %40, 508
  %42 = shl i64 %41, 24
  %43 = load i64, ptr %4, align 8, !tbaa !13
  %44 = add i64 %43, %42
  store i64 %44, ptr %4, align 8, !tbaa !13
  br label %51

45:                                               ; preds = %35
  %46 = load i64, ptr getelementptr inbounds ([4 x i64], ptr @as, i64 0, i64 1), align 8, !tbaa !13
  %47 = and i64 %46, 15
  %48 = shl i64 %47, 23
  %49 = load i64, ptr %4, align 8, !tbaa !13
  %50 = add i64 %49, %48
  store i64 %50, ptr %4, align 8, !tbaa !13
  br label %51

51:                                               ; preds = %45, %39
  br label %52

52:                                               ; preds = %51, %30
  %53 = load i32, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 1), align 8, !tbaa !14
  %54 = and i32 %53, 2
  %55 = icmp ne i32 %54, 0
  br i1 %55, label %56, label %66

56:                                               ; preds = %52
  %57 = load i64, ptr %4, align 8, !tbaa !13
  %58 = and i64 %57, 4194304
  %59 = icmp eq i64 %58, 0
  br i1 %59, label %60, label %65

60:                                               ; preds = %56
  %61 = load i64, ptr getelementptr inbounds ([4 x i64], ptr @as, i64 0, i64 2), align 8, !tbaa !13
  %62 = and i64 %61, 4194304
  %63 = load i64, ptr %4, align 8, !tbaa !13
  %64 = add i64 %63, %62
  store i64 %64, ptr %4, align 8, !tbaa !13
  br label %65

65:                                               ; preds = %60, %56
  br label %66

66:                                               ; preds = %65, %52
  %67 = load i32, ptr getelementptr inbounds (%struct.Assembler, ptr @as, i32 0, i32 1), align 8, !tbaa !14
  %68 = and i32 %67, 1
  %69 = icmp ne i32 %68, 0
  br i1 %69, label %70, label %78

70:                                               ; preds = %66
  %71 = load i64, ptr %4, align 8, !tbaa !13
  %72 = and i64 %71, 68719214592
  %73 = load i64, ptr %4, align 8, !tbaa !13
  %74 = load i64, ptr getelementptr inbounds ([4 x i64], ptr @as, i64 0, i64 3), align 8, !tbaa !13
  %75 = add i64 %73, %74
  %76 = and i64 %75, 262143
  %77 = add i64 %72, %76
  store i64 %77, ptr %4, align 8, !tbaa !13
  br label %78

78:                                               ; preds = %70, %66
  %79 = load i64, ptr %4, align 8, !tbaa !13
  %80 = and i64 %79, 68719476735
  store i64 %80, ptr %4, align 8, !tbaa !13
  %81 = load i64, ptr %4, align 8, !tbaa !13
  %82 = load ptr, ptr %3, align 8, !tbaa !5
  store i64 %81, ptr %82, align 8, !tbaa !13
  call void @resetexp()
  store i32 1, ptr %2, align 4
  store i32 1, ptr %5, align 4
  br label %83

83:                                               ; preds = %78, %11
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  %84 = load i32, ptr %2, align 4
  ret i32 %84
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 52}
!10 = !{!"Assembler", !7, i64 0, !11, i64 32, !12, i64 40, !11, i64 48, !11, i64 52}
!11 = !{!"int", !7, i64 0}
!12 = !{!"long", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!10, !11, i64 32}
!15 = !{!10, !12, i64 40}


; 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.Assembler = type { [4 x i64], i32, i64, i32, i32 }

@as = external dso_local local_unnamed_addr global %struct.Assembler, align 8

; 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: nounwind uwtable
declare dso_local i32 @parse(ptr noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @resetexp() local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @combine(i64 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
define dso_local range(i32 0, 2) i32 @endword(ptr nocapture noundef writeonly %0) local_unnamed_addr #1 {
  %2 = alloca i64, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #2
  %3 = call i32 @parse(ptr noundef nonnull %2)
  %.not = icmp eq i32 %3, 0
  br i1 %.not, label %4, label %._crit_edge

._crit_edge:                                      ; preds = %1
  %.pre = load i64, ptr %2, align 8, !tbaa !5
  br label %7

4:                                                ; preds = %1
  %5 = load i32, ptr getelementptr inbounds (i8, ptr @as, i64 52), align 4, !tbaa !9
  %.not1 = icmp eq i32 %5, 0
  br i1 %.not1, label %54, label %6

6:                                                ; preds = %4
  store i64 0, ptr %2, align 8, !tbaa !5
  br label %7

7:                                                ; preds = %._crit_edge, %6
  %8 = phi i64 [ %.pre, %._crit_edge ], [ 0, %6 ]
  call void @combine(i64 noundef %8)
  %9 = load i32, ptr getelementptr inbounds (i8, ptr @as, i64 32), align 8, !tbaa !12
  %10 = and i32 %9, 12
  %.not2 = icmp eq i32 %10, 0
  %11 = load i64, ptr getelementptr inbounds (i8, ptr @as, i64 40), align 8, !tbaa !13
  br i1 %.not2, label %16, label %12

12:                                               ; preds = %7
  %13 = load i64, ptr getelementptr inbounds (i8, ptr @as, i64 24), align 8, !tbaa !5
  %14 = add i64 %13, %11
  store i64 %14, ptr getelementptr inbounds (i8, ptr @as, i64 24), align 8, !tbaa !5
  %15 = or i32 %9, 1
  %.pre6 = load i64, ptr @as, align 8, !tbaa !5
  br label %20

16:                                               ; preds = %7
  %17 = load i64, ptr @as, align 8, !tbaa !5
  %18 = add i64 %17, %11
  store i64 %18, ptr @as, align 8, !tbaa !5
  %19 = or disjoint i32 %9, 8
  br label %20

20:                                               ; preds = %16, %12
  %21 = phi i64 [ %18, %16 ], [ %.pre6, %12 ]
  %storemerge = phi i32 [ %19, %16 ], [ %15, %12 ]
  store i32 %storemerge, ptr getelementptr inbounds (i8, ptr @as, i64 32), align 8, !tbaa !12
  %22 = and i32 %storemerge, 4
  %.not3 = icmp eq i32 %22, 0
  br i1 %.not3, label %35, label %23

23:                                               ; preds = %20
  %24 = and i64 %21, 60129542144
  %25 = icmp eq i64 %24, 60129542144
  %26 = load i64, ptr getelementptr inbounds (i8, ptr @as, i64 8), align 8, !tbaa !5
  br i1 %25, label %27, label %31

27:                                               ; preds = %23
  %28 = shl i64 %26, 24
  %29 = and i64 %28, 8522825728
  %30 = add i64 %29, %21
  br label %35

31:                                               ; preds = %23
  %32 = shl i64 %26, 23
  %33 = and i64 %32, 125829120
  %34 = add i64 %33, %21
  br label %35

35:                                               ; preds = %27, %31, %20
  %36 = phi i64 [ %30, %27 ], [ %34, %31 ], [ %21, %20 ]
  %37 = and i32 %storemerge, 2
  %.not4 = icmp ne i32 %37, 0
  %38 = and i64 %36, 4194304
  %39 = icmp eq i64 %38, 0
  %or.cond = select i1 %.not4, i1 %39, i1 false
  %40 = load i64, ptr getelementptr inbounds (i8, ptr @as, i64 16), align 8
  %41 = and i64 %40, 4194304
  %42 = select i1 %or.cond, i64 %41, i64 0
  %43 = or disjoint i64 %36, %42
  %44 = and i32 %storemerge, 1
  %.not5 = icmp eq i32 %44, 0
  br i1 %.not5, label %51, label %45

45:                                               ; preds = %35
  %46 = and i64 %43, 68719214592
  %47 = load i64, ptr getelementptr inbounds (i8, ptr @as, i64 24), align 8, !tbaa !5
  %48 = add i64 %47, %36
  %49 = and i64 %48, 262143
  %50 = or disjoint i64 %49, %46
  br label %51

51:                                               ; preds = %45, %35
  %52 = phi i64 [ %50, %45 ], [ %43, %35 ]
  %53 = and i64 %52, 68719476735
  store i64 %53, ptr %2, align 8, !tbaa !5
  store i64 %53, ptr %0, align 8, !tbaa !5
  call void @resetexp()
  br label %54

54:                                               ; preds = %4, %51
  %.0 = phi i32 [ 1, %51 ], [ 0, %4 ]
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #2
  ret i32 %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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 = !{!"long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !11, i64 52}
!10 = !{!"Assembler", !7, i64 0, !11, i64 32, !6, i64 40, !11, i64 48, !11, i64 52}
!11 = !{!"int", !7, i64 0}
!12 = !{!10, !11, i64 32}
!13 = !{!10, !6, i64 40}


; Effective O3 passes: DSEPass,EarlyCSEPass,GVNPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass