The betting game consists of two rounds. In each round you can bet a certain amount, and you know beforehand that the opponent's bet follows a distribution with p.d.f. $f(x)$ whose support is on $[0, \infty)$.
In a round, if your bet is higher you pay whatever the opponent's bet is; otherwise you lose the round and you pay nothing.
Suppose you have $S \in [0, \infty)$ amount of money to bet, and the goal is to win as many rounds as possible with the money in hand (in expectation), under the condition that you cannot spend more than $S$ almost surely.
If you lose the first round, clearly the best strategy is to bet $S$ in the second round, and if you win with a cost of $C$ in the first round, the best strategy is to bet $S - C$ in the second round. Now the problem simply boils down to a 1D optimization problem where the optimization variable is how much you should betin the first round. I'm having a hard time finding the analytical form of the solution.