#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 lexer(char);
int term(char *, int, int);
int factor(char string[], int count) {
  int ctr = 0;
  char letter;
  int token = 0;
  int checked = 0;
  do {
    letter = string[ctr];
    ctr++;
  } while (letter == ' ');
  token = lexer(letter);
  if (token == 1)
    checked = term(string, ctr, 1);
  else if (token == 9)
    checked = term(string, ctr, 2);
  else if (token == 7)
    checked = term(string, ctr, 3);
  else
    return 0;
  return checked;
}


x86 assembly (clang, -O0):
<factor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x20,%eax
je     1144 <factor+0x24>
movsbl -0x19(%rbp),%edi
call   1040 <lexer@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x1,-0x20(%rbp)
jne    1197 <factor+0x77>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    $0x1,%edx
call   1030 <term@plt>
mov    %eax,-0x24(%rbp)
jmp    11f3 <factor+0xd3>
cmpl   $0x9,-0x20(%rbp)
jne    11ba <factor+0x9a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    $0x2,%edx
call   1030 <term@plt>
mov    %eax,-0x24(%rbp)
jmp    11ee <factor+0xce>
cmpl   $0x7,-0x20(%rbp)
jne    11dd <factor+0xbd>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
mov    $0x3,%edx
call   1030 <term@plt>
mov    %eax,-0x24(%rbp)
jmp    11e9 <factor+0xc9>
movl   $0x0,-0x4(%rbp)
jmp    11f9 <factor+0xd9>
jmp    11ee <factor+0xce>
jmp    11f3 <factor+0xd3>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<factor>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl (%r14,%rbx,1),%eax
add    $0x1,%rbx
cmp    $0x20,%al
je     1130 <factor+0x10>
movsbl %al,%edi
call   1040 <lexer@plt>
cmp    $0x1,%eax
je     1160 <factor+0x40>
cmp    $0x7,%eax
je     115b <factor+0x3b>
cmp    $0x9,%eax
jne    1173 <factor+0x53>
mov    $0x2,%eax
jmp    1160 <factor+0x40>
mov    $0x3,%eax
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <term@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @factor(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i32 0, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %18, %2
%11 = load i8*, i8** %4
%12 = load i32, i32* %6
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
store i8 %15, i8* %7
%16 = load i32, i32* %6
%17 = add nsw i32 %16, 1
store i32 %17, i32* %6
br label %18
18: ; preds = %10
%19 = load i8, i8* %7
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 32
br i1 %21, label %10, label %22
22: ; preds = %18
%23 = load i8, i8* %7
%24 = call i32 @lexer(i8 signext %23)
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = icmp eq i32 %25, 1
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i8*, i8** %4
%29 = load i32, i32* %6
%30 = call i32 @term(i8* %28, i32 %29, i32 1)
store i32 %30, i32* %9
br label %48
31: ; preds = %22
%32 = load i32, i32* %8
%33 = icmp eq i32 %32, 9
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i8*, i8** %4
%36 = load i32, i32* %6
%37 = call i32 @term(i8* %35, i32 %36, i32 2)
store i32 %37, i32* %9
br label %47
38: ; preds = %31
%39 = load i32, i32* %8
%40 = icmp eq i32 %39, 7
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i8*, i8** %4
%43 = load i32, i32* %6
%44 = call i32 @term(i8* %42, i32 %43, i32 3)
store i32 %44, i32* %9
br label %46
45: ; preds = %38
store i32 0, i32* %3
br label %50
46: ; preds = %41
br label %47
47: ; preds = %46, %34
br label %48
48: ; preds = %47, %27
%49 = load i32, i32* %9
store i32 %49, i32* %3
br label %50
50: ; preds = %48, %45
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
define i32 @factor(i8* %0, i32 %1) {
br label %3
3: ; preds = %3, %2
%4 = phi i64 [ %7, %3 ], [ 0, %2 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = add nuw i64 %4, 1
%8 = icmp eq i8 %6, 32
br i1 %8, label %3, label %9
9: ; preds = %3
%10 = trunc i64 %7 to i32
%11 = tail call i32 @lexer(i8 signext %6)
switch i32 %11, label %17 [
i32 1, label %14
i32 9, label %12
i32 7, label %13
]
12: ; preds = %9
br label %14
13: ; preds = %9
br label %14
14: ; preds = %9, %12, %13
%15 = phi i32 [ 3, %13 ], [ 2, %12 ], [ %11, %9 ]
%16 = tail call i32 @term(i8* %0, i32 %10, i32 %15)
br label %17
17: ; preds = %14, %9
%18 = phi i32 [ 0, %9 ], [ %16, %14 ]
ret i32 %18
}