#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ matho_init();
int /*<<< orphan*/ matho_parse(char *, int /*<<< orphan*/ *);
int matho_process(char *, char **);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  char *output;
  int rv;
  if (!matho_init()) {
    printf("Not enough memory.\n");
    exit(1);
  }
  matho_parse((char *)"x^2=4", NULL);
  rv = matho_process((char *)"solve x", &output);
  if (output) {
    printf("%s\n", output);
    if (rv) {
      free(output);
    } else {
      printf("Error return.\n");
    }
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1060 <matho_init@plt>
cmp    $0x0,%eax
jne    1197 <main+0x37>
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe76(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1070 <matho_parse@plt>
lea    0xe6c(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <matho_process@plt>
mov    %eax,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1202 <main+0xa2>
mov    -0x10(%rbp),%rsi
lea    0xe52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11ef <main+0x8f>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
jmp    11fd <main+0x9d>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1202 <main+0xa2>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1060 <matho_init@plt>
test   %eax,%eax
jne    1186 <main+0x26>
lea    0xe97(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
lea    0xe73(%rip),%rdi
xor    %esi,%esi
call   1070 <matho_parse@plt>
lea    0xe6b(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <matho_process@plt>
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     11c6 <main+0x66>
mov    %eax,%ebx
call   1040 <puts@plt>
test   %ebx,%ebx
jne    11cd <main+0x6d>
lea    0xe60(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Not enough memory.\0A\00"
@.str.1 = [6 x i8] c"x^2=4\00"
@.str.2 = [8 x i8] c"solve x\00"
@.str.3 = [4 x i8] c"%s\0A\00"
@.str.4 = [15 x i8] c"Error return.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (...) @matho_init()
%5 = icmp ne i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %0
%10 = call i32 @matho_parse(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* null)
%11 = call i32 @matho_process(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %2)
store i32 %11, i32* %3
%12 = load i8*, i8** %2
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %25
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %15)
%17 = load i32, i32* %3
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = load i8*, i8** %2
%21 = call i32 @free(i8* %20)
br label %24
22: ; preds = %14
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
br label %24
24: ; preds = %22, %19
br label %25
25: ; preds = %24, %9
%26 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"x^2=4\00"
@.str.2 = [8 x i8] c"solve x\00"
@str = [19 x i8] c"Not enough memory.\00"
@str.5 = [14 x i8] c"Error return.\00"
define i32 @main() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = tail call i32 (...) @matho_init()
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = tail call i32 @matho_parse(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* null)
%10 = call i32 @matho_process(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8** %1)
%11 = load i8*, i8** %1
%12 = icmp eq i8* %11, null
br i1 %12, label %21, label %13
13: ; preds = %8
%14 = call i32 @puts(i8* %11)
%15 = icmp eq i32 %10, 0
br i1 %15, label %19, label %16
16: ; preds = %13
%17 = load i8*, i8** %1
%18 = call i32 @free(i8* %17)
br label %21
19: ; preds = %13
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.5, i64 0, i64 0))
br label %21
21: ; preds = %16, %19, %8
%22 = call i32 @exit(i32 0)
unreachable
}