; LLVM IR from tangjz/acm-icpc :: 51nod/1648.ll (Z6rotatei)

; 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.Node = type { i32, [2 x i32], i32 }

@t = external dso_local global [100009 x %struct.Node], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8maintaini(i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5setchiii(i32 noundef, i32 noundef, i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z6isrooti(i32 noundef) #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6rotatei(i32 noundef %0) #0 {
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i32 %0, ptr %2, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  %5 = load i32, ptr %2, align 4, !tbaa !5
  %6 = sext i32 %5 to i64
  %7 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %6
  %8 = getelementptr inbounds %struct.Node, ptr %7, i32 0, i32 0
  %9 = load i32, ptr %8, align 16, !tbaa !9
  %10 = sext i32 %9 to i64
  %11 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %10
  %12 = getelementptr inbounds %struct.Node, ptr %11, i32 0, i32 1
  %13 = getelementptr inbounds [2 x i32], ptr %12, i64 0, i64 1
  %14 = load i32, ptr %13, align 4, !tbaa !5
  %15 = load i32, ptr %2, align 4, !tbaa !5
  %16 = icmp eq i32 %14, %15
  %17 = zext i1 %16 to i32
  store i32 %17, ptr %3, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  %18 = load i32, ptr %2, align 4, !tbaa !5
  %19 = sext i32 %18 to i64
  %20 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %19
  %21 = getelementptr inbounds %struct.Node, ptr %20, i32 0, i32 0
  %22 = load i32, ptr %21, align 16, !tbaa !9
  store i32 %22, ptr %4, align 4, !tbaa !5
  %23 = load i32, ptr %4, align 4, !tbaa !5
  %24 = load i32, ptr %3, align 4, !tbaa !5
  %25 = load i32, ptr %2, align 4, !tbaa !5
  %26 = sext i32 %25 to i64
  %27 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %26
  %28 = getelementptr inbounds %struct.Node, ptr %27, i32 0, i32 1
  %29 = load i32, ptr %3, align 4, !tbaa !5
  %30 = xor i32 %29, 1
  %31 = sext i32 %30 to i64
  %32 = getelementptr inbounds [2 x i32], ptr %28, i64 0, i64 %31
  %33 = load i32, ptr %32, align 4, !tbaa !5
  call void @_Z5setchiii(i32 noundef %23, i32 noundef %24, i32 noundef %33)
  %34 = load i32, ptr %2, align 4, !tbaa !5
  %35 = sext i32 %34 to i64
  %36 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %35
  %37 = getelementptr inbounds %struct.Node, ptr %36, i32 0, i32 0
  %38 = load i32, ptr %37, align 16, !tbaa !9
  %39 = call noundef zeroext i1 @_Z6isrooti(i32 noundef %38)
  br i1 %39, label %40, label %58

40:                                               ; preds = %1
  %41 = load i32, ptr %2, align 4, !tbaa !5
  %42 = sext i32 %41 to i64
  %43 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %42
  %44 = getelementptr inbounds %struct.Node, ptr %43, i32 0, i32 0
  %45 = load i32, ptr %44, align 16, !tbaa !9
  %46 = sext i32 %45 to i64
  %47 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %46
  %48 = getelementptr inbounds %struct.Node, ptr %47, i32 0, i32 0
  %49 = load i32, ptr %48, align 16, !tbaa !9
  %50 = load i32, ptr %2, align 4, !tbaa !5
  %51 = sext i32 %50 to i64
  %52 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %51
  %53 = getelementptr inbounds %struct.Node, ptr %52, i32 0, i32 0
  store i32 %49, ptr %53, align 16, !tbaa !9
  %54 = load i32, ptr %2, align 4, !tbaa !5
  %55 = load i32, ptr %3, align 4, !tbaa !5
  %56 = xor i32 %55, 1
  %57 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z5setchiii(i32 noundef %54, i32 noundef %56, i32 noundef %57)
  br label %99

58:                                               ; preds = %1
  %59 = load i32, ptr %2, align 4, !tbaa !5
  %60 = sext i32 %59 to i64
  %61 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %60
  %62 = getelementptr inbounds %struct.Node, ptr %61, i32 0, i32 0
  %63 = load i32, ptr %62, align 16, !tbaa !9
  %64 = sext i32 %63 to i64
  %65 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %64
  %66 = getelementptr inbounds %struct.Node, ptr %65, i32 0, i32 0
  %67 = load i32, ptr %66, align 16, !tbaa !9
  %68 = load i32, ptr %2, align 4, !tbaa !5
  %69 = sext i32 %68 to i64
  %70 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %69
  %71 = getelementptr inbounds %struct.Node, ptr %70, i32 0, i32 0
  %72 = load i32, ptr %71, align 16, !tbaa !9
  %73 = sext i32 %72 to i64
  %74 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %73
  %75 = getelementptr inbounds %struct.Node, ptr %74, i32 0, i32 0
  %76 = load i32, ptr %75, align 16, !tbaa !9
  %77 = sext i32 %76 to i64
  %78 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %77
  %79 = getelementptr inbounds %struct.Node, ptr %78, i32 0, i32 1
  %80 = getelementptr inbounds [2 x i32], ptr %79, i64 0, i64 1
  %81 = load i32, ptr %80, align 4, !tbaa !5
  %82 = load i32, ptr %2, align 4, !tbaa !5
  %83 = sext i32 %82 to i64
  %84 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %83
  %85 = getelementptr inbounds %struct.Node, ptr %84, i32 0, i32 0
  %86 = load i32, ptr %85, align 16, !tbaa !9
  %87 = icmp eq i32 %81, %86
  %88 = zext i1 %87 to i32
  %89 = load i32, ptr %2, align 4, !tbaa !5
  call void @_Z5setchiii(i32 noundef %67, i32 noundef %88, i32 noundef %89)
  %90 = load i32, ptr %2, align 4, !tbaa !5
  %91 = load i32, ptr %3, align 4, !tbaa !5
  %92 = xor i32 %91, 1
  %93 = load i32, ptr %4, align 4, !tbaa !5
  call void @_Z5setchiii(i32 noundef %90, i32 noundef %92, i32 noundef %93)
  %94 = load i32, ptr %2, align 4, !tbaa !5
  %95 = sext i32 %94 to i64
  %96 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %95
  %97 = getelementptr inbounds %struct.Node, ptr %96, i32 0, i32 0
  %98 = load i32, ptr %97, align 16, !tbaa !9
  call void @_Z8maintaini(i32 noundef %98)
  br label %99

99:                                               ; preds = %58, %40
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret void
}

; 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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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 = !{!"int", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !6, i64 0}
!10 = !{!"_ZTS4Node", !6, i64 0, !7, i64 4, !6, i64 12}


; 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.Node = type { i32, [2 x i32], i32 }

@t = external dso_local local_unnamed_addr global [100009 x %struct.Node], align 16

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z8maintaini(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_Z5setchiii(i32 noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef zeroext i1 @_Z6isrooti(i32 noundef) local_unnamed_addr #0

; Function Attrs: mustprogress nounwind uwtable
define dso_local void @_Z6rotatei(i32 noundef %0) local_unnamed_addr #0 {
  %2 = sext i32 %0 to i64
  %3 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %2
  %4 = load i32, ptr %3, align 16, !tbaa !5
  %5 = sext i32 %4 to i64
  %6 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %5, i32 1, i64 1
  %7 = load i32, ptr %6, align 8, !tbaa !10
  %8 = icmp eq i32 %7, %0
  %9 = zext i1 %8 to i32
  %10 = getelementptr inbounds i8, ptr %3, i64 4
  %11 = xor i32 %9, 1
  %12 = zext nneg i32 %11 to i64
  %13 = getelementptr inbounds [2 x i32], ptr %10, i64 0, i64 %12
  %14 = load i32, ptr %13, align 4, !tbaa !10
  tail call void @_Z5setchiii(i32 noundef %4, i32 noundef %9, i32 noundef %14)
  %15 = load i32, ptr %3, align 16, !tbaa !5
  %16 = tail call noundef zeroext i1 @_Z6isrooti(i32 noundef %15)
  %17 = load i32, ptr %3, align 16, !tbaa !5
  %18 = sext i32 %17 to i64
  %19 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %18
  %20 = load i32, ptr %19, align 16, !tbaa !5
  br i1 %16, label %21, label %22

21:                                               ; preds = %1
  store i32 %20, ptr %3, align 16, !tbaa !5
  tail call void @_Z5setchiii(i32 noundef %0, i32 noundef %11, i32 noundef %4)
  br label %29

22:                                               ; preds = %1
  %23 = sext i32 %20 to i64
  %24 = getelementptr inbounds [100009 x %struct.Node], ptr @t, i64 0, i64 %23, i32 1, i64 1
  %25 = load i32, ptr %24, align 8, !tbaa !10
  %26 = icmp eq i32 %25, %17
  %27 = zext i1 %26 to i32
  tail call void @_Z5setchiii(i32 noundef %20, i32 noundef %27, i32 noundef %0)
  tail call void @_Z5setchiii(i32 noundef %0, i32 noundef %11, i32 noundef %4)
  %28 = load i32, ptr %3, align 16, !tbaa !5
  tail call void @_Z8maintaini(i32 noundef %28)
  br label %29

29:                                               ; preds = %22, %21
  ret void
}

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 0}
!6 = !{!"_ZTS4Node", !7, i64 0, !8, i64 4, !7, i64 12}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}
!10 = !{!7, !7, i64 0}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferAlignmentPass,InferFunctionAttrsPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass