#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 */
typedef scalar_t__ str2;

/* Variables and functions */
int parse_expression_list(char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
char *strstr(char const *, char *);
int parse_expression(char *str) {
  char *except;
  char str2[8];
  int tmp;
  char const *__cil_tmp5;
  unsigned long __cil_tmp6;
  unsigned long __cil_tmp7;
  char *__cil_tmp8;
  char const *__cil_tmp9;
  int __cil_tmp10;
  int __cil_tmp11;
  unsigned long __cil_tmp12;
  unsigned long __cil_tmp13;
  char *__cil_tmp14;
  {
    {
      __cil_tmp5 = (char const *)str;
      except = strstr(__cil_tmp5, "EX");
    }
    if (except) {
      {
        __cil_tmp6 = 0 * 1UL;
        __cil_tmp7 = (unsigned long)(str2) + __cil_tmp6;
        __cil_tmp8 = (char *)__cil_tmp7;
        __cil_tmp9 = (char const *)str;
        __cil_tmp10 = except - str;
        strncpy(__cil_tmp8, __cil_tmp9, __cil_tmp10);
        __cil_tmp11 = except - str;
        __cil_tmp12 = __cil_tmp11 * 1UL;
        __cil_tmp13 = (unsigned long)(str2) + __cil_tmp12;
        *((char *)__cil_tmp13) = (char)0;
        __cil_tmp14 = except + 2;
        tmp = parse_expression_list(__cil_tmp14);
      }
      if (tmp) {
        return (-1);
      } else {
      }
    } else {
    }
    return (0);
  }
}


x86 assembly (clang, -O0):
<parse_expression>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     120a <parse_expression+0xda>
movq   $0x0,-0x38(%rbp)
lea    -0x20(%rbp),%rax
add    -0x38(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,-0x58(%rbp)
movslq -0x58(%rbp),%rax
shl    $0x0,%rax
mov    %rax,-0x60(%rbp)
lea    -0x20(%rbp),%rax
add    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x68(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rdi
call   1040 <parse_expression_list@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1200 <parse_expression+0xd0>
movl   $0xffffffff,-0x4(%rbp)
jmp    1216 <parse_expression+0xe6>
jmp    1205 <parse_expression+0xd5>
jmp    120f <parse_expression+0xdf>
jmp    120f <parse_expression+0xdf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_expression>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
lea    0xebe(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1185 <parse_expression+0x55>
mov    %rax,%rbx
mov    %rax,%r15
sub    %r14,%r15
mov    %rsp,%r12
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
movslq %r15d,%rax
movb   $0x0,(%rax,%r12,1)
add    $0x2,%rbx
mov    %rbx,%rdi
call   1040 <parse_expression_list@plt>
mov    %eax,%ecx
mov    $0xffffffff,%eax
test   %ecx,%ecx
jne    1187 <parse_expression+0x57>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"EX\00"
define i32 @parse_expression(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [8 x i8]
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i64
%15 = alloca i64
%16 = alloca i8*
store i8* %0, i8** %3
%17 = load i8*, i8** %3
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = call i8* @strstr(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %64
22: ; preds = %1
store i64 0, i64* %8
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%24 = ptrtoint i8* %23 to i64
%25 = load i64, i64* %8
%26 = add i64 %24, %25
store i64 %26, i64* %9
%27 = load i64, i64* %9
%28 = inttoptr i64 %27 to i8*
store i8* %28, i8** %10
%29 = load i8*, i8** %3
store i8* %29, i8** %11
%30 = load i8*, i8** %4
%31 = load i8*, i8** %3
%32 = ptrtoint i8* %30 to i64
%33 = ptrtoint i8* %31 to i64
%34 = sub i64 %32, %33
%35 = trunc i64 %34 to i32
store i32 %35, i32* %12
%36 = load i8*, i8** %10
%37 = load i8*, i8** %11
%38 = load i32, i32* %12
%39 = call i32 @strncpy(i8* %36, i8* %37, i32 %38)
%40 = load i8*, i8** %4
%41 = load i8*, i8** %3
%42 = ptrtoint i8* %40 to i64
%43 = ptrtoint i8* %41 to i64
%44 = sub i64 %42, %43
%45 = trunc i64 %44 to i32
store i32 %45, i32* %13
%46 = load i32, i32* %13
%47 = sext i32 %46 to i64
%48 = mul i64 %47, 1
store i64 %48, i64* %14
%49 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%50 = ptrtoint i8* %49 to i64
%51 = load i64, i64* %14
%52 = add i64 %50, %51
store i64 %52, i64* %15
%53 = load i64, i64* %15
%54 = inttoptr i64 %53 to i8*
store i8 0, i8* %54
%55 = load i8*, i8** %4
%56 = getelementptr inbounds i8, i8* %55, i64 2
store i8* %56, i8** %16
%57 = load i8*, i8** %16
%58 = call i32 @parse_expression_list(i8* %57)
store i32 %58, i32* %6
%59 = load i32, i32* %6
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %62
61: ; preds = %22
store i32 -1, i32* %2
br label %66
62: ; preds = %22
br label %63
63: ; preds = %62
br label %65
64: ; preds = %1
br label %65
65: ; preds = %64, %63
store i32 0, i32* %2
br label %66
66: ; preds = %65, %61
%67 = load i32, i32* %2
ret i32 %67
}

LLVM IR (-O2):
@.str = [3 x i8] c"EX\00"
define i32 @parse_expression(i8* %0) {
%2 = alloca [8 x i8]
%3 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%4 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %20, label %6
6: ; preds = %1
%7 = ptrtoint [8 x i8]* %2 to i64
%8 = ptrtoint i8* %4 to i64
%9 = ptrtoint i8* %0 to i64
%10 = sub i64 %8, %9
%11 = trunc i64 %10 to i32
%12 = call i32 @strncpy(i8* %3, i8* %0, i32 %11)
%13 = shl i64 %10, 32
%14 = ashr exact i64 %13, 32
%15 = add i64 %14, %7
%16 = inttoptr i64 %15 to i8*
store i8 0, i8* %16
%17 = getelementptr inbounds i8, i8* %4, i64 2
%18 = call i32 @parse_expression_list(i8* %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %1, %6
br label %21
21: ; preds = %6, %20
%22 = phi i32 [ 0, %20 ], [ -1, %6 ]
ret i32 %22
}