primary(lval) int *lval;
{
  char *ptr, sname[9];
  int num[1];
  int k;
  if (match("(")) {
    k = heir1(lval);
    needbrack(")");
    return k;
  }
  if (symname(sname)) {
    if (ptr = findloc(sname)) {
      getloc(ptr);
      lval[0] = ptr;
      lval[1] = ptr[10];
      if (ptr[9] == 3)
        lval[1] = 2;
      if (ptr[9] == 2)
        return 0;
      else
        return 1;
    }
    if (ptr = findglb(sname))
      if (ptr[9] != 4) {
        lval[0] = ptr;
        lval[1] = 0;
        if (ptr[9] != 2)
          return 1;
        immed();
        outstr(ptr);
        nl();
        lval[1] = ptr[10];
        return 0;
      }
    ptr = addglb(sname, 4, 2, 0);
    lval[0] = ptr;
    lval[1] = 0;
    return 0;
  }
  if (constant(num))
    return (lval[0] = lval[1] = 0);
  else {
    error("invalid expression");
    immed();
    outdec(0);
    nl();
    junk();
    return 0;
  }
}


x86 assembly (clang, -O0):
<primary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   10e0 <match@plt>
cmp    $0x0,%eax
je     123a <primary+0x4a>
mov    -0x10(%rbp),%rdi
mov    $0x0,%al
call   1090 <heir1@plt>
mov    %eax,-0x2c(%rbp)
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   10f0 <needbrack@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1415 <primary+0x225>
lea    -0x21(%rbp),%rdi
mov    $0x0,%al
call   10a0 <symname@plt>
cmp    $0x0,%eax
je     13ad <primary+0x1bd>
lea    -0x21(%rbp),%rdi
mov    $0x0,%al
call   1080 <findloc@plt>
cltq
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     12d4 <primary+0xe4>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1110 <getloc@plt>
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
movsbl 0xa(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%rax
movsbl 0x9(%rax),%eax
cmp    $0x3,%eax
jne    12ab <primary+0xbb>
mov    -0x10(%rbp),%rax
movl   $0x2,0x4(%rax)
mov    -0x18(%rbp),%rax
movsbl 0x9(%rax),%eax
cmp    $0x2,%eax
jne    12c8 <primary+0xd8>
movl   $0x0,-0x4(%rbp)
jmp    1415 <primary+0x225>
movl   $0x1,-0x4(%rbp)
jmp    1415 <primary+0x225>
lea    -0x21(%rbp),%rdi
mov    $0x0,%al
call   10d0 <findglb@plt>
cltq
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     136d <primary+0x17d>
mov    -0x18(%rbp),%rax
movsbl 0x9(%rax),%eax
cmp    $0x4,%eax
je     1368 <primary+0x178>
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x18(%rbp),%rax
movsbl 0x9(%rax),%eax
cmp    $0x2,%eax
je     1334 <primary+0x144>
movl   $0x1,-0x4(%rbp)
jmp    1415 <primary+0x225>
mov    $0x0,%al
call   1050 <immed@plt>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1070 <outstr@plt>
mov    $0x0,%al
call   1040 <nl@plt>
mov    -0x18(%rbp),%rax
movsbl 0xa(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1415 <primary+0x225>
jmp    136d <primary+0x17d>
lea    -0x21(%rbp),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1060 <addglb@plt>
cltq
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,0x4(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1415 <primary+0x225>
lea    -0x28(%rbp),%rdi
mov    $0x0,%al
call   10c0 <constant@plt>
cmp    $0x0,%eax
je     13e2 <primary+0x1f2>
mov    -0x10(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1415 <primary+0x225>
lea    0xc1b(%rip),%rdi
mov    $0x0,%al
call   1100 <error@plt>
mov    $0x0,%al
call   1050 <immed@plt>
xor    %edi,%edi
mov    $0x0,%al
call   10b0 <outdec@plt>
mov    $0x0,%al
call   1040 <nl@plt>
mov    $0x0,%al
call   1030 <junk@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<primary>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r15
lea    0xdfc(%rip),%rdi
xor    %eax,%eax
call   10e0 <match@plt>
test   %eax,%eax
je     1230 <primary+0x40>
mov    %r15,%rdi
xor    %eax,%eax
call   1090 <heir1@plt>
mov    %eax,%ebx
lea    0xde0(%rip),%rdi
xor    %eax,%eax
call   10f0 <needbrack@plt>
mov    %ebx,%eax
jmp    1354 <primary+0x164>
lea    0xb(%rsp),%rdi
xor    %eax,%eax
call   10a0 <symname@plt>
test   %eax,%eax
je     1289 <primary+0x99>
lea    0xb(%rsp),%rdi
xor    %eax,%eax
call   1080 <findloc@plt>
test   %eax,%eax
je     12a7 <primary+0xb7>
mov    %eax,%ebp
movslq %eax,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1110 <getloc@plt>
mov    %ebp,(%r15)
movsbl 0xa(%rbx),%eax
mov    %eax,0x4(%r15)
cmpb   $0x3,0x9(%rbx)
mov    $0x2,%ecx
cmovne %eax,%ecx
mov    %ecx,0x4(%r15)
xor    %ebp,%ebp
cmpb   $0x2,0x9(%rbx)
setne  %bpl
jmp    1352 <primary+0x162>
xor    %ebp,%ebp
lea    0x14(%rsp),%rdi
xor    %eax,%eax
call   10c0 <constant@plt>
test   %eax,%eax
je     12e8 <primary+0xf8>
movq   $0x0,(%r15)
jmp    1352 <primary+0x162>
xor    %ebp,%ebp
lea    0xb(%rsp),%rdi
xor    %eax,%eax
call   10d0 <findglb@plt>
test   %eax,%eax
je     12c3 <primary+0xd3>
movslq %eax,%r14
cmpb   $0x4,0x9(%r14)
jne    1318 <primary+0x128>
lea    0xb(%rsp),%rdi
mov    $0x4,%esi
mov    $0x2,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1060 <addglb@plt>
mov    %eax,(%r15)
movl   $0x0,0x4(%r15)
jmp    1352 <primary+0x162>
lea    0xd15(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1100 <error@plt>
xor    %eax,%eax
call   1050 <immed@plt>
xor    %edi,%edi
xor    %eax,%eax
call   10b0 <outdec@plt>
xor    %eax,%eax
call   1040 <nl@plt>
xor    %eax,%eax
call   1030 <junk@plt>
jmp    1352 <primary+0x162>
mov    %r14d,(%r15)
movl   $0x0,0x4(%r15)
mov    $0x1,%ebp
cmpb   $0x2,0x9(%r14)
jne    1352 <primary+0x162>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <immed@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1070 <outstr@plt>
xor    %eax,%eax
call   1040 <nl@plt>
movsbl 0xa(%r14),%eax
mov    %eax,0x4(%r15)
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"(\00"
@.str.1 = [2 x i8] c")\00"
@.str.2 = [19 x i8] c"invalid expression\00"
define i32 @primary(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca [9 x i8]
%6 = alloca [1 x i32]
%7 = alloca i32
store i32* %0, i32** %3
%8 = call i32 (i8*, ...) bitcast (i32 (...)* @match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %1
%11 = load i32*, i32** %3
%12 = call i32 (i32*, ...) bitcast (i32 (...)* @heir1 to i32 (i32*, ...)*)(i32* %11)
store i32 %12, i32* %7
%13 = call i32 (i8*, ...) bitcast (i32 (...)* @needbrack to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = load i32, i32* %7
store i32 %14, i32* %2
br label %117
15: ; preds = %1
%16 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%17 = call i32 (i8*, ...) bitcast (i32 (...)* @symname to i32 (i8*, ...)*)(i8* %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %102
19: ; preds = %15
%20 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%21 = call i32 (i8*, ...) bitcast (i32 (...)* @findloc to i32 (i8*, ...)*)(i8* %20)
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %4
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %54
25: ; preds = %19
%26 = load i8*, i8** %4
%27 = call i32 (i8*, ...) bitcast (i32 (...)* @getloc to i32 (i8*, ...)*)(i8* %26)
%28 = load i8*, i8** %4
%29 = ptrtoint i8* %28 to i32
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 0
store i32 %29, i32* %31
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 10
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = load i32*, i32** %3
%37 = getelementptr inbounds i32, i32* %36, i64 1
store i32 %35, i32* %37
%38 = load i8*, i8** %4
%39 = getelementptr inbounds i8, i8* %38, i64 9
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 3
br i1 %42, label %43, label %46
43: ; preds = %25
%44 = load i32*, i32** %3
%45 = getelementptr inbounds i32, i32* %44, i64 1
store i32 2, i32* %45
br label %46
46: ; preds = %43, %25
%47 = load i8*, i8** %4
%48 = getelementptr inbounds i8, i8* %47, i64 9
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 2
br i1 %51, label %52, label %53
52: ; preds = %46
store i32 0, i32* %2
br label %117
53: ; preds = %46
store i32 1, i32* %2
br label %117
54: ; preds = %19
%55 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%56 = call i32 (i8*, ...) bitcast (i32 (...)* @findglb to i32 (i8*, ...)*)(i8* %55)
%57 = sext i32 %56 to i64
%58 = inttoptr i64 %57 to i8*
store i8* %58, i8** %4
%59 = icmp ne i8* %58, null
br i1 %59, label %60, label %91
60: ; preds = %54
%61 = load i8*, i8** %4
%62 = getelementptr inbounds i8, i8* %61, i64 9
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp ne i32 %64, 4
br i1 %65, label %66, label %90
66: ; preds = %60
%67 = load i8*, i8** %4
%68 = ptrtoint i8* %67 to i32
%69 = load i32*, i32** %3
%70 = getelementptr inbounds i32, i32* %69, i64 0
store i32 %68, i32* %70
%71 = load i32*, i32** %3
%72 = getelementptr inbounds i32, i32* %71, i64 1
store i32 0, i32* %72
%73 = load i8*, i8** %4
%74 = getelementptr inbounds i8, i8* %73, i64 9
%75 = load i8, i8* %74
%76 = sext i8 %75 to i32
%77 = icmp ne i32 %76, 2
br i1 %77, label %78, label %79
78: ; preds = %66
store i32 1, i32* %2
br label %117
79: ; preds = %66
%80 = call i32 (...) @immed()
%81 = load i8*, i8** %4
%82 = call i32 (i8*, ...) bitcast (i32 (...)* @outstr to i32 (i8*, ...)*)(i8* %81)
%83 = call i32 (...) @nl()
%84 = load i8*, i8** %4
%85 = getelementptr inbounds i8, i8* %84, i64 10
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = load i32*, i32** %3
%89 = getelementptr inbounds i32, i32* %88, i64 1
store i32 %87, i32* %89
store i32 0, i32* %2
br label %117
90: ; preds = %60
br label %91
91: ; preds = %90, %54
%92 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%93 = call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @addglb to i32 (i8*, i32, i32, i32, ...)*)(i8* %92, i32 4, i32 2, i32 0)
%94 = sext i32 %93 to i64
%95 = inttoptr i64 %94 to i8*
store i8* %95, i8** %4
%96 = load i8*, i8** %4
%97 = ptrtoint i8* %96 to i32
%98 = load i32*, i32** %3
%99 = getelementptr inbounds i32, i32* %98, i64 0
store i32 %97, i32* %99
%100 = load i32*, i32** %3
%101 = getelementptr inbounds i32, i32* %100, i64 1
store i32 0, i32* %101
store i32 0, i32* %2
br label %117
102: ; preds = %15
%103 = getelementptr inbounds [1 x i32], [1 x i32]* %6, i64 0, i64 0
%104 = call i32 (i32*, ...) bitcast (i32 (...)* @constant to i32 (i32*, ...)*)(i32* %103)
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %111
106: ; preds = %102
%107 = load i32*, i32** %3
%108 = getelementptr inbounds i32, i32* %107, i64 1
store i32 0, i32* %108
%109 = load i32*, i32** %3
%110 = getelementptr inbounds i32, i32* %109, i64 0
store i32 0, i32* %110
store i32 0, i32* %2
br label %117
111: ; preds = %102
%112 = call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%113 = call i32 (...) @immed()
%114 = call i32 (i32, ...) bitcast (i32 (...)* @outdec to i32 (i32, ...)*)(i32 0)
%115 = call i32 (...) @nl()
%116 = call i32 (...) @junk()
store i32 0, i32* %2
br label %117
117: ; preds = %111, %106, %91, %79, %78, %53, %52, %10
%118 = load i32, i32* %2
ret i32 %118
}

LLVM IR (-O2):
@.str = [2 x i8] c"(\00"
@.str.1 = [2 x i8] c")\00"
@.str.2 = [19 x i8] c"invalid expression\00"
define i32 @primary(i32* %0) {
%2 = alloca [9 x i8]
%3 = alloca [1 x i32]
%4 = getelementptr inbounds [9 x i8], [9 x i8]* %2, i64 0, i64 0
%5 = bitcast [1 x i32]* %3 to i8*
%6 = tail call i32 (i8*, ...) bitcast (i32 (...)* @match to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %1
%9 = tail call i32 (i32*, ...) bitcast (i32 (...)* @heir1 to i32 (i32*, ...)*)(i32* %0)
%10 = tail call i32 (i8*, ...) bitcast (i32 (...)* @needbrack to i32 (i8*, ...)*)(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %67
11: ; preds = %1
%12 = call i32 (i8*, ...) bitcast (i32 (...)* @symname to i32 (i8*, ...)*)(i8* %4)
%13 = icmp eq i32 %12, 0
br i1 %13, label %55, label %14
14: ; preds = %11
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @findloc to i32 (i8*, ...)*)(i8* %4)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
%18 = icmp eq i32 %15, 0
br i1 %18, label %32, label %19
19: ; preds = %14
%20 = call i32 (i8*, ...) bitcast (i32 (...)* @getloc to i32 (i8*, ...)*)(i8* %17)
store i32 %15, i32* %0
%21 = getelementptr inbounds i8, i8* %17, i64 10
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %23, i32* %24
%25 = getelementptr inbounds i8, i8* %17, i64 9
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 3
%28 = select i1 %27, i32 2, i32 %23
store i32 %28, i32* %24
%29 = load i8, i8* %25
%30 = icmp ne i8 %29, 2
%31 = zext i1 %30 to i32
br label %67
32: ; preds = %14
%33 = call i32 (i8*, ...) bitcast (i32 (...)* @findglb to i32 (i8*, ...)*)(i8* %4)
%34 = sext i32 %33 to i64
%35 = inttoptr i64 %34 to i8*
%36 = icmp eq i32 %33, 0
br i1 %36, label %52, label %37
37: ; preds = %32
%38 = getelementptr inbounds i8, i8* %35, i64 9
%39 = load i8, i8* %38
%40 = icmp eq i8 %39, 4
br i1 %40, label %52, label %41
41: ; preds = %37
store i32 %33, i32* %0
%42 = getelementptr inbounds i32, i32* %0, i64 1
store i32 0, i32* %42
%43 = load i8, i8* %38
%44 = icmp eq i8 %43, 2
br i1 %44, label %45, label %67
45: ; preds = %41
%46 = call i32 (...) @immed()
%47 = call i32 (i8*, ...) bitcast (i32 (...)* @outstr to i32 (i8*, ...)*)(i8* %35)
%48 = call i32 (...) @nl()
%49 = getelementptr inbounds i8, i8* %35, i64 10
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
store i32 %51, i32* %42
br label %67
52: ; preds = %37, %32
%53 = call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @addglb to i32 (i8*, i32, i32, i32, ...)*)(i8* %4, i32 4, i32 2, i32 0)
store i32 %53, i32* %0
%54 = getelementptr inbounds i32, i32* %0, i64 1
store i32 0, i32* %54
br label %67
55: ; preds = %11
%56 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
%57 = call i32 (i32*, ...) bitcast (i32 (...)* @constant to i32 (i32*, ...)*)(i32* %56)
%58 = icmp eq i32 %57, 0
br i1 %58, label %61, label %59
59: ; preds = %55
%60 = getelementptr inbounds i32, i32* %0, i64 1
store i32 0, i32* %60
store i32 0, i32* %0
br label %67
61: ; preds = %55
%62 = call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%63 = call i32 (...) @immed()
%64 = call i32 (i32, ...) bitcast (i32 (...)* @outdec to i32 (i32, ...)*)(i32 0)
%65 = call i32 (...) @nl()
%66 = call i32 (...) @junk()
br label %67
67: ; preds = %19, %41, %61, %59, %52, %45, %8
%68 = phi i32 [ %9, %8 ], [ 0, %45 ], [ 0, %52 ], [ 0, %59 ], [ 0, %61 ], [ 1, %41 ], [ %31, %19 ]
ret i32 %68
}