#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 BASM_PP_Expand(char **, char **, char *);
int BASM_PP_ExpandBinary(char *, char *, char *, char *);
char *BASM_PP_PrintName(char *, char *);
char *BASM_PP_PrintToken(char *, char *, int);
char *BASM_Parse_Token(char *, char *, int *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int BASM_PP_LineArith(char *str) {
  char lbuf[4096];
  char b[256], b2[256], b3[256];
  char *s, *s1, *s2, *t, *t1;
  int i, ty, ty2, ty3, ni;
  ni = 0;
  s = str;
  t = lbuf;
  while (*s) {
    s = BASM_Parse_Token(s, b, &ty);
    s1 = BASM_Parse_Token(s, b2, &ty2);
    s2 = BASM_Parse_Token(s1, b3, &ty3);
    if ((ty == 2) && (ty2 == 6) && (ty3 == 2)) {
      i = BASM_PP_ExpandBinary(b, b2, b3, b2);
      if (i >= 0) {
        s = s2;
        t = BASM_PP_PrintName(t, b2);
        ni++;
        continue;
      }
      t = BASM_PP_PrintName(t, b);
      continue;
    }
    if (!strcmp(b, "(") && !strcmp(b3, ")") && (ty2 == 2)) {
      t = BASM_PP_PrintName(t, b2);
      ni++;
      continue;
    }
    if (ty == 1) {
      i = BASM_PP_Expand(&s, &t, b);
      if (i > 0) {
        ni++;
        continue;
      }
      t = BASM_PP_PrintName(t, b);
      continue;
    }
    t = BASM_PP_PrintToken(t, b, ty);
  }
  *t = 0;
  strcpy(str, lbuf);
  return (ni);
}


x86 assembly (clang, -O0):
<BASM_PP_LineArith>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1350,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x134c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x1318(%rbp)
lea    -0x1010(%rbp),%rax
mov    %rax,-0x1330(%rbp)
mov    -0x1318(%rbp),%rax
cmpb   $0x0,(%rax)
je     13d0 <BASM_PP_LineArith+0x260>
mov    -0x1318(%rbp),%rdi
lea    -0x1110(%rbp),%rsi
lea    -0x1340(%rbp),%rdx
call   1050 <BASM_Parse_Token@plt>
mov    %rax,-0x1318(%rbp)
mov    -0x1318(%rbp),%rdi
lea    -0x1210(%rbp),%rsi
lea    -0x1344(%rbp),%rdx
call   1050 <BASM_Parse_Token@plt>
mov    %rax,-0x1320(%rbp)
mov    -0x1320(%rbp),%rdi
lea    -0x1310(%rbp),%rsi
lea    -0x1348(%rbp),%rdx
call   1050 <BASM_Parse_Token@plt>
mov    %rax,-0x1328(%rbp)
cmpl   $0x2,-0x1340(%rbp)
jne    12cb <BASM_PP_LineArith+0x15b>
cmpl   $0x6,-0x1344(%rbp)
jne    12cb <BASM_PP_LineArith+0x15b>
cmpl   $0x2,-0x1348(%rbp)
jne    12cb <BASM_PP_LineArith+0x15b>
lea    -0x1110(%rbp),%rdi
lea    -0x1210(%rbp),%rsi
lea    -0x1310(%rbp),%rdx
lea    -0x1210(%rbp),%rcx
call   1060 <BASM_PP_ExpandBinary@plt>
mov    %eax,-0x133c(%rbp)
cmpl   $0x0,-0x133c(%rbp)
jl     12ac <BASM_PP_LineArith+0x13c>
mov    -0x1328(%rbp),%rax
mov    %rax,-0x1318(%rbp)
mov    -0x1330(%rbp),%rdi
lea    -0x1210(%rbp),%rsi
call   1090 <BASM_PP_PrintName@plt>
mov    %rax,-0x1330(%rbp)
mov    -0x134c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134c(%rbp)
jmp    11a2 <BASM_PP_LineArith+0x32>
mov    -0x1330(%rbp),%rdi
lea    -0x1110(%rbp),%rsi
call   1090 <BASM_PP_PrintName@plt>
mov    %rax,-0x1330(%rbp)
jmp    11a2 <BASM_PP_LineArith+0x32>
lea    -0x1110(%rbp),%rdi
lea    0xd27(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    133e <BASM_PP_LineArith+0x1ce>
lea    -0x1310(%rbp),%rdi
lea    0xd0d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    133e <BASM_PP_LineArith+0x1ce>
cmpl   $0x2,-0x1344(%rbp)
jne    133e <BASM_PP_LineArith+0x1ce>
mov    -0x1330(%rbp),%rdi
lea    -0x1210(%rbp),%rsi
call   1090 <BASM_PP_PrintName@plt>
mov    %rax,-0x1330(%rbp)
mov    -0x134c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134c(%rbp)
jmp    11a2 <BASM_PP_LineArith+0x32>
cmpl   $0x1,-0x1340(%rbp)
jne    13ab <BASM_PP_LineArith+0x23b>
lea    -0x1110(%rbp),%rdx
lea    -0x1318(%rbp),%rdi
lea    -0x1330(%rbp),%rsi
call   1080 <BASM_PP_Expand@plt>
mov    %eax,-0x133c(%rbp)
cmpl   $0x0,-0x133c(%rbp)
jle    138c <BASM_PP_LineArith+0x21c>
mov    -0x134c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x134c(%rbp)
jmp    11a2 <BASM_PP_LineArith+0x32>
mov    -0x1330(%rbp),%rdi
lea    -0x1110(%rbp),%rsi
call   1090 <BASM_PP_PrintName@plt>
mov    %rax,-0x1330(%rbp)
jmp    11a2 <BASM_PP_LineArith+0x32>
mov    -0x1330(%rbp),%rdi
lea    -0x1110(%rbp),%rsi
mov    -0x1340(%rbp),%edx
call   1030 <BASM_PP_PrintToken@plt>
mov    %rax,-0x1330(%rbp)
jmp    11a2 <BASM_PP_LineArith+0x32>
mov    -0x1330(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
lea    -0x1010(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x134c(%rbp),%eax
add    $0x1350,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BASM_PP_LineArith>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1338,%rsp
lea    0x330(%rsp),%rax
mov    %rdi,0x10(%rsp)
mov    %rax,(%rsp)
cmpb   $0x0,(%rdi)
je     12c4 <BASM_PP_LineArith+0x164>
movl   $0x0,0xc(%rsp)
lea    0x130(%rsp),%rbx
lea    0x230(%rsp),%rbp
lea    0x20(%rsp),%r13
lea    0x30(%rsp),%r14
lea    0x1c(%rsp),%r15
mov    %rdi,0x28(%rsp)
jmp    11f6 <BASM_PP_LineArith+0x96>
nopl   0x0(%rax)
lea    0x10(%rsp),%rdi
mov    %rsp,%rsi
mov    %rbx,%rdx
call   1070 <BASM_PP_Expand@plt>
test   %eax,%eax
jg     12a2 <BASM_PP_LineArith+0x142>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1080 <BASM_PP_PrintName@plt>
mov    %rax,(%rsp)
mov    0x10(%rsp),%rdi
cmpb   $0x0,(%rdi)
je     12b9 <BASM_PP_LineArith+0x159>
mov    %rbx,%rsi
lea    0x24(%rsp),%rdx
call   1050 <BASM_Parse_Token@plt>
mov    %rax,0x10(%rsp)
mov    %rax,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1050 <BASM_Parse_Token@plt>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1050 <BASM_Parse_Token@plt>
mov    %rax,%r12
mov    0x24(%rsp),%edx
mov    0x20(%rsp),%eax
cmp    $0x2,%edx
jne    1260 <BASM_PP_LineArith+0x100>
cmp    $0x6,%eax
jne    1260 <BASM_PP_LineArith+0x100>
cmpl   $0x2,0x1c(%rsp)
jne    1260 <BASM_PP_LineArith+0x100>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
mov    %rbp,%rcx
call   1060 <BASM_PP_ExpandBinary@plt>
test   %eax,%eax
js     11d8 <BASM_PP_LineArith+0x78>
mov    %r12,0x10(%rsp)
jmp    1292 <BASM_PP_LineArith+0x132>
nopl   0x0(%rax)
cmpw   $0x28,0x130(%rsp)
jne    1278 <BASM_PP_LineArith+0x118>
cmpw   $0x29,0x30(%rsp)
jne    1278 <BASM_PP_LineArith+0x118>
cmp    $0x2,%eax
je     1292 <BASM_PP_LineArith+0x132>
cmp    $0x1,%edx
je     11c0 <BASM_PP_LineArith+0x60>
mov    (%rsp),%rdi
mov    %rbx,%rsi
call   1030 <BASM_PP_PrintToken@plt>
jmp    11e4 <BASM_PP_LineArith+0x84>
mov    (%rsp),%rdi
mov    %rbp,%rsi
call   1080 <BASM_PP_PrintName@plt>
mov    %rax,(%rsp)
addl   $0x1,0xc(%rsp)
mov    0x10(%rsp),%rdi
cmpb   $0x0,(%rdi)
jne    11f6 <BASM_PP_LineArith+0x96>
mov    (%rsp),%rax
mov    0x28(%rsp),%rdi
mov    0xc(%rsp),%ebx
jmp    12c6 <BASM_PP_LineArith+0x166>
xor    %ebx,%ebx
movb   $0x0,(%rax)
lea    0x330(%rsp),%rsi
call   1040 <strcpy@plt>
mov    %ebx,%eax
add    $0x1338,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"(\00"
@.str.1 = [2 x i8] c")\00"
define i32 @BASM_PP_LineArith(i8* %0) {
%2 = alloca i8*
%3 = alloca [4096 x i8]
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %16
%17 = load i8*, i8** %2
store i8* %17, i8** %7
%18 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
store i8* %18, i8** %10
br label %19
19: ; preds = %92, %88, %85, %71, %56, %49, %1
%20 = load i8*, i8** %7
%21 = load i8, i8* %20
%22 = icmp ne i8 %21, 0
br i1 %22, label %23, label %97
23: ; preds = %19
%24 = load i8*, i8** %7
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%26 = call i8* @BASM_Parse_Token(i8* %24, i8* %25, i32* %13)
store i8* %26, i8** %7
%27 = load i8*, i8** %7
%28 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%29 = call i8* @BASM_Parse_Token(i8* %27, i8* %28, i32* %14)
store i8* %29, i8** %8
%30 = load i8*, i8** %8
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%32 = call i8* @BASM_Parse_Token(i8* %30, i8* %31, i32* %15)
store i8* %32, i8** %9
%33 = load i32, i32* %13
%34 = icmp eq i32 %33, 2
br i1 %34, label %35, label %60
35: ; preds = %23
%36 = load i32, i32* %14
%37 = icmp eq i32 %36, 6
br i1 %37, label %38, label %60
38: ; preds = %35
%39 = load i32, i32* %15
%40 = icmp eq i32 %39, 2
br i1 %40, label %41, label %60
41: ; preds = %38
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%43 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%44 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%45 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%46 = call i32 @BASM_PP_ExpandBinary(i8* %42, i8* %43, i8* %44, i8* %45)
store i32 %46, i32* %12
%47 = load i32, i32* %12
%48 = icmp sge i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %41
%50 = load i8*, i8** %9
store i8* %50, i8** %7
%51 = load i8*, i8** %10
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%53 = call i8* @BASM_PP_PrintName(i8* %51, i8* %52)
store i8* %53, i8** %10
%54 = load i32, i32* %16
%55 = add nsw i32 %54, 1
store i32 %55, i32* %16
br label %19
56: ; preds = %41
%57 = load i8*, i8** %10
%58 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%59 = call i8* @BASM_PP_PrintName(i8* %57, i8* %58)
store i8* %59, i8** %10
br label %19
60: ; preds = %38, %35, %23
%61 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%62 = call i32 @strcmp(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%63 = icmp ne i32 %62, 0
br i1 %63, label %77, label %64
64: ; preds = %60
%65 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%66 = call i32 @strcmp(i8* %65, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%67 = icmp ne i32 %66, 0
br i1 %67, label %77, label %68
68: ; preds = %64
%69 = load i32, i32* %14
%70 = icmp eq i32 %69, 2
br i1 %70, label %71, label %77
71: ; preds = %68
%72 = load i8*, i8** %10
%73 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%74 = call i8* @BASM_PP_PrintName(i8* %72, i8* %73)
store i8* %74, i8** %10
%75 = load i32, i32* %16
%76 = add nsw i32 %75, 1
store i32 %76, i32* %16
br label %19
77: ; preds = %68, %64, %60
%78 = load i32, i32* %13
%79 = icmp eq i32 %78, 1
br i1 %79, label %80, label %92
80: ; preds = %77
%81 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%82 = call i32 @BASM_PP_Expand(i8** %7, i8** %10, i8* %81)
store i32 %82, i32* %12
%83 = load i32, i32* %12
%84 = icmp sgt i32 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %80
%86 = load i32, i32* %16
%87 = add nsw i32 %86, 1
store i32 %87, i32* %16
br label %19
88: ; preds = %80
%89 = load i8*, i8** %10
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%91 = call i8* @BASM_PP_PrintName(i8* %89, i8* %90)
store i8* %91, i8** %10
br label %19
92: ; preds = %77
%93 = load i8*, i8** %10
%94 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%95 = load i32, i32* %13
%96 = call i8* @BASM_PP_PrintToken(i8* %93, i8* %94, i32 %95)
store i8* %96, i8** %10
br label %19
97: ; preds = %19
%98 = load i8*, i8** %10
store i8 0, i8* %98
%99 = load i8*, i8** %2
%100 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%101 = call i32 @strcpy(i8* %99, i8* %100)
%102 = load i32, i32* %16
ret i32 %102
}

LLVM IR (-O2):
define i32 @BASM_PP_LineArith(i8* %0) {
%2 = alloca [4096 x i8]
%3 = alloca [256 x i8]
%4 = alloca [256 x i8]
%5 = alloca [256 x i8]
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %2, i64 0, i64 0
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%15 = bitcast i8** %6 to i8*
%16 = bitcast i8** %7 to i8*
%17 = bitcast i32* %8 to i8*
%18 = bitcast i32* %9 to i8*
%19 = bitcast i32* %10 to i8*
store i8* %0, i8** %6
store i8* %11, i8** %7
%20 = load i8, i8* %0
%21 = icmp eq i8 %20, 0
br i1 %21, label %84, label %22
22: ; preds = %1
%23 = bitcast [256 x i8]* %3 to i16*
%24 = bitcast [256 x i8]* %5 to i16*
br label %25
25: ; preds = %22, %47
%26 = phi i8* [ %0, %22 ], [ %49, %47 ]
%27 = phi i32 [ 0, %22 ], [ %48, %47 ]
br label %28
28: ; preds = %25, %55
%29 = phi i8* [ %26, %25 ], [ %57, %55 ]
%30 = call i8* @BASM_Parse_Token(i8* %29, i8* %12, i32* %8)
store i8* %30, i8** %6
%31 = call i8* @BASM_Parse_Token(i8* %30, i8* %13, i32* %9)
%32 = call i8* @BASM_Parse_Token(i8* %31, i8* %14, i32* %10)
%33 = load i32, i32* %8
%34 = icmp eq i32 %33, 2
%35 = load i32, i32* %9
%36 = icmp eq i32 %35, 6
%37 = select i1 %34, i1 %36, i1 false
%38 = load i32, i32* %10
%39 = icmp eq i32 %38, 2
%40 = select i1 %37, i1 %39, i1 false
br i1 %40, label %41, label %60
41: ; preds = %28
%42 = call i32 @BASM_PP_ExpandBinary(i8* %12, i8* %13, i8* %14, i8* %13)
%43 = icmp sgt i32 %42, -1
br i1 %43, label %44, label %52
44: ; preds = %41
store i8* %32, i8** %6
%45 = load i8*, i8** %7
%46 = call i8* @BASM_PP_PrintName(i8* %45, i8* %13)
store i8* %46, i8** %7
br label %47
47: ; preds = %73, %44, %68
%48 = add nuw nsw i32 %27, 1
%49 = load i8*, i8** %6
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 0
br i1 %51, label %82, label %25
52: ; preds = %41
%53 = load i8*, i8** %7
%54 = call i8* @BASM_PP_PrintName(i8* %53, i8* %12)
store i8* %54, i8** %7
br label %55
55: ; preds = %52, %76, %79
%56 = phi i8* [ %54, %52 ], [ %78, %76 ], [ %81, %79 ]
%57 = load i8*, i8** %6
%58 = load i8, i8* %57
%59 = icmp eq i8 %58, 0
br i1 %59, label %84, label %28
60: ; preds = %28
%61 = load i16, i16* %23
%62 = icmp eq i16 %61, 40
br i1 %62, label %63, label %71
63: ; preds = %60
%64 = load i16, i16* %24
%65 = icmp eq i16 %64, 41
%66 = icmp eq i32 %35, 2
%67 = select i1 %65, i1 %66, i1 false
br i1 %67, label %68, label %71
68: ; preds = %63
%69 = load i8*, i8** %7
%70 = call i8* @BASM_PP_PrintName(i8* %69, i8* %13)
store i8* %70, i8** %7
br label %47
71: ; preds = %63, %60
%72 = icmp eq i32 %33, 1
br i1 %72, label %73, label %79
73: ; preds = %71
%74 = call i32 @BASM_PP_Expand(i8** %6, i8** %7, i8* %12)
%75 = icmp sgt i32 %74, 0
br i1 %75, label %47, label %76
76: ; preds = %73
%77 = load i8*, i8** %7
%78 = call i8* @BASM_PP_PrintName(i8* %77, i8* %12)
store i8* %78, i8** %7
br label %55
79: ; preds = %71
%80 = load i8*, i8** %7
%81 = call i8* @BASM_PP_PrintToken(i8* %80, i8* %12, i32 %33)
store i8* %81, i8** %7
br label %55
82: ; preds = %47
%83 = load i8*, i8** %7
br label %84
84: ; preds = %55, %82, %1
%85 = phi i8* [ %11, %1 ], [ %83, %82 ], [ %56, %55 ]
%86 = phi i32 [ 0, %1 ], [ %48, %82 ], [ %27, %55 ]
store i8 0, i8* %85
%87 = call i32 @strcpy(i8* %0, i8* %11)
ret i32 %86
}