int picolNeedsBraces(const char *str) {
  int i;
  int length = 0;
  for (i = 0;; i++) {
    if (str[i] == '\0') {
      break;
    }
    switch (str[i]) {
    case ' ':
      return 1;
    case '"':
      return 1;
    case '$':
      return 1;
    case '[':
      return 1;
    case '\\':
      return 1;
    case '\n':
      return 1;
    case '\r':
      return 1;
    case '\t':
      return 1;
    }
    length++;
  }
  if (length == 0) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<picolNeedsBraces>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1130 <picolNeedsBraces+0x30>
jmp    123b <picolNeedsBraces+0x13b>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x9,%eax
je     1218 <picolNeedsBraces+0x118>
jmp    114d <picolNeedsBraces+0x4d>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
je     1200 <picolNeedsBraces+0x100>
jmp    115e <picolNeedsBraces+0x5e>
mov    -0x1c(%rbp),%eax
sub    $0xd,%eax
je     120c <picolNeedsBraces+0x10c>
jmp    116f <picolNeedsBraces+0x6f>
mov    -0x1c(%rbp),%eax
sub    $0x20,%eax
je     11c4 <picolNeedsBraces+0xc4>
jmp    1180 <picolNeedsBraces+0x80>
mov    -0x1c(%rbp),%eax
sub    $0x22,%eax
je     11d0 <picolNeedsBraces+0xd0>
jmp    1191 <picolNeedsBraces+0x91>
mov    -0x1c(%rbp),%eax
sub    $0x24,%eax
je     11dc <picolNeedsBraces+0xdc>
jmp    11a2 <picolNeedsBraces+0xa2>
mov    -0x1c(%rbp),%eax
sub    $0x5b,%eax
je     11e8 <picolNeedsBraces+0xe8>
jmp    11b3 <picolNeedsBraces+0xb3>
mov    -0x1c(%rbp),%eax
sub    $0x5c,%eax
je     11f4 <picolNeedsBraces+0xf4>
jmp    1224 <picolNeedsBraces+0x124>
movl   $0x1,-0x4(%rbp)
jmp    1258 <picolNeedsBraces+0x158>
movl   $0x1,-0x4(%rbp)
jmp    1258 <picolNeedsBraces+0x158>
movl   $0x1,-0x4(%rbp)
jmp    1258 <picolNeedsBraces+0x158>
movl   $0x1,-0x4(%rbp)
jmp    1258 <picolNeedsBraces+0x158>
movl   $0x1,-0x4(%rbp)
jmp    1258 <picolNeedsBraces+0x158>
movl   $0x1,-0x4(%rbp)
jmp    1258 <picolNeedsBraces+0x158>
movl   $0x1,-0x4(%rbp)
jmp    1258 <picolNeedsBraces+0x158>
movl   $0x1,-0x4(%rbp)
jmp    1258 <picolNeedsBraces+0x158>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1116 <picolNeedsBraces+0x16>
cmpl   $0x0,-0x18(%rbp)
jne    1251 <picolNeedsBraces+0x151>
movl   $0x1,-0x4(%rbp)
jmp    1258 <picolNeedsBraces+0x158>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<picolNeedsBraces>:
mov    (%rdi),%cl
test   %cl,%cl
je     1137 <picolNeedsBraces+0x37>
add    $0x1,%rdi
movabs $0x1500002600,%rax
mov    %ecx,%edx
movsbl %dl,%edx
cmp    $0x24,%edx
ja     1124 <picolNeedsBraces+0x24>
bt     %rdx,%rax
jb     113f <picolNeedsBraces+0x3f>
add    $0xffffffa5,%edx
cmp    $0x2,%edx
jb     113f <picolNeedsBraces+0x3f>
movzbl (%rdi),%edx
add    $0x1,%rdi
test   %dl,%dl
jne    1116 <picolNeedsBraces+0x16>
xor    %eax,%eax
test   %cl,%cl
sete   %al
ret
mov    $0x1,%eax
ret

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

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