| /* | |
| * Copyright 2019, Data61 | |
| * Commonwealth Scientific and Industrial Research Organisation (CSIRO) | |
| * ABN 41 687 119 230. | |
| * | |
| * This software may be distributed and modified according to the terms of | |
| * the GNU General Public License version 2. Note that NO WARRANTY is provided. | |
| * See "LICENSE_GPLv2.txt" for details. | |
| * | |
| * @TAG(DATA61_GPL) | |
| */ | |
| $esc:(#include <stdio.h>) | |
| $esc:(#include <stdlib.h>) | |
| $esc:(#include <limits.h>) | |
| typedef void *SysState; | |
| #include <cogent-defns.h> | |
| #include "generated.c" | |
| #include <gum/anti/common.ac> | |
| #include <gum/anti/iterator.ac> | |
| $ty:(SysState) print_string($ty:((SysState, String)) arg) | |
| { | |
| printf("%s\n", arg.p2); | |
| return arg.p1; | |
| } | |
| $ty:(SysState) print_result($ty:((SysState, U32)) arg) | |
| { | |
| printf("The sum is: %d\n", arg.p2); | |
| return arg.p1; | |
| } | |
| int main(int argc, char **argv) | |
| { | |
| $ty:((SysState, U32)) arg; | |
| if (argc != 2) { | |
| fprintf(stderr, "Usage: %s <num>\n", argv[0]); | |
| exit(1); | |
| } | |
| arg.p2 = atoi(argv[1]); | |
| if (arg.p2 == 0 || arg.p2 == UINT_MAX) { | |
| fprintf(stderr, "Invalid input %s\n", argv[1]); | |
| exit(1); | |
| } | |
| printf("%u\n", arg.p2); | |
| $exp:sum(arg); | |
| return 0; | |
| } |