Problem p03994 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

signed main() {
  char c[11111];
  int ops;
  scanf("%s %d", c, &ops);
  int n = strlen(c);

#define next(c) (c == 'z' ? 'a' : c + 1)
#define minimize(c)                                                            \
  do {                                                                         \
    if (ops > 30) {                                                            \
      if (c == 'a')                                                            \
        break;                                                                 \
      ops -= 'z' - c + 1;                                                      \
      c = 'a';                                                                 \
      break;                                                                   \
    }                                                                          \
                                                                               \
    int ops_orig = ops;                                                        \
    char c_orig = c;                                                           \
    while (c != 'a' && ops > 0) {                                              \
      c = next(c);                                                             \
      --ops;                                                                   \
    }                                                                          \
    if (c != 'a') {                                                            \
      ops = ops_orig;                                                          \
      c = c_orig;                                                              \
    }                                                                          \
  } while (0);

  for (int i = 0; i < n; ++i)
    minimize(c[i]);
  while (ops > 0) {
    c[n - 1] = next(c[n - 1]);
    --ops;
  }
  puts(c);
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14
 * c.cc -o c && for f in *.in; do echo \"--- $f -------------\"; ./c <$f; done"
 * end:
 */


Fixed submission:
#include <bits/stdc++.h>
using namespace std;

signed main() {
  char c[111111];
  int ops;
  scanf("%s %d", c, &ops);
  int n = strlen(c);

#define next(c) (c == 'z' ? 'a' : c + 1)
#define minimize(c)                                                            \
  do {                                                                         \
    if (ops > 30) {                                                            \
      if (c == 'a')                                                            \
        break;                                                                 \
      ops -= 'z' - c + 1;                                                      \
      c = 'a';                                                                 \
      break;                                                                   \
    }                                                                          \
                                                                               \
    int ops_orig = ops;                                                        \
    char c_orig = c;                                                           \
    while (c != 'a' && ops > 0) {                                              \
      c = next(c);                                                             \
      --ops;                                                                   \
    }                                                                          \
    if (c != 'a') {                                                            \
      ops = ops_orig;                                                          \
      c = c_orig;                                                              \
    }                                                                          \
  } while (0);

  for (int i = 0; i < n; ++i)
    minimize(c[i]);
  while (ops > 0) {
    c[n - 1] = next(c[n - 1]);
    --ops;
  }
  puts(c);
}

/*
 * Local variables:
 * compile-command:"g++ -D_GLIBCXX_DEBUG -g3 -ggdb3 -O0 -Wall -Wextra -std=c++14
 * c.cc -o c && for f in *.in; do echo \"--- $f -------------\"; ./c <$f; done"
 * end:
 */