// gcc -O2 -Wall -Wextra -Werror
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#define E_YOU_ARE_STUPID (-2)
typedef struct { uint64_t garbage; uint64_t more_garbage; } Result;
int UnsafeParse(uint64_t start, uint64_t end, Result* output);
int DoStuff(Result* a);
static inline int Parse(uint64_t start, uint64_t end, Result* output) {
if (start >= end) {
return E_YOU_ARE_STUPID;
}
if (output == 0) {
return E_YOU_ARE_STUPID;
}
return UnsafeParse(start, end, output);
}
int Run() {
Result* output = (Result*)malloc(sizeof(Result));
int code = Parse(0, 1024, output);
if (code == 0) {
DoStuff(output);
}
free(output);
return code;
}
Run():
pushq %rbp
movl $16, %edi
pushq %rbx
subq $8, %rsp
call malloc
movq %rax, %rbp
testq %rax, %rax
je .L5
movq %rax, %rdx
movl $1024, %esi
xorl %edi, %edi
call UnsafeParse(unsigned long, unsigned long, Result*)
movl %eax, %ebx
testl %eax, %eax
je .L8
.L2:
movq %rbp, %rdi
call free
addq $8, %rsp
movl %ebx, %eax
popq %rbx
popq %rbp
ret
.L8:
movq %rbp, %rdi
call DoStuff(Result*)
jmp .L2
.L5:
movl $-2, %ebx
jmp .L2