#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*/ exit(int /*<<< orphan*/);
int process_rhs(char *, int *);
int /*<<< orphan*/ puts(char *);
int sscanf(char *, char *, int *);
char *strchr(char *, char);
void process_eqn(char *eqn, int *variables) {
  int lhs_var;
  if (sscanf(eqn, "V%d", &lhs_var) != 1) {
    puts("Left side should be a variable!");
    exit(0);
  }
  char *curr = strchr(eqn, '=');
  if (curr == NULL) {
    puts("missing = sign");
    exit(0);
  }
  curr += 1;
  int val = process_rhs(curr, variables);
  variables[lhs_var] = val;
}


x86 assembly (clang, -O0):
<process_eqn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
je     1190 <process_eqn+0x40>
lea    0xe80(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c0 <process_eqn+0x70>
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <process_rhs@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_eqn>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xe9f(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1060 <sscanf@plt>
cmp    $0x1,%eax
jne    11a2 <process_eqn+0x52>
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11ab <process_eqn+0x5b>
add    $0x1,%rax
mov    %rax,%rdi
mov    %r14,%rsi
call   1050 <process_rhs@plt>
movslq 0x4(%rsp),%rcx
mov    %eax,(%r14,%rcx,4)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe5b(%rip),%rdi
jmp    11b2 <process_eqn+0x62>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"V%d\00"
@.str.1 = [32 x i8] c"Left side should be a variable!\00"
@.str.2 = [15 x i8] c"missing = sign\00"
define void @process_eqn(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%8 = load i8*, i8** %3
%9 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %5)
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = call i32 @puts(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @exit(i32 0)
unreachable
14: ; preds = %2
%15 = load i8*, i8** %3
%16 = call i8* @strchr(i8* %15, i8 signext 61)
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %14
%20 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @exit(i32 0)
unreachable
22: ; preds = %14
%23 = load i8*, i8** %6
%24 = getelementptr inbounds i8, i8* %23, i64 1
store i8* %24, i8** %6
%25 = load i8*, i8** %6
%26 = load i32*, i32** %4
%27 = call i32 @process_rhs(i8* %25, i32* %26)
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = load i32*, i32** %4
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %29, i64 %31
store i32 %28, i32* %32
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"V%d\00"
@.str.1 = [32 x i8] c"Left side should be a variable!\00"
@.str.2 = [15 x i8] c"missing = sign\00"
define void @process_eqn(i8* %0, i32* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
%6 = icmp eq i32 %5, 1
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @exit(i32 0)
unreachable
10: ; preds = %2
%11 = call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 61)
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @exit(i32 0)
unreachable
16: ; preds = %10
%17 = getelementptr inbounds i8, i8* %11, i64 1
%18 = call i32 @process_rhs(i8* %17, i32* %1)
%19 = load i32, i32* %3
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %1, i64 %20
store i32 %18, i32* %21
ret void
}