#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*/ LC_ALL;
scalar_t__ iscntrl(char);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int main() {
  unsigned char c = '\x94';
  printf("In the default C locale, \\x94 is %sa control character\n",
         iscntrl(c) ? "" : "not ");
  setlocale(LC_ALL, "en_GB.iso88591");
  printf("In ISO-8859-1 locale, \\x94 is %sa control character\n",
         iscntrl(c) ? "" : "not ");
  int i = 0;
  char str[] = "first line \n second line \n";
  while (!iscntrl(str[i])) {
    putchar(str[i]);
    i++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x94,-0x5(%rbp)
movsbl -0x5(%rbp),%edi
call   1040 <iscntrl@plt>
mov    %rax,%rcx
lea    0xed2(%rip),%rsi
lea    0xf13(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe84(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
lea    0xeac(%rip),%rsi
call   1060 <setlocale@plt>
movsbl -0x5(%rbp),%edi
call   1040 <iscntrl@plt>
mov    %rax,%rcx
lea    0xe8f(%rip),%rsi
lea    0xed0(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe8d(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0xc(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xebb(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xeb8(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeb5(%rip),%ax
mov    %ax,-0x18(%rbp)
mov    0xead(%rip),%al
mov    %al,-0x16(%rbp)
movslq -0xc(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1040 <iscntrl@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1224 <main+0xe4>
jmp    1240 <main+0x100>
movslq -0xc(%rbp),%rax
movsbl -0x30(%rbp,%rax,1),%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1200 <main+0xc0>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffff94,%edi
call   1040 <iscntrl@plt>
test   %rax,%rax
lea    0xee1(%rip),%rbp
lea    0xf22(%rip),%rbx
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xe94(%rip),%rdi
call   1050 <printf@plt>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xebc(%rip),%rsi
call   1060 <setlocale@plt>
mov    $0xffffff94,%edi
call   1040 <iscntrl@plt>
test   %rax,%rax
cmove  %rbp,%rbx
lea    0xeae(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    $0x66,%edi
call   1040 <iscntrl@plt>
test   %rax,%rax
jne    11de <main+0x9e>
mov    $0x66,%bpl
lea    0xed2(%rip),%rbx
nop
movsbl %bpl,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%ebp
movsbl %bpl,%edi
call   1040 <iscntrl@plt>
add    $0x1,%rbx
test   %rax,%rax
je     11c0 <main+0x80>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [56 x i8] c"In the default C locale, \\x94 is %sa control character\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"not \00"
@LC_ALL = global i32 0
@.str.3 = [15 x i8] c"en_GB.iso88591\00"
@.str.4 = [53 x i8] c"In ISO-8859-1 locale, \\x94 is %sa control character\0A\00"
@__const.main.str = [27 x i8] c"first line \0A second line \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca [27 x i8]
store i32 0, i32* %1
store i8 -108, i8* %2
%5 = load i8, i8* %2
%6 = call i64 @iscntrl(i8 signext %5)
%7 = icmp ne i64 %6, 0
%8 = zext i1 %7 to i64
%9 = select i1 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%10 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = load i32, i32* @LC_ALL
%12 = call i32 @setlocale(i32 %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%13 = load i8, i8* %2
%14 = call i64 @iscntrl(i8 signext %13)
%15 = icmp ne i64 %14, 0
%16 = zext i1 %15 to i64
%17 = select i1 %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0)
%18 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %17)
store i32 0, i32* %3
%19 = bitcast [27 x i8]* %4 to i8*
br label %20
20: ; preds = %28, %0
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [27 x i8], [27 x i8]* %4, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = call i64 @iscntrl(i8 signext %24)
%26 = icmp ne i64 %25, 0
%27 = xor i1 %26, true
br i1 %27, label %28, label %36
28: ; preds = %20
%29 = load i32, i32* %3
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [27 x i8], [27 x i8]* %4, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @putchar(i8 signext %32)
%34 = load i32, i32* %3
%35 = add nsw i32 %34, 1
store i32 %35, i32* %3
br label %20
36: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [56 x i8] c"In the default C locale, \\x94 is %sa control character\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [5 x i8] c"not \00"
@LC_ALL = global i32 0
@.str.3 = [15 x i8] c"en_GB.iso88591\00"
@.str.4 = [53 x i8] c"In ISO-8859-1 locale, \\x94 is %sa control character\0A\00"
@__const.main.str = [27 x i8] c"first line \0A second line \0A\00"
define i32 @main() {
%1 = tail call i64 @iscntrl(i8 signext -108)
%2 = icmp eq i64 %1, 0
%3 = select i1 %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %3)
%5 = load i32, i32* @LC_ALL
%6 = tail call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%7 = tail call i64 @iscntrl(i8 signext -108)
%8 = icmp eq i64 %7, 0
%9 = select i1 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%11 = tail call i64 @iscntrl(i8 signext 102)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %0, %13
%14 = phi i64 [ %17, %13 ], [ 0, %0 ]
%15 = phi i8 [ %19, %13 ], [ 102, %0 ]
%16 = tail call i32 @putchar(i8 signext %15)
%17 = add nuw i64 %14, 1
%18 = getelementptr inbounds [27 x i8], [27 x i8]* @__const.main.str, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = tail call i64 @iscntrl(i8 signext %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %13, label %22
22: ; preds = %13, %0
ret i32 0
}