#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*/ assert(int /*<<< orphan*/);
int expr(char *, size_t *);
int /*<<< orphan*/ free(char *);
char *strdup(char const *);
int eval_expr(const char *expr_str, int vars[], int target) {
  size_t expr_i = 0;
  size_t var_i = 0;
  char *generated = strdup(expr_str);
  assert(generated != NULL);
  while (generated[expr_i] != '=') {
    if (generated[expr_i] == '_') {
      generated[expr_i] = vars[var_i++] + '0';
    }
    expr_i++;
  }
  generated[expr_i] = '\0';
  size_t cursor = 0;
  int res = expr(generated, &cursor);
  free(generated);
  return res == target;
}


x86 assembly (clang, -O0):
<eval_expr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
je     11e3 <eval_expr+0xa3>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
jne    11d2 <eval_expr+0x92>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    (%rax,%rcx,4),%eax
add    $0x30,%eax
mov    %al,%dl
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1182 <eval_expr+0x42>
mov    -0x30(%rbp),%rax
mov    -0x20(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movq   $0x0,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1040 <expr@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x3c(%rbp),%eax
cmp    -0x14(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eval_expr>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%r14d
mov    %rsi,%rbp
call   1060 <strdup@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1050 <assert@plt>
xor    %eax,%eax
mov    %rbx,%rcx
jmp    1182 <eval_expr+0x42>
nopl   0x0(%rax,%rax,1)
movzbl 0x0(%rbp,%rax,4),%edx
add    $0x1,%rax
add    $0x30,%dl
mov    %dl,(%rcx)
add    $0x1,%rcx
movzbl (%rcx),%edx
cmp    $0x5f,%dl
je     1170 <eval_expr+0x30>
cmp    $0x3d,%dl
jne    117e <eval_expr+0x3e>
movb   $0x0,(%rcx)
movq   $0x0,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <expr@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
cmp    %r14d,%ebp
sete   %al
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @eval_expr(i8* %0, i32* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i64 0, i64* %7
store i64 0, i64* %8
%12 = load i8*, i8** %4
%13 = call i8* @strdup(i8* %12)
store i8* %13, i8** %9
%14 = load i8*, i8** %9
%15 = icmp ne i8* %14, null
%16 = zext i1 %15 to i32
%17 = call i32 @assert(i32 %16)
br label %18
18: ; preds = %43, %3
%19 = load i8*, i8** %9
%20 = load i64, i64* %7
%21 = getelementptr inbounds i8, i8* %19, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp ne i32 %23, 61
br i1 %24, label %25, label %46
25: ; preds = %18
%26 = load i8*, i8** %9
%27 = load i64, i64* %7
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 95
br i1 %31, label %32, label %43
32: ; preds = %25
%33 = load i32*, i32** %5
%34 = load i64, i64* %8
%35 = add i64 %34, 1
store i64 %35, i64* %8
%36 = getelementptr inbounds i32, i32* %33, i64 %34
%37 = load i32, i32* %36
%38 = add nsw i32 %37, 48
%39 = trunc i32 %38 to i8
%40 = load i8*, i8** %9
%41 = load i64, i64* %7
%42 = getelementptr inbounds i8, i8* %40, i64 %41
store i8 %39, i8* %42
br label %43
43: ; preds = %32, %25
%44 = load i64, i64* %7
%45 = add i64 %44, 1
store i64 %45, i64* %7
br label %18
46: ; preds = %18
%47 = load i8*, i8** %9
%48 = load i64, i64* %7
%49 = getelementptr inbounds i8, i8* %47, i64 %48
store i8 0, i8* %49
store i64 0, i64* %10
%50 = load i8*, i8** %9
%51 = call i32 @expr(i8* %50, i64* %10)
store i32 %51, i32* %11
%52 = load i8*, i8** %9
%53 = call i32 @free(i8* %52)
%54 = load i32, i32* %11
%55 = load i32, i32* %6
%56 = icmp eq i32 %54, %55
%57 = zext i1 %56 to i32
ret i32 %57
}

LLVM IR (-O2):
define i32 @eval_expr(i8* nocapture %0, i32* nocapture %1, i32 %2) {
%4 = alloca i64
%5 = tail call i8* @strdup(i8* %0)
%6 = icmp ne i8* %5, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
br label %9
9: ; preds = %20, %3
%10 = phi i64 [ 0, %3 ], [ %21, %20 ]
%11 = phi i64 [ 0, %3 ], [ %22, %20 ]
%12 = getelementptr inbounds i8, i8* %5, i64 %11
%13 = load i8, i8* %12
switch i8 %13, label %20 [
i8 61, label %23
i8 95, label %14
]
14: ; preds = %9
%15 = add i64 %10, 1
%16 = getelementptr inbounds i32, i32* %1, i64 %10
%17 = load i32, i32* %16
%18 = trunc i32 %17 to i8
%19 = add i8 %18, 48
store i8 %19, i8* %12
br label %20
20: ; preds = %9, %14
%21 = phi i64 [ %15, %14 ], [ %10, %9 ]
%22 = add i64 %11, 1
br label %9
23: ; preds = %9
store i8 0, i8* %12
%24 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%25 = call i32 @expr(i8* %5, i64* %4)
%26 = call i32 @free(i8* %5)
%27 = icmp eq i32 %25, %2
%28 = zext i1 %27 to i32
ret i32 %28
}