#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 */
scalar_t__ addop();
scalar_t__ primary();
int /*<<< orphan*/ printf(char *);
int expression() {
  int sentinel = 0;
  if (primary()) {
    sentinel = 1;
    while (addop()) {
      if (primary()) {
        sentinel = 1;
      } else {
        printf("Expected Primary\n");
        sentinel = 0;
      }
    }
  } else {
    printf("Expecting primary\n");
  }
  return sentinel;
}


x86 assembly (clang, -O0):
<expression>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <primary@plt>
cmp    $0x0,%rax
je     11a2 <expression+0x72>
movl   $0x1,-0x4(%rbp)
mov    $0x0,%al
call   1030 <addop@plt>
cmp    $0x0,%rax
je     119d <expression+0x6d>
mov    $0x0,%al
call   1050 <primary@plt>
cmp    $0x0,%rax
je     1185 <expression+0x55>
movl   $0x1,-0x4(%rbp)
jmp    1198 <expression+0x68>
lea    0xe74(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1157 <expression+0x27>
jmp    11ae <expression+0x7e>
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expression>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <primary@plt>
test   %rax,%rax
je     1189 <expression+0x59>
xor    %eax,%eax
call   1040 <addop@plt>
test   %rax,%rax
je     1197 <expression+0x67>
lea    0xebd(%rip),%r14
jmp    116c <expression+0x3c>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <addop@plt>
test   %rax,%rax
je     119c <expression+0x6c>
xor    %eax,%eax
call   1050 <primary@plt>
mov    $0x1,%ebx
test   %rax,%rax
jne    1160 <expression+0x30>
mov    %r14,%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
jmp    1160 <expression+0x30>
lea    0xe70(%rip),%rdi
call   1030 <puts@plt>
jmp    119c <expression+0x6c>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Expected Primary\0A\00"
@.str.1 = [19 x i8] c"Expecting primary\0A\00"
define i32 @expression() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i64 (...) @primary()
%3 = icmp ne i64 %2, 0
br i1 %3, label %4, label %16
4: ; preds = %0
store i32 1, i32* %1
br label %5
5: ; preds = %14, %4
%6 = call i64 (...) @addop()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = call i64 (...) @primary()
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
store i32 1, i32* %1
br label %14
12: ; preds = %8
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %14
14: ; preds = %12, %11
br label %5
15: ; preds = %5
br label %18
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %15
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@str = [18 x i8] c"Expecting primary\00"
@str.2 = [17 x i8] c"Expected Primary\00"
define i32 @expression() {
%1 = tail call i64 (...) @primary()
%2 = icmp eq i64 %1, 0
br i1 %2, label %15, label %3
3: ; preds = %0
%4 = tail call i64 (...) @addop()
%5 = icmp eq i64 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %3, %11
%7 = tail call i64 (...) @primary()
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.2, i64 0, i64 0))
br label %11
11: ; preds = %6, %9
%12 = phi i32 [ 0, %9 ], [ 1, %6 ]
%13 = tail call i64 (...) @addop()
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %6
15: ; preds = %0
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %17
17: ; preds = %11, %3, %15
%18 = phi i32 [ 0, %15 ], [ 1, %3 ], [ %12, %11 ]
ret i32 %18
}