#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__ isalpha(char);
scalar_t__ isdigit(char);
char findFirstSymbol(char *text, int length) {
  char notfound = '0';
  for (int i = 0; i < length; i++) {
    if (isalpha(text[i])) {
      notfound = '0';
    } else if (isdigit(text[i])) {
      notfound = '0';
    } else {
      return text[i];
    }
  }
  return notfound;
}


x86 assembly (clang, -O0):
<findFirstSymbol>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movb   $0x30,-0x15(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11b9 <findFirstSymbol+0x99>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     116a <findFirstSymbol+0x4a>
movb   $0x30,-0x15(%rbp)
jmp    11a6 <findFirstSymbol+0x86>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     118e <findFirstSymbol+0x6e>
movb   $0x30,-0x15(%rbp)
jmp    11a1 <findFirstSymbol+0x81>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1(%rbp)
jmp    11bf <findFirstSymbol+0x9f>
jmp    11a6 <findFirstSymbol+0x86>
jmp    11ab <findFirstSymbol+0x8b>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <findFirstSymbol+0x1a>
mov    -0x15(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findFirstSymbol>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x30,%r14b
test   %esi,%esi
jle    1169 <findFirstSymbol+0x49>
mov    %rdi,%rbx
mov    %esi,%r15d
xor    %ebp,%ebp
jmp    1149 <findFirstSymbol+0x29>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%r15
je     1169 <findFirstSymbol+0x49>
movsbl (%rbx,%rbp,1),%edi
call   1040 <isalpha@plt>
test   %rax,%rax
jne    1140 <findFirstSymbol+0x20>
movsbl (%rbx,%rbp,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1140 <findFirstSymbol+0x20>
mov    (%rbx,%rbp,1),%r14b
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define signext i8 @findFirstSymbol(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %18
%7 = phi i64 [ 0, %4 ], [ %19, %18 ]
%8 = getelementptr inbounds i8, i8* %0, i64 %7
%9 = load i8, i8* %8
%10 = tail call i64 @isalpha(i8 signext %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %18
12: ; preds = %6
%13 = load i8, i8* %8
%14 = tail call i64 @isdigit(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = load i8, i8* %8
br label %21
18: ; preds = %12, %6
%19 = add nuw nsw i64 %7, 1
%20 = icmp eq i64 %19, %5
br i1 %20, label %21, label %6
21: ; preds = %18, %2, %16
%22 = phi i8 [ %17, %16 ], [ 48, %2 ], [ 48, %18 ]
ret i8 %22
}