This answer is from https://www.codesdope.com/course/data-structures-red-black-trees-insertion/
All credit to those guys.
LEFT_ROTATION(T, x)
y = x.right
x.right = y.left
The left child of y is going to be the right child of x - x.right = y.left. We also need to change the parent of y.left to x. We will do this if the left child of y is not NULL.
if y.left != NULL
y.left.parent = x
Then we need to put y to the position of x. We will first change the parent of y to the parent of x - y.parent = x.parent. After this, we will make the node x the child of y's parent instead of y. We will do so by checking if y is the right or left child of its parent. We will also check if y is the root of the tree.
y.parent = x.parent
if x.parent == NULL //x is root
T.root = y
elseif x == x.parent.left // x is left child
x.parent.left = y
else // x is right child
x.parent.right = y
At last, we need to make x the left child of y.
y.left = x
x.parent = y
LEFT_ROTATE(T, x)
y = x.right
x.right = y.left
if y.left != NULL
y.left.parent = x
y.parent = x.parent
if x.parent == NULL //x is root
T.root = y
elseif x == x.parent.left // x is left child
x.parent.left = y
else // x is right child
x.parent.right = y
y.left = x
x.parent = y