#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__ isalnum(char);
bool str_is_alnum(char str[]) {
  unsigned int i = 0;
  if (str[i] == '\0')
    return false;
  while (str[i] != '\0') {
    if (isalnum(str[i]) == 0) {
      return false;
    }
    ++i;
  }
  return true;
}


x86 assembly (clang, -O0):
<str_is_alnum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1143 <str_is_alnum+0x33>
movl   $0x0,-0x4(%rbp)
jmp    1197 <str_is_alnum+0x87>
jmp    1148 <str_is_alnum+0x38>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1190 <str_is_alnum+0x80>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    1182 <str_is_alnum+0x72>
movl   $0x0,-0x4(%rbp)
jmp    1197 <str_is_alnum+0x87>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1148 <str_is_alnum+0x38>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_is_alnum>:
push   %rbp
push   %r14
push   %rbx
mov    (%rdi),%al
xor    %r14d,%r14d
test   %al,%al
je     1150 <str_is_alnum+0x40>
mov    %rdi,%rbx
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
je     1150 <str_is_alnum+0x40>
mov    %ebp,%eax
movzbl (%rbx,%rax,1),%eax
add    $0x1,%ebp
test   %al,%al
jne    1130 <str_is_alnum+0x20>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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