#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_CTYPE;
int /*<<< orphan*/ dump(unsigned char);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ parse_options(int, char **);
char *setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strcmp(char *, char *);
char *strrchr(char const *, char);
int main(int argc, char *argv[]) {
  unsigned char seq_len;
  const char *locale;
  parse_options(argc, argv);
  setlocale(LC_CTYPE, "");
  locale = setlocale(LC_CTYPE, NULL);
  if (locale == NULL)
    fprintf(stderr, "setlocale returned NULL.\n");
  else {
    char *dot;
    dot = strrchr(locale, '.');
    if (dot == NULL)
      fprintf(stderr,
              "setlocale returned '%s', which does "
              "not specify encoding.\n",
              locale);
    else {
      if (strcmp(++dot, "UTF-8") != 0)
        fprintf(stderr,
                "setlocale returned encoding "
                "'%s', which is not 'UTF-8'.\n",
                dot);
    }
  }
  for (seq_len = 1; seq_len <= 4; seq_len++)
    dump(seq_len);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <parse_options@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
lea    0xef1(%rip),%rsi
call   1080 <setlocale@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
xor    %eax,%eax
mov    %eax,%esi
call   1080 <setlocale@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e4 <main+0x74>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1268 <main+0xf8>
mov    -0x20(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1221 <main+0xb1>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xe05(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1263 <main+0xf3>
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
mov    %rdi,-0x28(%rbp)
lea    0xe21(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     125e <main+0xee>
mov    0x2d8e(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xe04(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1263 <main+0xf3>
jmp    1268 <main+0xf8>
movb   $0x1,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x4,%eax
jg     128f <main+0x11f>
movzbl -0x11(%rbp),%edi
call   1050 <dump@plt>
mov    -0x11(%rbp),%al
add    $0x1,%al
mov    %al,-0x11(%rbp)
jmp    126c <main+0xfc>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
call   1030 <parse_options@plt>
mov    0x2e68(%rip),%rbx
mov    (%rbx),%edi
lea    0xf0a(%rip),%rsi
call   1080 <setlocale@plt>
mov    (%rbx),%edi
xor    %esi,%esi
call   1080 <setlocale@plt>
test   %rax,%rax
jne    11b5 <main+0x45>
mov    0x2e35(%rip),%rax
mov    (%rax),%edi
lea    0xe54(%rip),%rsi
xor    %eax,%eax
call   1070 <fprintf@plt>
jmp    1214 <main+0xa4>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
jne    11df <main+0x6f>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
mov    %rbx,%rdx
jmp    120d <main+0x9d>
mov    %rax,%r14
add    $0x1,%r14
lea    0xe68(%rip),%rsi
mov    %r14,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1214 <main+0xa4>
mov    0x2dd7(%rip),%rax
mov    (%rax),%edi
lea    0xe51(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   1050 <dump@plt>
mov    $0x2,%edi
call   1050 <dump@plt>
mov    $0x3,%edi
call   1050 <dump@plt>
mov    $0x4,%edi
call   1050 <dump@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@LC_CTYPE = global i32 0
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.1 = [26 x i8] c"setlocale returned NULL.\0A\00"
@.str.2 = [59 x i8] c"setlocale returned '%s', which does not specify encoding.\0A\00"
@.str.3 = [6 x i8] c"UTF-8\00"
@.str.4 = [57 x i8] c"setlocale returned encoding '%s', which is not 'UTF-8'.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @parse_options(i32 %9, i8** %10)
%12 = load i32, i32* @LC_CTYPE
%13 = call i8* @setlocale(i32 %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @LC_CTYPE
%15 = call i8* @setlocale(i32 %14, i8* null)
store i8* %15, i8** %7
%16 = load i8*, i8** %7
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %41
21: ; preds = %2
%22 = load i8*, i8** %7
%23 = call i8* @strrchr(i8* %22, i8 signext 46)
store i8* %23, i8** %8
%24 = load i8*, i8** %8
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %30
26: ; preds = %21
%27 = load i32, i32* @stderr
%28 = load i8*, i8** %7
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %40
30: ; preds = %21
%31 = load i8*, i8** %8
%32 = getelementptr inbounds i8, i8* %31, i32 1
store i8* %32, i8** %8
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %30
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %8
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %35, %30
br label %40
40: ; preds = %39, %26
br label %41
41: ; preds = %40, %18
store i8 1, i8* %6
br label %42
42: ; preds = %49, %41
%43 = load i8, i8* %6
%44 = zext i8 %43 to i32
%45 = icmp sle i32 %44, 4
br i1 %45, label %46, label %52
46: ; preds = %42
%47 = load i8, i8* %6
%48 = call i32 @dump(i8 zeroext %47)
br label %49
49: ; preds = %46
%50 = load i8, i8* %6
%51 = add i8 %50, 1
store i8 %51, i8* %6
br label %42
52: ; preds = %42
%53 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@LC_CTYPE = global i32 0
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.1 = [26 x i8] c"setlocale returned NULL.\0A\00"
@.str.2 = [59 x i8] c"setlocale returned '%s', which does not specify encoding.\0A\00"
@.str.3 = [6 x i8] c"UTF-8\00"
@.str.4 = [57 x i8] c"setlocale returned encoding '%s', which is not 'UTF-8'.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @parse_options(i32 %0, i8** %1)
%4 = load i32, i32* @LC_CTYPE
%5 = tail call i8* @setlocale(i32 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* @LC_CTYPE
%7 = tail call i8* @setlocale(i32 %6, i8* null)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %25
12: ; preds = %2
%13 = tail call i8* @strrchr(i8* %7, i8 signext 46)
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = tail call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.2, i64 0, i64 0), i8* %7)
br label %25
18: ; preds = %12
%19 = getelementptr inbounds i8, i8* %13, i64 1
%20 = tail call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i8* %19)
br label %25
25: ; preds = %15, %22, %18, %9
%26 = tail call i32 @dump(i8 zeroext 1)
%27 = tail call i32 @dump(i8 zeroext 2)
%28 = tail call i32 @dump(i8 zeroext 3)
%29 = tail call i32 @dump(i8 zeroext 4)
%30 = tail call i32 @exit(i32 0)
unreachable
}