#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__ isspecial(char);
int needs_quotation_len(char *str, int len) {
  char c;
  while ((c = *str++) && len) {
    if (isspecial(c))
      return 1;
    len--;
  }
  return 0;
}


x86 assembly (clang, -O0):
<needs_quotation_len>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x15(%rbp)
movsbl %al,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x16(%rbp)
je     114e <needs_quotation_len+0x3e>
cmpl   $0x0,-0x14(%rbp)
setne  %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
test   $0x1,%al
jne    115e <needs_quotation_len+0x4e>
jmp    118b <needs_quotation_len+0x7b>
movsbl -0x15(%rbp),%edi
call   1030 <isspecial@plt>
cmp    $0x0,%rax
je     117d <needs_quotation_len+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    1192 <needs_quotation_len+0x82>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    111f <needs_quotation_len+0xf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<needs_quotation_len>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
xor    %r14d,%r14d
test   %al,%al
je     1159 <needs_quotation_len+0x49>
test   %esi,%esi
je     1159 <needs_quotation_len+0x49>
mov    %rdi,%rbx
mov    %esi,%r15d
mov    $0x1,%ebp
nop
movsbl %al,%edi
call   1030 <isspecial@plt>
test   %rax,%rax
jne    1153 <needs_quotation_len+0x43>
movzbl (%rbx,%rbp,1),%eax
test   %al,%al
je     1159 <needs_quotation_len+0x49>
lea    0x1(%rbp),%rcx
cmp    %ebp,%r15d
mov    %rcx,%rbp
jne    1130 <needs_quotation_len+0x20>
jmp    1159 <needs_quotation_len+0x49>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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