#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char const *);
int /*<<< orphan*/ stderr;
int utf8_test_1();
int utf8_test_2();
int utf8_test_3();
int utf8_test(void) {
  const char *locale = "de_DE.UTF-8";
  int error = 0;
  if (!setlocale(LC_CTYPE, locale)) {
    fprintf(stderr, "locale '%s' not available!\n", locale);
    exit(1);
  }
  error |= utf8_test_1();
  error |= utf8_test_2();
  error |= utf8_test_3();
  return error;
}


x86 assembly (clang, -O0):
<utf8_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xe91(%rip),%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1050 <setlocale@plt>
cmp    $0x0,%eax
jne    11b8 <utf8_test+0x58>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xe63(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    $0x0,%al
call   1070 <utf8_test_1@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <utf8_test_2@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <utf8_test_3@plt>
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utf8_test>:
push   %rbp
push   %rbx
push   %rax
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
lea    0xe8d(%rip),%rsi
call   1050 <setlocale@plt>
test   %eax,%eax
je     11a0 <utf8_test+0x40>
xor    %eax,%eax
call   1070 <utf8_test_1@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <utf8_test_2@plt>
mov    %eax,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1060 <utf8_test_3@plt>
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
lea    0xe5c(%rip),%rsi
lea    0xe49(%rip),%rdx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [12 x i8] c"de_DE.UTF-8\00"
@LC_CTYPE = global i32 0
@stderr = global i32 0
@.str.1 = [28 x i8] c"locale '%s' not available!\0A\00"
define i32 @utf8_test() {
%1 = alloca i8*
%2 = alloca i32
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %1
store i32 0, i32* %2
%3 = load i32, i32* @LC_CTYPE
%4 = load i8*, i8** %1
%5 = call i32 @setlocale(i32 %3, i8* %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i8*, i8** %1
%10 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %0
%13 = call i32 (...) @utf8_test_1()
%14 = load i32, i32* %2
%15 = or i32 %14, %13
store i32 %15, i32* %2
%16 = call i32 (...) @utf8_test_2()
%17 = load i32, i32* %2
%18 = or i32 %17, %16
store i32 %18, i32* %2
%19 = call i32 (...) @utf8_test_3()
%20 = load i32, i32* %2
%21 = or i32 %20, %19
store i32 %21, i32* %2
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [12 x i8] c"de_DE.UTF-8\00"
@LC_CTYPE = global i32 0
@stderr = global i32 0
@.str.1 = [28 x i8] c"locale '%s' not available!\0A\00"
define i32 @utf8_test() {
%1 = load i32, i32* @LC_CTYPE
%2 = tail call i32 @setlocale(i32 %1, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %0
%9 = tail call i32 (...) @utf8_test_1()
%10 = tail call i32 (...) @utf8_test_2()
%11 = or i32 %10, %9
%12 = tail call i32 (...) @utf8_test_3()
%13 = or i32 %11, %12
ret i32 %13
}