#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 /*<<< orphan*/ docheck(int, char *, int);
int iscntrl(int);
int /*<<< orphan*/ printf(char *);
void testctrlmacro(void) {
  int i;
  printf("iscntrl ");
  for (i = 0; i < 0x20; i++) {
    docheck(iscntrl(i), "iscntrl(i)", i);
  }
  for (i = 0x20; i < 0x7f; i++) {
    docheck(!iscntrl(i), "!iscntrl(i)", i);
  }
  docheck(iscntrl(0x7f), "iscntrl(0x7f)", 0x7f);
  for (i = 0x80; i <= 0xff; i++) {
    docheck(!iscntrl(i), "!iscntrl(i)", i);
  }
}


x86 assembly (clang, -O0):
<testctrlmacro>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x20,-0x4(%rbp)
jge    117c <testctrlmacro+0x4c>
mov    -0x4(%rbp),%edi
call   1030 <iscntrl@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%edx
lea    0xea1(%rip),%rsi
call   1050 <docheck@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114b <testctrlmacro+0x1b>
movl   $0x20,-0x4(%rbp)
cmpl   $0x7f,-0x4(%rbp)
jge    11bf <testctrlmacro+0x8f>
mov    -0x4(%rbp),%edi
call   1030 <iscntrl@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    -0x4(%rbp),%edx
lea    0xe5d(%rip),%rsi
call   1050 <docheck@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1183 <testctrlmacro+0x53>
mov    $0x7f,%edi
call   1030 <iscntrl@plt>
mov    %eax,%edi
lea    0xe43(%rip),%rsi
mov    $0x7f,%edx
call   1050 <docheck@plt>
movl   $0x80,-0x4(%rbp)
cmpl   $0xff,-0x4(%rbp)
jg     1222 <testctrlmacro+0xf2>
mov    -0x4(%rbp),%edi
call   1030 <iscntrl@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
mov    -0x4(%rbp),%edx
lea    0xdfa(%rip),%rsi
call   1050 <docheck@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11e3 <testctrlmacro+0xb3>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<testctrlmacro>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
call   1040 <printf@plt>
xor    %ebx,%ebx
lea    0xec1(%rip),%r14
nopl   0x0(%rax)
mov    %ebx,%edi
call   1030 <iscntrl@plt>
mov    %eax,%edi
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <docheck@plt>
add    $0x1,%ebx
cmp    $0x20,%ebx
jne    1150 <testctrlmacro+0x20>
mov    $0x20,%ebx
lea    0xe92(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <iscntrl@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <docheck@plt>
add    $0x1,%ebx
cmp    $0x7f,%ebx
jne    1180 <testctrlmacro+0x50>
mov    $0x7f,%edi
call   1030 <iscntrl@plt>
lea    0xe63(%rip),%rsi
mov    %eax,%edi
mov    $0x7f,%edx
call   1050 <docheck@plt>
mov    $0x80,%ebx
lea    0xe3f(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1030 <iscntrl@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
mov    %r14,%rsi
mov    %ebx,%edx
call   1050 <docheck@plt>
add    $0x1,%ebx
cmp    $0x100,%ebx
jne    11d0 <testctrlmacro+0xa0>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"iscntrl \00"
@.str.1 = [11 x i8] c"iscntrl(i)\00"
@.str.2 = [12 x i8] c"!iscntrl(i)\00"
@.str.3 = [14 x i8] c"iscntrl(0x7f)\00"
define void @testctrlmacro() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %3
3: ; preds = %11, %0
%4 = load i32, i32* %1
%5 = icmp slt i32 %4, 32
br i1 %5, label %6, label %14
6: ; preds = %3
%7 = load i32, i32* %1
%8 = call i32 @iscntrl(i32 %7)
%9 = load i32, i32* %1
%10 = call i32 @docheck(i32 %8, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %9)
br label %11
11: ; preds = %6
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
br label %3
14: ; preds = %3
store i32 32, i32* %1
br label %15
15: ; preds = %26, %14
%16 = load i32, i32* %1
%17 = icmp slt i32 %16, 127
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load i32, i32* %1
%20 = call i32 @iscntrl(i32 %19)
%21 = icmp ne i32 %20, 0
%22 = xor i1 %21, true
%23 = zext i1 %22 to i32
%24 = load i32, i32* %1
%25 = call i32 @docheck(i32 %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %1
%28 = add nsw i32 %27, 1
store i32 %28, i32* %1
br label %15
29: ; preds = %15
%30 = call i32 @iscntrl(i32 127)
%31 = call i32 @docheck(i32 %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 127)
store i32 128, i32* %1
br label %32
32: ; preds = %43, %29
%33 = load i32, i32* %1
%34 = icmp sle i32 %33, 255
br i1 %34, label %35, label %46
35: ; preds = %32
%36 = load i32, i32* %1
%37 = call i32 @iscntrl(i32 %36)
%38 = icmp ne i32 %37, 0
%39 = xor i1 %38, true
%40 = zext i1 %39 to i32
%41 = load i32, i32* %1
%42 = call i32 @docheck(i32 %40, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %35
%44 = load i32, i32* %1
%45 = add nsw i32 %44, 1
store i32 %45, i32* %1
br label %32
46: ; preds = %32
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"iscntrl \00"
@.str.1 = [11 x i8] c"iscntrl(i)\00"
@.str.2 = [12 x i8] c"!iscntrl(i)\00"
@.str.3 = [14 x i8] c"iscntrl(0x7f)\00"
define void @testctrlmacro() {
%1 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %6, %2 ]
%4 = tail call i32 @iscntrl(i32 %3)
%5 = tail call i32 @docheck(i32 %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%6 = add nuw nsw i32 %3, 1
%7 = icmp eq i32 %6, 32
br i1 %7, label %8, label %2
8: ; preds = %2, %8
%9 = phi i32 [ %14, %8 ], [ 32, %2 ]
%10 = tail call i32 @iscntrl(i32 %9)
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = tail call i32 @docheck(i32 %12, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%14 = add nuw nsw i32 %9, 1
%15 = icmp eq i32 %14, 127
br i1 %15, label %16, label %8
16: ; preds = %8
%17 = tail call i32 @iscntrl(i32 127)
%18 = tail call i32 @docheck(i32 %17, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i32 127)
br label %19
19: ; preds = %16, %19
%20 = phi i32 [ 128, %16 ], [ %25, %19 ]
%21 = tail call i32 @iscntrl(i32 %20)
%22 = icmp eq i32 %21, 0
%23 = zext i1 %22 to i32
%24 = tail call i32 @docheck(i32 %23, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%25 = add nuw nsw i32 %20, 1
%26 = icmp eq i32 %25, 256
br i1 %26, label %27, label %19
27: ; preds = %19
ret void
}