; LLVM IR from AnneLivia/Competitive-Programming :: Online Judges/URI/Olimpiadas - OBI2009/main.ll (Z8sortRank6PaisesS_)

; 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.Paises = type { i32, i32, i32, i32 }

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef zeroext i1 @_Z8sortRank6PaisesS_(i64 %0, i64 %1, i64 %2, i64 %3) #0 {
  %5 = alloca i1, align 1
  %6 = alloca %struct.Paises, align 4
  %7 = alloca %struct.Paises, align 4
  %8 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 0
  store i64 %0, ptr %8, align 4
  %9 = getelementptr inbounds { i64, i64 }, ptr %6, i32 0, i32 1
  store i64 %1, ptr %9, align 4
  %10 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 0
  store i64 %2, ptr %10, align 4
  %11 = getelementptr inbounds { i64, i64 }, ptr %7, i32 0, i32 1
  store i64 %3, ptr %11, align 4
  %12 = getelementptr inbounds %struct.Paises, ptr %6, i32 0, i32 1
  %13 = load i32, ptr %12, align 4, !tbaa !5
  %14 = getelementptr inbounds %struct.Paises, ptr %7, i32 0, i32 1
  %15 = load i32, ptr %14, align 4, !tbaa !5
  %16 = icmp sgt i32 %13, %15
  br i1 %16, label %17, label %18

17:                                               ; preds = %4
  store i1 true, ptr %5, align 1
  br label %62

18:                                               ; preds = %4
  %19 = getelementptr inbounds %struct.Paises, ptr %6, i32 0, i32 1
  %20 = load i32, ptr %19, align 4, !tbaa !5
  %21 = getelementptr inbounds %struct.Paises, ptr %7, i32 0, i32 1
  %22 = load i32, ptr %21, align 4, !tbaa !5
  %23 = icmp eq i32 %20, %22
  br i1 %23, label %24, label %60

24:                                               ; preds = %18
  %25 = getelementptr inbounds %struct.Paises, ptr %6, i32 0, i32 2
  %26 = load i32, ptr %25, align 4, !tbaa !10
  %27 = getelementptr inbounds %struct.Paises, ptr %7, i32 0, i32 2
  %28 = load i32, ptr %27, align 4, !tbaa !10
  %29 = icmp sgt i32 %26, %28
  br i1 %29, label %30, label %31

30:                                               ; preds = %24
  store i1 true, ptr %5, align 1
  br label %62

31:                                               ; preds = %24
  %32 = getelementptr inbounds %struct.Paises, ptr %6, i32 0, i32 2
  %33 = load i32, ptr %32, align 4, !tbaa !10
  %34 = getelementptr inbounds %struct.Paises, ptr %7, i32 0, i32 2
  %35 = load i32, ptr %34, align 4, !tbaa !10
  %36 = icmp eq i32 %33, %35
  br i1 %36, label %37, label %59

37:                                               ; preds = %31
  %38 = getelementptr inbounds %struct.Paises, ptr %6, i32 0, i32 3
  %39 = load i32, ptr %38, align 4, !tbaa !11
  %40 = getelementptr inbounds %struct.Paises, ptr %7, i32 0, i32 3
  %41 = load i32, ptr %40, align 4, !tbaa !11
  %42 = icmp sgt i32 %39, %41
  br i1 %42, label %43, label %44

43:                                               ; preds = %37
  store i1 true, ptr %5, align 1
  br label %62

44:                                               ; preds = %37
  %45 = getelementptr inbounds %struct.Paises, ptr %6, i32 0, i32 3
  %46 = load i32, ptr %45, align 4, !tbaa !11
  %47 = getelementptr inbounds %struct.Paises, ptr %7, i32 0, i32 3
  %48 = load i32, ptr %47, align 4, !tbaa !11
  %49 = icmp eq i32 %46, %48
  br i1 %49, label %50, label %58

50:                                               ; preds = %44
  %51 = getelementptr inbounds %struct.Paises, ptr %6, i32 0, i32 0
  %52 = load i32, ptr %51, align 4, !tbaa !12
  %53 = getelementptr inbounds %struct.Paises, ptr %7, i32 0, i32 0
  %54 = load i32, ptr %53, align 4, !tbaa !12
  %55 = icmp slt i32 %52, %54
  br i1 %55, label %56, label %57

56:                                               ; preds = %50
  store i1 true, ptr %5, align 1
  br label %62

57:                                               ; preds = %50
  store i1 false, ptr %5, align 1
  br label %62

58:                                               ; preds = %44
  store i1 false, ptr %5, align 1
  br label %62

59:                                               ; preds = %31
  store i1 false, ptr %5, align 1
  br label %62

60:                                               ; preds = %18
  br label %61

61:                                               ; preds = %60
  store i1 false, ptr %5, align 1
  br label %62

62:                                               ; preds = %61, %59, %58, %57, %56, %43, %30, %17
  %63 = load i1, ptr %5, align 1
  ret i1 %63
}

attributes #0 = { mustprogress 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, !7, i64 4}
!6 = !{!"_ZTS6Paises", !7, i64 0, !7, i64 4, !7, i64 8, !7, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!6, !7, i64 8}
!11 = !{!6, !7, i64 12}
!12 = !{!6, !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 nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local noundef zeroext i1 @_Z8sortRank6PaisesS_(i64 %0, i64 %1, i64 %2, i64 %3) local_unnamed_addr #0 {
  %.sroa.04.0.extract.trunc = trunc i64 %0 to i32
  %.sroa.25.0.extract.shift = lshr i64 %0, 32
  %.sroa.25.0.extract.trunc = trunc nuw i64 %.sroa.25.0.extract.shift to i32
  %.sroa.47.8.extract.trunc = trunc i64 %1 to i32
  %.sroa.79.8.extract.shift = lshr i64 %1, 32
  %.sroa.79.8.extract.trunc = trunc nuw i64 %.sroa.79.8.extract.shift to i32
  %.sroa.0.0.extract.trunc = trunc i64 %2 to i32
  %.sroa.2.0.extract.shift = lshr i64 %2, 32
  %.sroa.2.0.extract.trunc = trunc nuw i64 %.sroa.2.0.extract.shift to i32
  %.sroa.4.8.extract.trunc = trunc i64 %3 to i32
  %.sroa.7.8.extract.shift = lshr i64 %3, 32
  %.sroa.7.8.extract.trunc = trunc nuw i64 %.sroa.7.8.extract.shift to i32
  %5 = icmp sgt i32 %.sroa.25.0.extract.trunc, %.sroa.2.0.extract.trunc
  br i1 %5, label %17, label %6

6:                                                ; preds = %4
  %7 = icmp eq i64 %.sroa.25.0.extract.shift, %.sroa.2.0.extract.shift
  br i1 %7, label %8, label %17

8:                                                ; preds = %6
  %9 = icmp sgt i32 %.sroa.47.8.extract.trunc, %.sroa.4.8.extract.trunc
  br i1 %9, label %17, label %10

10:                                               ; preds = %8
  %11 = icmp eq i32 %.sroa.47.8.extract.trunc, %.sroa.4.8.extract.trunc
  br i1 %11, label %12, label %17

12:                                               ; preds = %10
  %13 = icmp sgt i32 %.sroa.79.8.extract.trunc, %.sroa.7.8.extract.trunc
  br i1 %13, label %17, label %14

14:                                               ; preds = %12
  %15 = icmp eq i64 %.sroa.79.8.extract.shift, %.sroa.7.8.extract.shift
  %16 = icmp slt i32 %.sroa.04.0.extract.trunc, %.sroa.0.0.extract.trunc
  %spec.select = and i1 %16, %15
  br label %17

17:                                               ; preds = %14, %6, %10, %12, %8, %4
  %.0 = phi i1 [ true, %4 ], [ true, %8 ], [ true, %12 ], [ false, %10 ], [ false, %6 ], [ %spec.select, %14 ]
  ret i1 %.0
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(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)"}


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