#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*/ CODESET;
int /*<<< orphan*/ LC_CTYPE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ nl_langinfo(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char const *);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
void sl(const char *loc) {
  if (!setlocale(LC_CTYPE, loc))
    return;
  if (strcmp(nl_langinfo(CODESET), "UTF-8"))
    return;
  printf("%s\n", loc);
  exit(0);
}


x86 assembly (clang, -O0):
<sl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1060 <setlocale@plt>
cmp    $0x0,%eax
jne    117c <sl+0x2c>
jmp    11be <sl+0x6e>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1050 <nl_langinfo@plt>
mov    %eax,%edi
lea    0xe6d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11a7 <sl+0x57>
jmp    11be <sl+0x6e>
mov    -0x8(%rbp),%rsi
lea    0xe54(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sl>:
push   %rbx
mov    %rdi,%rbx
mov    0x2e8d(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rsi
call   1060 <setlocale@plt>
test   %eax,%eax
je     118a <sl+0x3a>
mov    0x2e70(%rip),%rax
mov    (%rax),%edi
call   1050 <nl_langinfo@plt>
lea    0xe82(%rip),%rsi
mov    %eax,%edi
call   1040 <strcmp@plt>
test   %rax,%rax
je     118c <sl+0x3c>
pop    %rbx
ret
lea    0xe73(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@LC_CTYPE = global i32 0
@CODESET = global i32 0
@.str = [6 x i8] c"UTF-8\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @sl(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @LC_CTYPE
%4 = load i8*, i8** %2
%5 = call i32 @setlocale(i32 %3, i8* %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
br label %18
8: ; preds = %1
%9 = load i32, i32* @CODESET
%10 = call i32 @nl_langinfo(i32 %9)
%11 = call i64 @strcmp(i32 %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %8
br label %18
14: ; preds = %8
%15 = load i8*, i8** %2
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %13, %7
ret void
}

LLVM IR (-O2):
@LC_CTYPE = global i32 0
@CODESET = global i32 0
@.str = [6 x i8] c"UTF-8\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @sl(i8* %0) {
%2 = load i32, i32* @LC_CTYPE
%3 = tail call i32 @setlocale(i32 %2, i8* %0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = load i32, i32* @CODESET
%7 = tail call i32 @nl_langinfo(i32 %6)
%8 = tail call i64 @strcmp(i32 %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %5
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %5, %1
ret void
}