#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 */
char *amath_to_mathml(char *);
int /*<<< orphan*/ asprintf(char **, char *, char *, char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdin;
scalar_t__ strlen(char *);
int main(int argc, char *argv[]) {
  char buffer[1024];
  char *content = "";
  while (fgets(buffer, 1024, stdin))
    asprintf(&content, "%s%s", content, buffer);
  char *result = amath_to_mathml(content);
  printf("%s\n", result);
  if (strlen(result) > 0)
    free(result);
  if (strlen(content) > 0)
    free(content);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe88(%rip),%rax
mov    %rax,-0x418(%rbp)
lea    -0x410(%rbp),%rdi
mov    0x2e53(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     11d1 <main+0x71>
mov    -0x418(%rbp),%rdx
lea    -0x410(%rbp),%rcx
lea    -0x418(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   1070 <asprintf@plt>
jmp    1187 <main+0x27>
mov    -0x418(%rbp),%rdi
call   1080 <amath_to_mathml@plt>
mov    %rax,-0x420(%rbp)
mov    -0x420(%rbp),%rsi
lea    0xe13(%rip),%rdi
call   1050 <printf@plt>
mov    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jle    1219 <main+0xb9>
mov    -0x420(%rbp),%rdi
call   1030 <free@plt>
mov    -0x418(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%rax
jle    123b <main+0xdb>
mov    -0x418(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x410,%rsp
lea    0xe91(%rip),%rbx
mov    %rbx,0x8(%rsp)
mov    0x2e65(%rip),%r13
mov    0x0(%r13),%edx
lea    0x10(%rsp),%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     11ec <main+0x8c>
lea    0xe66(%rip),%rbx
lea    0xe57(%rip),%r14
lea    0x8(%rsp),%r15
lea    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
call   1070 <asprintf@plt>
mov    0x0(%r13),%edx
mov    %r12,%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
mov    0x8(%rsp),%rbx
test   %rax,%rax
jne    11c0 <main+0x60>
mov    %rbx,%rdi
call   1080 <amath_to_mathml@plt>
mov    %rax,%rbx
lea    0xe07(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jle    121b <main+0xbb>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %rax,%rax
jle    1235 <main+0xd5>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@stdin = global i32 0
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1024 x i8]
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %7
br label %9
9: ; preds = %14, %2
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%11 = load i32, i32* @stdin
%12 = call i64 @fgets(i8* %10, i32 1024, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %9
%15 = load i8*, i8** %7
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%17 = call i32 @asprintf(i8** %7, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16)
br label %9
18: ; preds = %9
%19 = load i8*, i8** %7
%20 = call i8* @amath_to_mathml(i8* %19)
store i8* %20, i8** %8
%21 = load i8*, i8** %8
%22 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %8
%24 = call i64 @strlen(i8* %23)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %18
%27 = load i8*, i8** %8
%28 = call i32 @free(i8* %27)
br label %29
29: ; preds = %26, %18
%30 = load i8*, i8** %7
%31 = call i64 @strlen(i8* %30)
%32 = icmp sgt i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i8*, i8** %7
%35 = call i32 @free(i8* %34)
br label %36
36: ; preds = %33, %29
ret i32 0
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@stdin = global i32 0
@.str.1 = [5 x i8] c"%s%s\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1024 x i8]
%4 = alloca i8*
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = bitcast i8** %4 to i8*
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %4
%7 = load i32, i32* @stdin
%8 = call i64 @fgets(i8* %5, i32 1024, i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %2, %10
%11 = phi i8* [ %16, %10 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ]
%12 = call i32 @asprintf(i8** %4, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %11, i8* %5)
%13 = load i32, i32* @stdin
%14 = call i64 @fgets(i8* %5, i32 1024, i32 %13)
%15 = icmp eq i64 %14, 0
%16 = load i8*, i8** %4
br i1 %15, label %17, label %10
17: ; preds = %10, %2
%18 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %2 ], [ %16, %10 ]
%19 = call i8* @amath_to_mathml(i8* %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = call i64 @strlen(i8* dereferenceable(1) %19)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = call i32 @free(i8* %19)
br label %25
25: ; preds = %23, %17
%26 = load i8*, i8** %4
%27 = call i64 @strlen(i8* dereferenceable(1) %26)
%28 = icmp sgt i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = call i32 @free(i8* %26)
br label %31
31: ; preds = %29, %25
ret i32 0
}