#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 *);
char *get_language(void) {
  char *s;
  if ((s = getenv("LC_ALL")) != 0 || (s = getenv("LC_MESSAGES")) != 0 ||
      (s = getenv("LANG")) != 0)
    return s;
  else
    return "";
}


x86 assembly (clang, -O0):
<get_language>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1166 <get_language+0x56>
lea    0xece(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    1166 <get_language+0x56>
lea    0xec0(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1173 <get_language+0x63>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    117e <get_language+0x6e>
lea    0xe9d(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_language>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1124 <get_language+0x14>
pop    %rcx
ret
lea    0xedc(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1122 <get_language+0x12>
lea    0xed7(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
test   %rax,%rax
lea    0xec9(%rip),%rax
cmovne %rcx,%rax
pop    %rcx
ret

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

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