Making code elegant, clean and optimized I have some piece of code that I already optimized, however I found that there is an edge case that I should handle and I am unable to make it elegant.
char* data = get_data_from_queue(data);
Album album;
get_album(data, &amp;album);
if (get_album_vals(album) &lt;= 0) {
    printf(&quot;Album doesn't exist, will try to create it&quot;);
    return should_create_album(album);
}
do_stuff_with_data(&amp;data);

Now, when I don't find album vals, under certain conditions (&lt; 0.01%), it may be a golden album.
If it is a golden album, under certain conditions (&lt;0.01%), it may need a second chance.
This is the modified code that should keep same behavior, apart from the second chance for golden album:
char* data = get_data_from_queue(data);
Album album;
get_album(data, &amp;album);
if (get_album_vals(album) &lt;= 0) {
    int is_golden_album = 0;
    ret = should_create_album(album);
    if (!ret &amp;&amp; album_might_be_golden(album)) {
        GoldenAlbum golden_album;
        if (get_golden_album(data, &amp;golden_album)
        {
            ret = should_create_album(golden_album);
        } else {
            is_golden_album = 1;
        }
    }
    if (is_golden_album &gt; 0)
    {
        return ret;
    }
}
do_stuff_with_data(&amp;data);

However the new code is awful and I am not sure how to make it more elegant and optimized and I have spent way too much time on this.
Anyone have a suggestion?
The inelegance lies in the way you're storing your data.  You haven't normalized it, so you have to check multiple places for what should be the same information.
Why are golden albums in a different list?  The fact that you need to check that list too, should be an indication that those two lists should be the same.  Just like the artists, producers, and other information about the album, whether or not it's golden (and indeed, how many times, if I understand golden album status correctly) is an attribute of the data.
You don't spend much time justifying why GoldenAlbum and Album are different types. Without knowing much about the data you're modeling, it's hard to be sure exactly what your data attempts to describe.  So maybe I'm misunderstanding what 'golden' means for an 'album'.  But if you have only one Album object and it has a is_golden attribute, you can avoid continuing to implement checks for both types of album in any code that interacts with the data by album name.