#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 const);
int Mqtt_CheckClentIdentifier(const char *id) {
  int len;
  for (len = 0; '\0' != id[len]; ++len) {
    if (!isalnum(id[len])) {
      return -1;
    }
  }
  return len;
}


x86 assembly (clang, -O0):
<Mqtt_CheckClentIdentifier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     1172 <Mqtt_CheckClentIdentifier+0x62>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    115f <Mqtt_CheckClentIdentifier+0x4f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1178 <Mqtt_CheckClentIdentifier+0x68>
jmp    1164 <Mqtt_CheckClentIdentifier+0x54>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <Mqtt_CheckClentIdentifier+0x13>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Mqtt_CheckClentIdentifier>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     113c <Mqtt_CheckClentIdentifier+0x2c>
mov    %rdi,%r14
xor    %ebx,%ebx
nop
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
je     1140 <Mqtt_CheckClentIdentifier+0x30>
movzbl 0x1(%r14,%rbx,1),%eax
add    $0x1,%rbx
test   %al,%al
jne    1120 <Mqtt_CheckClentIdentifier+0x10>
jmp    1145 <Mqtt_CheckClentIdentifier+0x35>
xor    %ebx,%ebx
jmp    1145 <Mqtt_CheckClentIdentifier+0x35>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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