#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 smtp_attachment_validate_name(const char *const name) {
  size_t i;
  unsigned char uc;
  for (i = 0; name[i]; i++) {
    uc = (unsigned char)name[i];
    if (uc < ' ' || uc == 127 || uc == '\'' || uc == '\"') {
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<smtp_attachment_validate_name>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1186 <smtp_attachment_validate_name+0x86>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x19(%rbp)
movzbl -0x19(%rbp),%eax
cmp    $0x20,%eax
jl     1164 <smtp_attachment_validate_name+0x64>
movzbl -0x19(%rbp),%eax
cmp    $0x7f,%eax
je     1164 <smtp_attachment_validate_name+0x64>
movzbl -0x19(%rbp),%eax
cmp    $0x27,%eax
je     1164 <smtp_attachment_validate_name+0x64>
movzbl -0x19(%rbp),%eax
cmp    $0x22,%eax
jne    1170 <smtp_attachment_validate_name+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    118d <smtp_attachment_validate_name+0x8d>
jmp    1175 <smtp_attachment_validate_name+0x75>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1110 <smtp_attachment_validate_name+0x10>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<smtp_attachment_validate_name>:
mov    (%rdi),%cl
test   %cl,%cl
je     112f <smtp_attachment_validate_name+0x2f>
add    $0x1,%rdi
mov    $0xffffffff,%eax
nop
cmp    $0x20,%cl
jb     1131 <smtp_attachment_validate_name+0x31>
cmp    $0x22,%cl
je     1131 <smtp_attachment_validate_name+0x31>
cmp    $0x27,%cl
je     1131 <smtp_attachment_validate_name+0x31>
cmp    $0x7f,%cl
je     1131 <smtp_attachment_validate_name+0x31>
movzbl (%rdi),%ecx
add    $0x1,%rdi
test   %cl,%cl
jne    1110 <smtp_attachment_validate_name+0x10>
xor    %eax,%eax
ret

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

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