#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*/ check_base(char *);
int /*<<< orphan*/ check_ops(char *);
int /*<<< orphan*/ eval_expr(char *, char *, char *, unsigned int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ free(char *);
char *get_expr(unsigned int);
unsigned int my_atoi(char *);
int /*<<< orphan*/ my_putstr(char *);
scalar_t__ strcmp(char *, char *);
int main(int ac, char **av) {
  unsigned int size;
  char *expr;
  int p;
  p = 0;
  if (ac != 4 && ac != 5) {
    my_putstr("Usage : ");
    my_putstr(av[0]);
    my_putstr(" base (\"0123456789\") ops (\"()+-*/%\") exp_len\n");
    exit(1);
  } else if (ac == 5 && strcmp(av[4], "-p") == 0)
    p = 1;
  check_base(av[1]);
  check_ops(av[2]);
  size = my_atoi(av[3]);
  expr = get_expr(size);
  eval_expr(av[1], av[2], expr, size, p);
  free(expr);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11ef <main+0x5f>
cmpl   $0x5,-0x8(%rbp)
je     11ef <main+0x5f>
lea    0xe38(%rip),%rdi
call   1060 <my_putstr@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1060 <my_putstr@plt>
lea    0xe29(%rip),%rdi
call   1060 <my_putstr@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
cmpl   $0x5,-0x8(%rbp)
jne    121e <main+0x8e>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xe2f(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    121e <main+0x8e>
movl   $0x1,-0x24(%rbp)
jmp    1223 <main+0x93>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <check_base@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <check_ops@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <my_atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1080 <get_expr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x14(%rbp),%ecx
mov    -0x24(%rbp),%r8d
call   1090 <eval_expr@plt>
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x4,%eax
jne    1211 <main+0x81>
xor    %r14d,%r14d
cmp    $0x5,%edi
jne    11c6 <main+0x36>
mov    0x20(%rbx),%rdi
lea    0xe80(%rip),%rsi
call   1050 <strcmp@plt>
xor    %r14d,%r14d
test   %rax,%rax
sete   %r14b
mov    0x8(%rbx),%rdi
call   1070 <check_base@plt>
mov    0x10(%rbx),%rdi
call   10a0 <check_ops@plt>
mov    0x18(%rbx),%rdi
call   1030 <my_atoi@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1080 <get_expr@plt>
mov    %rax,%r15
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
mov    %rax,%rdx
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1090 <eval_expr@plt>
mov    %r15,%rdi
call   1040 <free@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xde8(%rip),%rdi
call   1060 <my_putstr@plt>
mov    (%rbx),%rdi
call   1060 <my_putstr@plt>
lea    0xddd(%rip),%rdi
call   1060 <my_putstr@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"Usage : \00"
@.str.1 = [46 x i8] c" base (\220123456789\22) ops (\22()+-*/%\22) exp_len\0A\00"
@.str.2 = [3 x i8] c"-p\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 4
br i1 %10, label %11, label %22
11: ; preds = %2
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 5
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = call i32 @my_putstr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @my_putstr(i8* %18)
%20 = call i32 @my_putstr(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %11, %2
%23 = load i32, i32* %4
%24 = icmp eq i32 %23, 5
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 4
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %25
store i32 1, i32* %8
br label %32
32: ; preds = %31, %25, %22
br label %33
33: ; preds = %32
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @check_base(i8* %36)
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32 @check_ops(i8* %40)
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 3
%44 = load i8*, i8** %43
%45 = call i32 @my_atoi(i8* %44)
store i32 %45, i32* %6
%46 = load i32, i32* %6
%47 = call i8* @get_expr(i32 %46)
store i8* %47, i8** %7
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = load i8**, i8*** %5
%52 = getelementptr inbounds i8*, i8** %51, i64 2
%53 = load i8*, i8** %52
%54 = load i8*, i8** %7
%55 = load i32, i32* %6
%56 = load i32, i32* %8
%57 = call i32 @eval_expr(i8* %50, i8* %53, i8* %54, i32 %55, i32 %56)
%58 = load i8*, i8** %7
%59 = call i32 @free(i8* %58)
%60 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [9 x i8] c"Usage : \00"
@.str.1 = [46 x i8] c" base (\220123456789\22) ops (\22()+-*/%\22) exp_len\0A\00"
@.str.2 = [3 x i8] c"-p\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = and i32 %0, -2
%4 = icmp eq i32 %3, 4
br i1 %4, label %11, label %5
5: ; preds = %2
%6 = tail call i32 @my_putstr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%7 = load i8*, i8** %1
%8 = tail call i32 @my_putstr(i8* %7)
%9 = tail call i32 @my_putstr(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.1, i64 0, i64 0))
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = icmp eq i32 %0, 5
br i1 %12, label %13, label %19
13: ; preds = %11
%14 = getelementptr inbounds i8*, i8** %1, i64 4
%15 = load i8*, i8** %14
%16 = tail call i64 @strcmp(i8* %15, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
%18 = zext i1 %17 to i32
br label %19
19: ; preds = %13, %11
%20 = phi i32 [ 0, %11 ], [ %18, %13 ]
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = tail call i32 @check_base(i8* %22)
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @check_ops(i8* %25)
%27 = getelementptr inbounds i8*, i8** %1, i64 3
%28 = load i8*, i8** %27
%29 = tail call i32 @my_atoi(i8* %28)
%30 = tail call i8* @get_expr(i32 %29)
%31 = load i8*, i8** %21
%32 = load i8*, i8** %24
%33 = tail call i32 @eval_expr(i8* %31, i8* %32, i8* %30, i32 %29, i32 %20)
%34 = tail call i32 @free(i8* %30)
%35 = tail call i32 @exit(i32 0)
unreachable
}