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();
        outname(ptr);
        nl();
        lval[1] = lval[2] = 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   1080 <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    141c <primary+0x22c>
lea    -0x21(%rbp),%rdi
mov    $0x0,%al
call   1090 <symname@plt>
cmp    $0x0,%eax
je     13b4 <primary+0x1c4>
lea    -0x21(%rbp),%rdi
mov    $0x0,%al
call   1070 <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    141c <primary+0x22c>
movl   $0x1,-0x4(%rbp)
jmp    141c <primary+0x22c>
lea    -0x21(%rbp),%rdi
mov    $0x0,%al
call   10d0 <findglb@plt>
cltq
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1374 <primary+0x184>
mov    -0x18(%rbp),%rax
movsbl 0x9(%rax),%eax
cmp    $0x4,%eax
je     136f <primary+0x17f>
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    141c <primary+0x22c>
mov    $0x0,%al
call   1050 <immed@plt>
mov    -0x18(%rbp),%rdi
mov    $0x0,%al
call   10c0 <outname@plt>
mov    $0x0,%al
call   1040 <nl@plt>
mov    -0x18(%rbp),%rax
movsbl 0xa(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
movl   $0x0,-0x4(%rbp)
jmp    141c <primary+0x22c>
jmp    1374 <primary+0x184>
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    141c <primary+0x22c>
lea    -0x28(%rbp),%rdi
mov    $0x0,%al
call   10b0 <constant@plt>
cmp    $0x0,%eax
je     13e9 <primary+0x1f9>
mov    -0x10(%rbp),%rax
movl   $0x0,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    141c <primary+0x22c>
lea    0xc14(%rip),%rdi
mov    $0x0,%al
call   1100 <error@plt>
mov    $0x0,%al
call   1050 <immed@plt>
xor    %edi,%edi
mov    $0x0,%al
call   10a0 <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   1080 <heir1@plt>
mov    %eax,%ebx
lea    0xde0(%rip),%rdi
xor    %eax,%eax
call   10f0 <needbrack@plt>
mov    %ebx,%eax
jmp    1358 <primary+0x168>
lea    0xb(%rsp),%rdi
xor    %eax,%eax
call   1090 <symname@plt>
test   %eax,%eax
je     1289 <primary+0x99>
lea    0xb(%rsp),%rdi
xor    %eax,%eax
call   1070 <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    1356 <primary+0x166>
xor    %ebp,%ebp
lea    0x14(%rsp),%rdi
xor    %eax,%eax
call   10b0 <constant@plt>
test   %eax,%eax
je     12e8 <primary+0xf8>
movq   $0x0,(%r15)
jmp    1356 <primary+0x166>
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    1356 <primary+0x166>
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   10a0 <outdec@plt>
xor    %eax,%eax
call   1040 <nl@plt>
xor    %eax,%eax
call   1030 <junk@plt>
jmp    1356 <primary+0x166>
mov    %r14d,(%r15)
movl   $0x0,0x4(%r15)
mov    $0x1,%ebp
cmpb   $0x2,0x9(%r14)
jne    1356 <primary+0x166>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <immed@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   10c0 <outname@plt>
xor    %eax,%eax
call   1040 <nl@plt>
movsbl 0xa(%r14),%eax
mov    %eax,0x8(%r15)
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 %119
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 %104
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 %119
53: ; preds = %46
store i32 1, i32* %2
br label %119
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 %93
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 %92
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 %119
79: ; preds = %66
%80 = call i32 (...) @immed()
%81 = load i8*, i8** %4
%82 = call i32 (i8*, ...) bitcast (i32 (...)* @outname 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 2
store i32 %87, i32* %89
%90 = load i32*, i32** %3
%91 = getelementptr inbounds i32, i32* %90, i64 1
store i32 %87, i32* %91
store i32 0, i32* %2
br label %119
92: ; preds = %60
br label %93
93: ; preds = %92, %54
%94 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%95 = call i32 (i8*, i32, i32, i32, ...) bitcast (i32 (...)* @addglb to i32 (i8*, i32, i32, i32, ...)*)(i8* %94, i32 4, i32 2, i32 0)
%96 = sext i32 %95 to i64
%97 = inttoptr i64 %96 to i8*
store i8* %97, i8** %4
%98 = load i8*, i8** %4
%99 = ptrtoint i8* %98 to i32
%100 = load i32*, i32** %3
%101 = getelementptr inbounds i32, i32* %100, i64 0
store i32 %99, i32* %101
%102 = load i32*, i32** %3
%103 = getelementptr inbounds i32, i32* %102, i64 1
store i32 0, i32* %103
store i32 0, i32* %2
br label %119
104: ; preds = %15
%105 = getelementptr inbounds [1 x i32], [1 x i32]* %6, i64 0, i64 0
%106 = call i32 (i32*, ...) bitcast (i32 (...)* @constant to i32 (i32*, ...)*)(i32* %105)
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %113
108: ; preds = %104
%109 = load i32*, i32** %3
%110 = getelementptr inbounds i32, i32* %109, i64 1
store i32 0, i32* %110
%111 = load i32*, i32** %3
%112 = getelementptr inbounds i32, i32* %111, i64 0
store i32 0, i32* %112
store i32 0, i32* %2
br label %119
113: ; preds = %104
%114 = call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%115 = call i32 (...) @immed()
%116 = call i32 (i32, ...) bitcast (i32 (...)* @outdec to i32 (i32, ...)*)(i32 0)
%117 = call i32 (...) @nl()
%118 = call i32 (...) @junk()
store i32 0, i32* %2
br label %119
119: ; preds = %113, %108, %93, %79, %78, %53, %52, %10
%120 = load i32, i32* %2
ret i32 %120
}

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 %68
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 %56, 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 %68
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 %53, 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 %53, 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 %68
45: ; preds = %41
%46 = call i32 (...) @immed()
%47 = call i32 (i8*, ...) bitcast (i32 (...)* @outname 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
%52 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %51, i32* %52
store i32 %51, i32* %42
br label %68
53: ; preds = %37, %32
%54 = 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 %54, i32* %0
%55 = getelementptr inbounds i32, i32* %0, i64 1
store i32 0, i32* %55
br label %68
56: ; preds = %11
%57 = getelementptr inbounds [1 x i32], [1 x i32]* %3, i64 0, i64 0
%58 = call i32 (i32*, ...) bitcast (i32 (...)* @constant to i32 (i32*, ...)*)(i32* %57)
%59 = icmp eq i32 %58, 0
br i1 %59, label %62, label %60
60: ; preds = %56
%61 = getelementptr inbounds i32, i32* %0, i64 1
store i32 0, i32* %61
store i32 0, i32* %0
br label %68
62: ; preds = %56
%63 = call i32 (i8*, ...) bitcast (i32 (...)* @error to i32 (i8*, ...)*)(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%64 = call i32 (...) @immed()
%65 = call i32 (i32, ...) bitcast (i32 (...)* @outdec to i32 (i32, ...)*)(i32 0)
%66 = call i32 (...) @nl()
%67 = call i32 (...) @junk()
br label %68
68: ; preds = %19, %41, %62, %60, %53, %45, %8
%69 = phi i32 [ %9, %8 ], [ 0, %45 ], [ 0, %53 ], [ 0, %60 ], [ 0, %62 ], [ 1, %41 ], [ %31, %19 ]
ret i32 %69
}