#include <stdio.h>
#define uint unsigned int
int atoi(const char* buf) {
if (buf == NULL) {
return -1;
}
int ans = 0;
uint i = 0;
while (buf[i] != 0x0) {
int val = buf[i] - '0';
if (val < 0 || val > 9) {
return -1;
}
ans = ans * 10;
ans += val;
i++;
}
return ans;
}
int main() {
printf("%d\n", atoi("130"));
printf("%d\n", atoi("1a0"));
return 0;
}