#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 /*<<< orphan*/ isalnum(char);
int environ_next_delimiter(char *looking_string) {
  int i = 0;
  if (*looking_string == '$')
    looking_string++;
  while (*looking_string) {
    if (*looking_string != '_' && !isalnum(*looking_string)) {
      return i + 1;
    } else {
      looking_string++;
      i++;
    }
  }
  return i + 1;
}


x86 assembly (clang, -O0):
<environ_next_delimiter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
jne    113f <environ_next_delimiter+0x2f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1144 <environ_next_delimiter+0x34>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     119e <environ_next_delimiter+0x8e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     1184 <environ_next_delimiter+0x74>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    1184 <environ_next_delimiter+0x74>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11a7 <environ_next_delimiter+0x97>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <environ_next_delimiter+0x34>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<environ_next_delimiter>:
push   %r14
push   %rbx
push   %rax
xor    %r14d,%r14d
cmpb   $0x24,(%rdi)
sete   %r14b
add    %rdi,%r14
xor    %ebx,%ebx
jmp    1134 <environ_next_delimiter+0x24>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%rbx
movzbl (%r14,%rbx,1),%eax
cmp    $0x5f,%al
je     1130 <environ_next_delimiter+0x20>
test   %al,%al
je     114d <environ_next_delimiter+0x3d>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    1130 <environ_next_delimiter+0x20>
add    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @environ_next_delimiter(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 36
%4 = zext i1 %3 to i64
%5 = getelementptr i8, i8* %0, i64 %4
br label %6
6: ; preds = %13, %1
%7 = phi i8* [ %5, %1 ], [ %14, %13 ]
%8 = phi i32 [ 1, %1 ], [ %15, %13 ]
%9 = load i8, i8* %7
switch i8 %9, label %10 [
i8 0, label %16
i8 95, label %13
]
10: ; preds = %6
%11 = tail call i32 @isalnum(i8 signext %9)
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %6, %10
%14 = getelementptr inbounds i8, i8* %7, i64 1
%15 = add i32 %8, 1
br label %6
16: ; preds = %6, %10
ret i32 %8
}