#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__ TOR_ISALPHA(char const);
scalar_t__ TOR_ISDIGIT(char const);
size_t strlen(char const *);
int string_is_C_identifier(const char *string) {
  size_t iter;
  size_t length = strlen(string);
  if (!length)
    return 0;
  for (iter = 0; iter < length; iter++) {
    if (iter == 0) {
      if (!(TOR_ISALPHA(string[iter]) || string[iter] == '_'))
        return 0;
    } else {
      if (!(TOR_ISALPHA(string[iter]) || TOR_ISDIGIT(string[iter]) ||
            string[iter] == '_'))
        return 0;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<string_is_C_identifier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1160 <string_is_C_identifier+0x30>
movl   $0x0,-0x4(%rbp)
jmp    123b <string_is_C_identifier+0x10b>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1234 <string_is_C_identifier+0x104>
cmpq   $0x0,-0x18(%rbp)
jne    11c2 <string_is_C_identifier+0x92>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <TOR_ISALPHA@plt>
cmp    $0x0,%rax
jne    11bd <string_is_C_identifier+0x8d>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
je     11bd <string_is_C_identifier+0x8d>
movl   $0x0,-0x4(%rbp)
jmp    123b <string_is_C_identifier+0x10b>
jmp    121e <string_is_C_identifier+0xee>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <TOR_ISALPHA@plt>
cmp    $0x0,%rax
jne    1219 <string_is_C_identifier+0xe9>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <TOR_ISDIGIT@plt>
cmp    $0x0,%rax
jne    1219 <string_is_C_identifier+0xe9>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
je     1219 <string_is_C_identifier+0xe9>
movl   $0x0,-0x4(%rbp)
jmp    123b <string_is_C_identifier+0x10b>
jmp    121e <string_is_C_identifier+0xee>
jmp    1223 <string_is_C_identifier+0xf3>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1168 <string_is_C_identifier+0x38>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_is_C_identifier>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %rax,%rax
je     1199 <string_is_C_identifier+0x69>
mov    %rax,%r14
xor    %ebx,%ebx
jmp    1167 <string_is_C_identifier+0x37>
nopl   0x0(%rax)
movsbl (%r15),%edi
call   1050 <TOR_ISALPHA@plt>
test   %rax,%rax
je     1193 <string_is_C_identifier+0x63>
add    $0x1,%rbx
cmp    %rbx,%r14
je     119d <string_is_C_identifier+0x6d>
test   %rbx,%rbx
je     1150 <string_is_C_identifier+0x20>
movsbl (%r15,%rbx,1),%edi
call   1050 <TOR_ISALPHA@plt>
test   %rax,%rax
jne    115e <string_is_C_identifier+0x2e>
movsbl (%r15,%rbx,1),%edi
call   1040 <TOR_ISDIGIT@plt>
test   %rax,%rax
jne    115e <string_is_C_identifier+0x2e>
cmpb   $0x5f,(%r15,%rbx,1)
je     115e <string_is_C_identifier+0x2e>
jmp    1199 <string_is_C_identifier+0x69>
cmpb   $0x5f,(%r15)
je     115e <string_is_C_identifier+0x2e>
xor    %eax,%eax
jmp    11a2 <string_is_C_identifier+0x72>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @string_is_C_identifier(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i64 @strlen(i8* %6)
store i64 %7, i64* %5
%8 = load i64, i64* %5
%9 = icmp ne i64 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 0, i32* %2
br label %63
11: ; preds = %1
store i64 0, i64* %4
br label %12
12: ; preds = %59, %11
%13 = load i64, i64* %4
%14 = load i64, i64* %5
%15 = icmp ult i64 %13, %14
br i1 %15, label %16, label %62
16: ; preds = %12
%17 = load i64, i64* %4
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %35
19: ; preds = %16
%20 = load i8*, i8** %3
%21 = load i64, i64* %4
%22 = getelementptr inbounds i8, i8* %20, i64 %21
%23 = load i8, i8* %22
%24 = call i64 @TOR_ISALPHA(i8 signext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %34, label %26
26: ; preds = %19
%27 = load i8*, i8** %3
%28 = load i64, i64* %4
%29 = getelementptr inbounds i8, i8* %27, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 95
br i1 %32, label %34, label %33
33: ; preds = %26
store i32 0, i32* %2
br label %63
34: ; preds = %26, %19
br label %58
35: ; preds = %16
%36 = load i8*, i8** %3
%37 = load i64, i64* %4
%38 = getelementptr inbounds i8, i8* %36, i64 %37
%39 = load i8, i8* %38
%40 = call i64 @TOR_ISALPHA(i8 signext %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %57, label %42
42: ; preds = %35
%43 = load i8*, i8** %3
%44 = load i64, i64* %4
%45 = getelementptr inbounds i8, i8* %43, i64 %44
%46 = load i8, i8* %45
%47 = call i64 @TOR_ISDIGIT(i8 signext %46)
%48 = icmp ne i64 %47, 0
br i1 %48, label %57, label %49
49: ; preds = %42
%50 = load i8*, i8** %3
%51 = load i64, i64* %4
%52 = getelementptr inbounds i8, i8* %50, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp eq i32 %54, 95
br i1 %55, label %57, label %56
56: ; preds = %49
store i32 0, i32* %2
br label %63
57: ; preds = %49, %42, %35
br label %58
58: ; preds = %57, %34
br label %59
59: ; preds = %58
%60 = load i64, i64* %4
%61 = add i64 %60, 1
store i64 %61, i64* %4
br label %12
62: ; preds = %12
store i32 1, i32* %2
br label %63
63: ; preds = %62, %56, %33, %10
%64 = load i32, i32* %2
ret i32 %64
}

LLVM IR (-O2):
define i32 @string_is_C_identifier(i8* nocapture %0) {
%2 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %29, label %4
4: ; preds = %1, %26
%5 = phi i64 [ %27, %26 ], [ 0, %1 ]
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i8, i8* %0
%9 = tail call i64 @TOR_ISALPHA(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %7
%12 = load i8, i8* %0
%13 = icmp eq i8 %12, 95
br i1 %13, label %26, label %29
14: ; preds = %4
%15 = getelementptr inbounds i8, i8* %0, i64 %5
%16 = load i8, i8* %15
%17 = tail call i64 @TOR_ISALPHA(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %14
%20 = load i8, i8* %15
%21 = tail call i64 @TOR_ISDIGIT(i8 signext %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i8, i8* %15
%25 = icmp eq i8 %24, 95
br i1 %25, label %26, label %29
26: ; preds = %11, %7, %23, %19, %14
%27 = add nuw i64 %5, 1
%28 = icmp eq i64 %27, %2
br i1 %28, label %29, label %4
29: ; preds = %11, %23, %26, %1
%30 = phi i32 [ 0, %1 ], [ 0, %11 ], [ 0, %23 ], [ 1, %26 ]
ret i32 %30
}