#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;
int /*<<< orphan*/ describe_char(short);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *);
char *setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main() {
  short c;
  char *cur_locale;
  cur_locale = setlocale(LC_ALL, "");
  if (cur_locale)
    fprintf(stderr, "Successfulle set locale to %s\n", cur_locale);
  else {
    fprintf(
        stderr,
        "Cannot setup locale. Either your libc does not provide\nlocale "
        "support, or your locale data is corrupt, or you have not set\nLANG or "
        "LC_CTYPE environment variable to proper value. Program aborted.\n");
    return 1;
  }
  printf("char#  char alnum alpha cntrl digit lower graph print punct space "
         "upper xdigit lo up\n");
  for (c = 0; c <= 255; c++)
    describe_char(c);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
lea    0xf83(%rip),%rsi
call   1060 <setlocale@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1193 <main+0x53>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    11b6 <main+0x76>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    0xe7c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f8 <main+0xb8>
lea    0xf26(%rip),%rdi
call   1030 <printf@plt>
movw   $0x0,-0x6(%rbp)
movswl -0x6(%rbp),%eax
cmp    $0xff,%eax
jg     11f1 <main+0xb1>
movswl -0x6(%rbp),%edi
call   1040 <describe_char@plt>
mov    -0x6(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x6(%rbp)
jmp    11c8 <main+0x88>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
lea    0xf8f(%rip),%rsi
call   1060 <setlocale@plt>
mov    0x2e81(%rip),%rcx
mov    (%rcx),%edi
test   %rax,%rax
je     11a9 <main+0x69>
lea    0xe93(%rip),%rsi
xor    %ebx,%ebx
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xf63(%rip),%rdi
call   1030 <puts@plt>
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
movswl %bp,%ebp
mov    %ebp,%edi
call   1040 <describe_char@plt>
add    $0x1,%ebp
movzwl %bp,%eax
cmp    $0x100,%eax
jne    1190 <main+0x50>
jmp    11bc <main+0x7c>
lea    0xe6f(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.1 = [31 x i8] c"Successfulle set locale to %s\0A\00"
@.str.2 = [196 x i8] c"Cannot setup locale. Either your libc does not provide\0Alocale support, or your locale data is corrupt, or you have not set\0ALANG or LC_CTYPE environment variable to proper value. Program aborted.\0A\00"
@.str.3 = [86 x i8] c"char# char alnum alpha cntrl digit lower graph print punct space upper xdigit lo up\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i8*
store i32 0, i32* %1
%4 = load i32, i32* @LC_ALL
%5 = call i8* @setlocale(i32 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %3
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %15
12: ; preds = %0
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([196 x i8], [196 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %28
15: ; preds = %8
%16 = call i32 @printf(i8* getelementptr inbounds ([86 x i8], [86 x i8]* @.str.3, i64 0, i64 0))
store i16 0, i16* %2
br label %17
17: ; preds = %24, %15
%18 = load i16, i16* %2
%19 = sext i16 %18 to i32
%20 = icmp sle i32 %19, 255
br i1 %20, label %21, label %27
21: ; preds = %17
%22 = load i16, i16* %2
%23 = call i32 @describe_char(i16 signext %22)
br label %24
24: ; preds = %21
%25 = load i16, i16* %2
%26 = add i16 %25, 1
store i16 %26, i16* %2
br label %17
27: ; preds = %17
store i32 0, i32* %1
br label %28
28: ; preds = %27, %12
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.1 = [31 x i8] c"Successfulle set locale to %s\0A\00"
@.str.2 = [196 x i8] c"Cannot setup locale. Either your libc does not provide\0Alocale support, or your locale data is corrupt, or you have not set\0ALANG or LC_CTYPE environment variable to proper value. Program aborted.\0A\00"
@str = [85 x i8] c"char# char alnum alpha cntrl digit lower graph print punct space upper xdigit lo up\00"
define i32 @main() {
%1 = load i32, i32* @LC_ALL
%2 = tail call i8* @setlocale(i32 %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
%4 = load i32, i32* @stderr
br i1 %3, label %8, label %5
5: ; preds = %0
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([85 x i8], [85 x i8]* @str, i64 0, i64 0))
br label %10
8: ; preds = %0
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([196 x i8], [196 x i8]* @.str.2, i64 0, i64 0))
br label %15
10: ; preds = %5, %10
%11 = phi i16 [ 0, %5 ], [ %13, %10 ]
%12 = tail call i32 @describe_char(i16 signext %11)
%13 = add nuw nsw i16 %11, 1
%14 = icmp eq i16 %13, 256
br i1 %14, label %15, label %10
15: ; preds = %10, %8
%16 = phi i32 [ 1, %8 ], [ 0, %10 ]
ret i32 %16
}