#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 */
size_t strlen(char *);
int ctrl_char(char *buf, size_t len) {
  if (strlen(buf) < len)
    return 1;
  for (size_t i = 0; i < (len - 1); i++) {
    if (buf[i] >= 10 && buf[i] <= 13)
      continue;
    if (buf[i] < 32) {
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<ctrl_char>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    -0x18(%rbp),%rax
jae    113f <ctrl_char+0x2f>
movl   $0x1,-0x4(%rbp)
jmp    11c9 <ctrl_char+0xb9>
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jae    11c2 <ctrl_char+0xb2>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jl     118b <ctrl_char+0x7b>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jg     118b <ctrl_char+0x7b>
jmp    11b1 <ctrl_char+0xa1>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jge    11ac <ctrl_char+0x9c>
movl   $0x1,-0x4(%rbp)
jmp    11c9 <ctrl_char+0xb9>
jmp    11b1 <ctrl_char+0xa1>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1147 <ctrl_char+0x37>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ctrl_char>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    $0x1,%eax
cmp    %r14,%rcx
jb     118e <ctrl_char+0x7e>
mov    %r14,%rdi
add    $0xffffffffffffffff,%rdi
je     118c <ctrl_char+0x7c>
mov    (%rbx),%cl
cmp    $0x1f,%cl
jg     1144 <ctrl_char+0x34>
add    $0xf2,%cl
cmp    $0xfc,%cl
jb     118e <ctrl_char+0x7e>
mov    $0x2,%eax
sub    %r14,%rax
mov    $0x1,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rsi,%rdx
lea    (%rax,%rsi,1),%rcx
cmp    $0x1,%rcx
je     1182 <ctrl_char+0x72>
movzbl (%rbx,%rdx,1),%ecx
lea    0x1(%rdx),%rsi
cmp    $0x1f,%cl
jg     1160 <ctrl_char+0x50>
add    $0xf2,%cl
cmp    $0xfb,%cl
ja     1160 <ctrl_char+0x50>
xor    %eax,%eax
cmp    %rdi,%rdx
setb   %al
jmp    118e <ctrl_char+0x7e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @ctrl_char(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
%7 = load i8*, i8** %4
%8 = call i64 @strlen(i8* %7)
%9 = load i64, i64* %5
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %46
12: ; preds = %2
store i64 0, i64* %6
br label %13
13: ; preds = %42, %12
%14 = load i64, i64* %6
%15 = load i64, i64* %5
%16 = sub i64 %15, 1
%17 = icmp ult i64 %14, %16
br i1 %17, label %18, label %45
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = load i64, i64* %6
%21 = getelementptr inbounds i8, i8* %19, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp sge i32 %23, 10
br i1 %24, label %25, label %33
25: ; preds = %18
%26 = load i8*, i8** %4
%27 = load i64, i64* %6
%28 = getelementptr inbounds i8, i8* %26, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp sle i32 %30, 13
br i1 %31, label %32, label %33
32: ; preds = %25
br label %42
33: ; preds = %25, %18
%34 = load i8*, i8** %4
%35 = load i64, i64* %6
%36 = getelementptr inbounds i8, i8* %34, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp slt i32 %38, 32
br i1 %39, label %40, label %41
40: ; preds = %33
store i32 1, i32* %3
br label %46
41: ; preds = %33
br label %42
42: ; preds = %41, %32
%43 = load i64, i64* %6
%44 = add i64 %43, 1
store i64 %44, i64* %6
br label %13
45: ; preds = %13
store i32 0, i32* %3
br label %46
46: ; preds = %45, %40, %11
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
define i32 @ctrl_char(i8* nocapture %0, i64 %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = icmp ult i64 %3, %1
br i1 %4, label %28, label %5
5: ; preds = %2
%6 = add i64 %1, -1
%7 = icmp eq i64 %6, 0
br i1 %7, label %28, label %8
8: ; preds = %5
%9 = load i8, i8* %0
%10 = add i8 %9, -14
%11 = icmp ult i8 %10, -4
%12 = icmp slt i8 %9, 32
%13 = and i1 %12, %11
br i1 %13, label %28, label %14
14: ; preds = %8, %17
%15 = phi i64 [ %24, %17 ], [ 1, %8 ]
%16 = icmp eq i64 %15, %6
br i1 %16, label %25, label %17
17: ; preds = %14
%18 = getelementptr inbounds i8, i8* %0, i64 %15
%19 = load i8, i8* %18
%20 = add i8 %19, -14
%21 = icmp ult i8 %20, -4
%22 = icmp slt i8 %19, 32
%23 = and i1 %22, %21
%24 = add nuw i64 %15, 1
br i1 %23, label %25, label %14
25: ; preds = %14, %17
%26 = icmp ult i64 %15, %6
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %5, %8, %25, %2
%29 = phi i32 [ 1, %2 ], [ 0, %5 ], [ 1, %8 ], [ %27, %25 ]
ret i32 %29
}