#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 *);
const char *compGuessLocalLanguage() {
  const char *language;
  language = getenv("LANG");
  if (language == NULL) {
    language = getenv("LANGUAGE");
  }
  if (language == NULL) {
    language = getenv("LC_MESSAGES");
  }
  if (language == NULL) {
    language = "en";
  }
  return language;
}


x86 assembly (clang, -O0):
<compGuessLocalLanguage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1143 <compGuessLocalLanguage+0x33>
lea    0xecb(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    115e <compGuessLocalLanguage+0x4e>
lea    0xeb9(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1174 <compGuessLocalLanguage+0x64>
lea    0xeaa(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compGuessLocalLanguage>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    113f <compGuessLocalLanguage+0x2f>
lea    0xedc(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    113f <compGuessLocalLanguage+0x2f>
lea    0xed4(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xed1(%rip),%rcx
cmovne %rax,%rcx
mov    %rcx,%rax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"LANG\00"
@.str.1 = [9 x i8] c"LANGUAGE\00"
@.str.2 = [12 x i8] c"LC_MESSAGES\00"
@.str.3 = [3 x i8] c"en\00"
define i8* @compGuessLocalLanguage() {
%1 = alloca i8*
%2 = call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8* %2, i8** %1
%3 = load i8*, i8** %1
%4 = icmp eq i8* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i8* %6, i8** %1
br label %7
7: ; preds = %5, %0
%8 = load i8*, i8** %1
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
store i8* %11, i8** %1
br label %12
12: ; preds = %10, %7
%13 = load i8*, i8** %1
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %12
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %1
br label %16
16: ; preds = %15, %12
%17 = load i8*, i8** %1
ret i8* %17
}

LLVM IR (-O2):
@.str = [5 x i8] c"LANG\00"
@.str.1 = [9 x i8] c"LANGUAGE\00"
@.str.2 = [12 x i8] c"LC_MESSAGES\00"
@.str.3 = [3 x i8] c"en\00"
define i8* @compGuessLocalLanguage() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
br label %8
8: ; preds = %0, %6, %3
%9 = phi i8* [ %7, %6 ], [ %4, %3 ], [ %1, %0 ]
%10 = icmp eq i8* %9, null
%11 = select i1 %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %9
ret i8* %11
}