#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__ parse_expression_list(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strstr(char *, char *);
int parse_expression(char *str) {
  char *except;
  char str2[2 + 2 + 4 + 1];
  except = strstr(str, "EX");
  if (except) {
    strncpy(str2, str, except - str);
    str2[except - str] = 0;
    if (parse_expression_list(except + 2)) {
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<parse_expression>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeb9(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11ad <parse_expression+0x7d>
lea    -0x21(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
sub    %rcx,%rax
movb   $0x0,-0x21(%rbp,%rax,1)
mov    -0x18(%rbp),%rdi
add    $0x2,%rdi
call   1040 <parse_expression_list@plt>
cmp    $0x0,%rax
je     11a8 <parse_expression+0x78>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <parse_expression+0x84>
jmp    11ad <parse_expression+0x7d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_expression>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0xebd(%rip),%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     1185 <parse_expression+0x55>
mov    %rax,%rbx
mov    %rax,%r15
sub    %r14,%r15
lea    0x7(%rsp),%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x7(%rsp,%r15,1)
add    $0x2,%rbx
mov    %rbx,%rdi
call   1040 <parse_expression_list@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    1187 <parse_expression+0x57>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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 [9 x i8]
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i8* @strstr(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %32
10: ; preds = %1
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = load i8*, i8** %3
%15 = ptrtoint i8* %13 to i64
%16 = ptrtoint i8* %14 to i64
%17 = sub i64 %15, %16
%18 = trunc i64 %17 to i32
%19 = call i32 @strncpy(i8* %11, i8* %12, i32 %18)
%20 = load i8*, i8** %4
%21 = load i8*, i8** %3
%22 = ptrtoint i8* %20 to i64
%23 = ptrtoint i8* %21 to i64
%24 = sub i64 %22, %23
%25 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 %24
store i8 0, i8* %25
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i64 2
%28 = call i64 @parse_expression_list(i8* %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %31
30: ; preds = %10
store i32 -1, i32* %2
br label %33
31: ; preds = %10
br label %32
32: ; preds = %31, %1
store i32 0, i32* %2
br label %33
33: ; preds = %32, %30
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
@.str = [3 x i8] c"EX\00"
define i32 @parse_expression(i8* %0) {
%2 = alloca [9 x i8]
%3 = getelementptr inbounds [9 x i8], [9 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 %16, label %6
6: ; preds = %1
%7 = ptrtoint i8* %4 to i64
%8 = ptrtoint i8* %0 to i64
%9 = sub i64 %7, %8
%10 = trunc i64 %9 to i32
%11 = call i32 @strncpy(i8* %3, i8* %0, i32 %10)
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 %9
store i8 0, i8* %12
%13 = getelementptr inbounds i8, i8* %4, i64 2
%14 = call i64 @parse_expression_list(i8* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %6, %1
br label %17
17: ; preds = %6, %16
%18 = phi i32 [ 0, %16 ], [ -1, %6 ]
ret i32 %18
}