#include <stdint.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <unistd.h>
int g_increment = 17;
int g_uninitialized;
int g_more_than_one_byte_int = 512;
char g_values[] = {1, 2, 3};
int g_non_char_values[] = {300, 400, 500};
int increment(int x) {
int result = x + g_increment;
if (result < 30)
return result;
else
return 42;
}
void sum(int x) {
int result = 0;
for (size_t i = 0; i < (sizeof(g_values) / sizeof(g_values[0])); i++) {
result += g_values[i];
}
fprintf(stderr, "%s\n", (result < x) ? "foo" : "bar");
}
void sum_ints(int x) {
int result = 0;
for (size_t i = 0; i < (sizeof(g_non_char_values) / sizeof(g_non_char_values[0])); i++) {
result += g_non_char_values[i];
}
fprintf(stderr, "%s\n", (result < x) ? "foo" : "bar");
}
int main(int argc, char* argv[]) {
int x;
if (read(STDIN_FILENO, &x, sizeof(x)) != sizeof(x)) {
fprintf(stderr, "Failed to read x\n");
return -1;
}
x = ntohl(x);
fprintf(stderr, "%d\n", increment(x));
g_increment = 18;
fprintf(stderr, "%d\n", increment(x));
g_uninitialized = 101;
fprintf(stderr, "%s\n", (x < g_uninitialized) ? "smaller" : "greater or equal");
sum(x);
fprintf(stderr, "%s\n", (x < g_more_than_one_byte_int) ? "true" : "false");
sum_ints(x);
return 0;
}