#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 */
scalar_t__ strlen(char *);
int /*<<< orphan*/ yy_delete_buffer(char *);
int /*<<< orphan*/ yylex_destroy();
int yyparse();
int compileST(char *pgm) {
  extern char *yy_scan_bytes();
  char *my_string_buffer = yy_scan_bytes(pgm, strlen(pgm) + 1);
  int my_parse_result = yyparse();
  if (my_parse_result)
    return -1;
  yy_delete_buffer(my_string_buffer);
  yylex_destroy();
  return 0;
}


x86 assembly (clang, -O0):
<compileST>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rsi
add    $0x1,%rsi
mov    $0x0,%al
call   1050 <yy_scan_bytes@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <yyparse@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11a3 <compileST+0x53>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ba <compileST+0x6a>
mov    -0x18(%rbp),%rdi
call   1060 <yy_delete_buffer@plt>
mov    $0x0,%al
call   1070 <yylex_destroy@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compileST>:
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    0x1(%rax),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <yy_scan_bytes@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1030 <yyparse@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
je     117e <compileST+0x2e>
pop    %rbx
ret
mov    %rbx,%rdi
call   1060 <yy_delete_buffer@plt>
xor    %eax,%eax
call   1070 <yylex_destroy@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @compileST(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = add nsw i64 %8, 1
%10 = call i8* (i8*, i64, ...) bitcast (i8* (...)* @yy_scan_bytes to i8* (i8*, i64, ...)*)(i8* %6, i64 %9)
store i8* %10, i8** %4
%11 = call i32 (...) @yyparse()
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %1
store i32 -1, i32* %2
br label %19
15: ; preds = %1
%16 = load i8*, i8** %4
%17 = call i32 @yy_delete_buffer(i8* %16)
%18 = call i32 (...) @yylex_destroy()
store i32 0, i32* %2
br label %19
19: ; preds = %15, %14
%20 = load i32, i32* %2
ret i32 %20
}

LLVM IR (-O2):
define i32 @compileST(i8* %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = add nsw i64 %2, 1
%4 = tail call i8* (i8*, i64, ...) bitcast (i8* (...)* @yy_scan_bytes to i8* (i8*, i64, ...)*)(i8* %0, i64 %3)
%5 = tail call i32 (...) @yyparse()
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %1
%8 = tail call i32 @yy_delete_buffer(i8* %4)
%9 = tail call i32 (...) @yylex_destroy()
br label %10
10: ; preds = %1, %7
%11 = phi i32 [ 0, %7 ], [ -1, %1 ]
ret i32 %11
}