#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 */
char *getenv(char *);
scalar_t__ strstr(char const *, char const *);
char supportsUTF8() {
  const char *LC_ALL = getenv("LC_ALL");
  const char *LANG = getenv("LANG");
  const char *LC_CTYPE = getenv("LC_CTYPE");
  const char *UTF = "UTF-8";
  return (LC_ALL && strstr(LC_ALL, UTF)) || (LANG && strstr(LANG, UTF)) ||
         (LC_CTYPE && strstr(LC_CTYPE, UTF));
}


x86 assembly (clang, -O0):
<supportsUTF8>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xed1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
lea    0xec8(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
lea    0xebd(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x18(%rbp)
lea    0xeb6(%rip),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     118d <supportsUTF8+0x6d>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    11e4 <supportsUTF8+0xc4>
cmpq   $0x0,-0x10(%rbp)
je     11b7 <supportsUTF8+0x97>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strstr@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x21(%rbp)
jne    11e4 <supportsUTF8+0xc4>
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x22(%rbp)
je     11de <supportsUTF8+0xbe>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
movsbl %al,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<supportsUTF8>:
push   %r15
push   %r14
push   %rbx
lea    0xed4(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xecc(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r15
lea    0xec2(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     1170 <supportsUTF8+0x50>
lea    0xeb7(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
mov    %rax,%rcx
mov    $0x1,%al
test   %rcx,%rcx
jne    11ac <supportsUTF8+0x8c>
test   %r15,%r15
je     118e <supportsUTF8+0x6e>
lea    0xe99(%rip),%rsi
mov    %r15,%rdi
call   1040 <strstr@plt>
mov    %rax,%rcx
mov    $0x1,%al
test   %rcx,%rcx
jne    11ac <supportsUTF8+0x8c>
test   %r14,%r14
je     11aa <supportsUTF8+0x8a>
lea    0xe7b(%rip),%rsi
mov    %r14,%rdi
call   1040 <strstr@plt>
test   %rax,%rax
setne  %al
jmp    11ac <supportsUTF8+0x8c>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"LC_ALL\00"
@.str.1 = [5 x i8] c"LANG\00"
@.str.2 = [9 x i8] c"LC_CTYPE\00"
@.str.3 = [6 x i8] c"UTF-8\00"
define signext i8 @supportsUTF8() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %1
%6 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
store i8* %6, i8** %2
%7 = call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
store i8* %7, i8** %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i8** %4
%8 = load i8*, i8** %1
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %15
10: ; preds = %0
%11 = load i8*, i8** %1
%12 = load i8*, i8** %4
%13 = call i64 @strstr(i8* %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %33, label %15
15: ; preds = %10, %0
%16 = load i8*, i8** %2
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %23
18: ; preds = %15
%19 = load i8*, i8** %2
%20 = load i8*, i8** %4
%21 = call i64 @strstr(i8* %19, i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %33, label %23
23: ; preds = %18, %15
%24 = load i8*, i8** %3
%25 = icmp ne i8* %24, null
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i8*, i8** %3
%28 = load i8*, i8** %4
%29 = call i64 @strstr(i8* %27, i8* %28)
%30 = icmp ne i64 %29, 0
br label %31
31: ; preds = %26, %23
%32 = phi i1 [ false, %23 ], [ %30, %26 ]
br label %33
33: ; preds = %31, %18, %10
%34 = phi i1 [ true, %18 ], [ true, %10 ], [ %32, %31 ]
%35 = zext i1 %34 to i32
%36 = trunc i32 %35 to i8
ret i8 %36
}

LLVM IR (-O2):
@.str = [7 x i8] c"LC_ALL\00"
@.str.1 = [5 x i8] c"LANG\00"
@.str.2 = [9 x i8] c"LC_CTYPE\00"
@.str.3 = [6 x i8] c"UTF-8\00"
define signext i8 @supportsUTF8() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
%4 = icmp eq i8* %1, null
br i1 %4, label %8, label %5
5: ; preds = %0
%6 = tail call i64 @strstr(i8* %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %5, %0
%9 = icmp eq i8* %2, null
br i1 %9, label %13, label %10
10: ; preds = %8
%11 = tail call i64 @strstr(i8* %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %19
13: ; preds = %10, %8
%14 = icmp eq i8* %3, null
br i1 %14, label %19, label %15
15: ; preds = %13
%16 = tail call i64 @strstr(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp ne i64 %16, 0
%18 = zext i1 %17 to i8
br label %19
19: ; preds = %13, %15, %10, %5
%20 = phi i8 [ 1, %10 ], [ 1, %5 ], [ 0, %13 ], [ %18, %15 ]
ret i8 %20
}