cgen (S.When clauses) = do
    entryBlock <- entry
    exitBlock <- addBlock "case.exit"

    -- Throw error if else clause is zero or greater than 1
    -- Else should always be last
    let elseClause = last clauses
    let otherClauses = reverse (init clauses)

    elsePhi <- processElse exitBlock elseClause

    descendants <- scanM (processClause exitBlock) elsePhi otherClauses

    setBlock entryBlock
    let firstBlock = snd (last descendants)
    br firstBlock

    setBlock exitBlock

    phi double (map fst descendants)
cgen (S.When clauses) = do
    entryBlock <- entry
    exitBlock <- addBlock "case.exit"

    -- Throw error if else clause is zero or greater than 1
    -- Else should always be last
    let elseClause = last clauses
    let otherClauses = reverse (init clauses)

    elsePhi <- processElse exitBlock elseClause

    descendants <- scanM (processClause exitBlock) elsePhi otherClauses

    setBlock entryBlock
    let firstBlock = snd (last descendants)
    br firstBlock

    setBlock exitBlock

    phi double (map fst descendants)
cgen (S.When clauses) = do
    entryBlock <- entry
    exitBlock <- addBlock "case.exit"

    -- Throw error if else clause is zero or greater than 1
    -- Else should always be last
    let elseClause = last clauses
    let otherClauses = reverse (init clauses)

    elsePhi <- processElse exitBlock elseClause

    descendants <- scanM (processClause exitBlock) elsePhi otherClauses

    setBlock entryBlock
    let firstBlock = snd (last descendants)
    br firstBlock

    setBlock exitBlock

    phi double (map fst descendants)