#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*/ expr(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
char *getstr();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main() {
  char *s;
  printf("Enter an expression:\n");
  if (!(s = getstr()))
    goto alocerr;
  printf("= %lf\n", expr(s));
  free(s);
  return 0;
alocerr:
  fprintf(stderr, "Allocation Error! Core Dumped!\n");
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getstr@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1187 <main+0x37>
jmp    11b5 <main+0x65>
mov    -0x10(%rbp),%rdi
call   1050 <expr@plt>
mov    %eax,%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d1 <main+0x81>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
lea    0xe58(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xebd(%rip),%rdi
call   1040 <puts@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1070 <getstr@plt>
test   %rax,%rax
je     11a2 <main+0x42>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <expr@plt>
lea    0xe71(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
jmp    11bc <main+0x5c>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter an expression:\0A\00"
@.str.1 = [7 x i8] c"= %lf\0A\00"
@stderr = global i32 0
@.str.2 = [32 x i8] c"Allocation Error! Core Dumped!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = call i8* (...) @getstr()
store i8* %4, i8** %2
%5 = icmp ne i8* %4, null
br i1 %5, label %7, label %6
6: ; preds = %0
br label %13
7: ; preds = %0
%8 = load i8*, i8** %2
%9 = call i32 @expr(i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i8*, i8** %2
%12 = call i32 @free(i8* %11)
store i32 0, i32* %1
br label %16
13: ; preds = %6
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %16
16: ; preds = %13, %7
%17 = load i32, i32* %1
ret i32 %17
}

LLVM IR (-O2):
@.str.1 = [7 x i8] c"= %lf\0A\00"
@stderr = global i32 0
@.str.2 = [32 x i8] c"Allocation Error! Core Dumped!\0A\00"
@str = [21 x i8] c"Enter an expression:\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%2 = tail call i8* (...) @getstr()
%3 = icmp eq i8* %2, null
br i1 %3, label %8, label %4
4: ; preds = %0
%5 = tail call i32 @expr(i8* %2)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @free(i8* %2)
br label %11
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %8, %4
%12 = phi i32 [ 0, %4 ], [ 1, %8 ]
ret i32 %12
}