; LLVM IR from travisdowns/uarch-bench :: page-info (fprint_info_row)

; 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.flag = type { i32, ptr, i8 }
%struct.page_info = type { i64, i8, i8, i8, i8, i8, i8, i64 }

@kpageflag_defs = external dso_local constant [26 x %struct.flag], align 16
@.str.28 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [5 x i8], align 1

; Function Attrs: nounwind
declare i32 @fprintf(ptr noundef, ptr noundef, ...) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local void @fprint_info_row(ptr noundef %0, ptr noundef byval(%struct.page_info) align 8 %1) #2 {
  %3 = alloca ptr, align 8
  %4 = alloca ptr, align 8
  store ptr %0, ptr %3, align 8, !tbaa !5
  %5 = load ptr, ptr %3, align 8, !tbaa !5
  %6 = getelementptr inbounds %struct.page_info, ptr %1, i32 0, i32 0
  %7 = load i64, ptr %6, align 8, !tbaa !9
  %8 = inttoptr i64 %7 to ptr
  %9 = getelementptr inbounds %struct.page_info, ptr %1, i32 0, i32 1
  %10 = load i8, ptr %9, align 8, !tbaa !13, !range !14, !noundef !15
  %11 = trunc i8 %10 to i1
  %12 = zext i1 %11 to i32
  %13 = getelementptr inbounds %struct.page_info, ptr %1, i32 0, i32 2
  %14 = load i8, ptr %13, align 1, !tbaa !16, !range !14, !noundef !15
  %15 = trunc i8 %14 to i1
  %16 = zext i1 %15 to i32
  %17 = getelementptr inbounds %struct.page_info, ptr %1, i32 0, i32 3
  %18 = load i8, ptr %17, align 2, !tbaa !17, !range !14, !noundef !15
  %19 = trunc i8 %18 to i1
  %20 = zext i1 %19 to i32
  %21 = getelementptr inbounds %struct.page_info, ptr %1, i32 0, i32 4
  %22 = load i8, ptr %21, align 1, !tbaa !18, !range !14, !noundef !15
  %23 = trunc i8 %22 to i1
  %24 = zext i1 %23 to i32
  %25 = getelementptr inbounds %struct.page_info, ptr %1, i32 0, i32 5
  %26 = load i8, ptr %25, align 4, !tbaa !19, !range !14, !noundef !15
  %27 = trunc i8 %26 to i1
  %28 = zext i1 %27 to i32
  %29 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %5, ptr noundef @.str.29, ptr noundef %8, i32 noundef %12, i32 noundef %16, i32 noundef %20, i32 noundef %24, i32 noundef %28) #3
  %30 = getelementptr inbounds %struct.page_info, ptr %1, i32 0, i32 6
  %31 = load i8, ptr %30, align 1, !tbaa !20, !range !14, !noundef !15
  %32 = trunc i8 %31 to i1
  br i1 %32, label %33, label %65

33:                                               ; preds = %2
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #3
  store ptr @kpageflag_defs, ptr %4, align 8, !tbaa !5
  br label %34

34:                                               ; preds = %61, %33
  %35 = load ptr, ptr %4, align 8, !tbaa !5
  %36 = getelementptr inbounds %struct.flag, ptr %35, i32 0, i32 0
  %37 = load i32, ptr %36, align 8, !tbaa !21
  %38 = icmp ne i32 %37, -1
  br i1 %38, label %40, label %39

39:                                               ; preds = %34
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #3
  br label %64

40:                                               ; preds = %34
  %41 = load ptr, ptr %4, align 8, !tbaa !5
  %42 = getelementptr inbounds %struct.flag, ptr %41, i32 0, i32 2
  %43 = load i8, ptr %42, align 8, !tbaa !24, !range !14, !noundef !15
  %44 = trunc i8 %43 to i1
  br i1 %44, label %45, label %60

45:                                               ; preds = %40
  %46 = load ptr, ptr %3, align 8, !tbaa !5
  %47 = getelementptr inbounds %struct.page_info, ptr %1, i32 0, i32 7
  %48 = load i64, ptr %47, align 8, !tbaa !25
  %49 = load ptr, ptr %4, align 8, !tbaa !5
  %50 = getelementptr inbounds %struct.flag, ptr %49, i32 0, i32 0
  %51 = load i32, ptr %50, align 8, !tbaa !21
  %52 = zext i32 %51 to i64
  %53 = shl i64 1, %52
  %54 = and i64 %48, %53
  %55 = icmp ne i64 %54, 0
  %56 = xor i1 %55, true
  %57 = xor i1 %56, true
  %58 = zext i1 %57 to i32
  %59 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %46, ptr noundef @.str.30, i32 noundef %58) #3
  br label %60

60:                                               ; preds = %45, %40
  br label %61

61:                                               ; preds = %60
  %62 = load ptr, ptr %4, align 8, !tbaa !5
  %63 = getelementptr inbounds %struct.flag, ptr %62, i32 1
  store ptr %63, ptr %4, align 8, !tbaa !5
  br label %34, !llvm.loop !26

64:                                               ; preds = %39
  br label %65

65:                                               ; preds = %64, %2
  %66 = load ptr, ptr %3, align 8, !tbaa !5
  %67 = call i32 (ptr, ptr, ...) @fprintf(ptr noundef %66, ptr noundef @.str.28) #3
  ret void
}

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 #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 = !{!"", !11, i64 0, !12, i64 8, !12, i64 9, !12, i64 10, !12, i64 11, !12, i64 12, !12, i64 13, !11, i64 16}
!11 = !{!"long", !7, i64 0}
!12 = !{!"_Bool", !7, i64 0}
!13 = !{!10, !12, i64 8}
!14 = !{i8 0, i8 2}
!15 = !{}
!16 = !{!10, !12, i64 9}
!17 = !{!10, !12, i64 10}
!18 = !{!10, !12, i64 11}
!19 = !{!10, !12, i64 12}
!20 = !{!10, !12, i64 13}
!21 = !{!22, !23, i64 0}
!22 = !{!"", !23, i64 0, !6, i64 8, !12, i64 16}
!23 = !{!"int", !7, i64 0}
!24 = !{!22, !12, i64 16}
!25 = !{!10, !11, i64 16}
!26 = distinct !{!26, !27}
!27 = !{!"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.flag = type { i32, ptr, i8 }
%struct.page_info = type { i64, i8, i8, i8, i8, i8, i8, i64 }

@kpageflag_defs = external dso_local local_unnamed_addr constant [26 x %struct.flag], align 16
@.str.28 = external hidden unnamed_addr constant [2 x i8], align 1
@.str.29 = external hidden unnamed_addr constant [22 x i8], align 1
@.str.30 = external hidden unnamed_addr constant [5 x i8], align 1

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

; Function Attrs: nofree nounwind uwtable
define dso_local void @fprint_info_row(ptr nocapture noundef %0, ptr nocapture noundef readonly byval(%struct.page_info) align 8 %1) local_unnamed_addr #1 {
  %3 = load i64, ptr %1, align 8, !tbaa !5
  %4 = inttoptr i64 %3 to ptr
  %5 = getelementptr inbounds i8, ptr %1, i64 8
  %6 = load i8, ptr %5, align 8, !tbaa !11, !range !12, !noundef !13
  %7 = zext nneg i8 %6 to i32
  %8 = getelementptr inbounds i8, ptr %1, i64 9
  %9 = load i8, ptr %8, align 1, !tbaa !14, !range !12, !noundef !13
  %10 = zext nneg i8 %9 to i32
  %11 = getelementptr inbounds i8, ptr %1, i64 10
  %12 = load i8, ptr %11, align 2, !tbaa !15, !range !12, !noundef !13
  %13 = zext nneg i8 %12 to i32
  %14 = getelementptr inbounds i8, ptr %1, i64 11
  %15 = load i8, ptr %14, align 1, !tbaa !16, !range !12, !noundef !13
  %16 = zext nneg i8 %15 to i32
  %17 = getelementptr inbounds i8, ptr %1, i64 12
  %18 = load i8, ptr %17, align 4, !tbaa !17, !range !12, !noundef !13
  %19 = zext nneg i8 %18 to i32
  %20 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.29, ptr noundef %4, i32 noundef %7, i32 noundef %10, i32 noundef %13, i32 noundef %16, i32 noundef %19) #2
  %21 = getelementptr inbounds i8, ptr %1, i64 13
  %22 = load i8, ptr %21, align 1, !tbaa !18, !range !12, !noundef !13
  %23 = trunc nuw i8 %22 to i1
  br i1 %23, label %.preheader, label %.loopexit

.preheader:                                       ; preds = %2
  %24 = load i32, ptr @kpageflag_defs, align 16, !tbaa !19
  %.not8 = icmp eq i32 %24, -1
  br i1 %.not8, label %.loopexit, label %.lr.ph

.lr.ph:                                           ; preds = %.preheader
  %25 = getelementptr inbounds i8, ptr %1, i64 16
  %26 = load i64, ptr %25, align 8
  br label %27

27:                                               ; preds = %.lr.ph, %39
  %28 = phi i32 [ %24, %.lr.ph ], [ %41, %39 ]
  %.09 = phi ptr [ @kpageflag_defs, %.lr.ph ], [ %40, %39 ]
  %29 = getelementptr inbounds i8, ptr %.09, i64 16
  %30 = load i8, ptr %29, align 8, !tbaa !23, !range !12, !noundef !13
  %31 = trunc nuw i8 %30 to i1
  br i1 %31, label %32, label %39

32:                                               ; preds = %27
  %33 = zext nneg i32 %28 to i64
  %34 = shl nuw i64 1, %33
  %35 = and i64 %26, %34
  %36 = icmp ne i64 %35, 0
  %37 = zext i1 %36 to i32
  %38 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.30, i32 noundef %37) #2
  br label %39

39:                                               ; preds = %27, %32
  %40 = getelementptr inbounds i8, ptr %.09, i64 24
  %41 = load i32, ptr %40, align 8, !tbaa !19
  %.not = icmp eq i32 %41, -1
  br i1 %.not, label %.loopexit, label %27, !llvm.loop !24

.loopexit:                                        ; preds = %39, %.preheader, %2
  %42 = tail call i32 (ptr, ptr, ...) @fprintf(ptr noundef %0, ptr noundef nonnull @.str.28) #2
  ret void
}

attributes #0 = { 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 #1 = { 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 #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, !7, i64 0}
!6 = !{!"", !7, i64 0, !10, i64 8, !10, i64 9, !10, i64 10, !10, i64 11, !10, i64 12, !10, i64 13, !7, i64 16}
!7 = !{!"long", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"_Bool", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = !{i8 0, i8 2}
!13 = !{}
!14 = !{!6, !10, i64 9}
!15 = !{!6, !10, i64 10}
!16 = !{!6, !10, i64 11}
!17 = !{!6, !10, i64 12}
!18 = !{!6, !10, i64 13}
!19 = !{!20, !21, i64 0}
!20 = !{!"", !21, i64 0, !22, i64 8, !10, i64 16}
!21 = !{!"int", !8, i64 0}
!22 = !{!"any pointer", !8, i64 0}
!23 = !{!20, !10, i64 16}
!24 = distinct !{!24, !25}
!25 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass