#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 *);
int /*<<< orphan*/ *strstr(char *, char *);
int Get_LANG(void) {
  int lang;
  char *lang_code;
  if ((lang_code = getenv("LANG")) != NULL) {
    if (strstr(lang_code, "de") != NULL) {
      lang = 1;
    } else if (strstr(lang_code, "es") != NULL) {
      lang = 2;
    } else {
      lang = 0;
    }
  } else {
    lang = 0;
  }
  return lang;
}


x86 assembly (clang, -O0):
<Get_LANG>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     119f <Get_LANG+0x7f>
mov    -0x10(%rbp),%rdi
lea    0xeb8(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     1168 <Get_LANG+0x48>
movl   $0x1,-0x4(%rbp)
jmp    119a <Get_LANG+0x7a>
mov    -0x10(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1040 <strstr@plt>
cmp    $0x0,%rax
je     118e <Get_LANG+0x6e>
movl   $0x2,-0x4(%rbp)
jmp    1195 <Get_LANG+0x75>
movl   $0x0,-0x4(%rbp)
jmp    119a <Get_LANG+0x7a>
jmp    11a6 <Get_LANG+0x86>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Get_LANG>:
push   %rbx
lea    0xed8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1153 <Get_LANG+0x33>
mov    %rax,%rbx
lea    0xec9(%rip),%rsi
mov    %rax,%rdi
call   1040 <strstr@plt>
mov    %rax,%rcx
mov    $0x1,%eax
test   %rcx,%rcx
je     1157 <Get_LANG+0x37>
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
lea    0xeaa(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strstr@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
setne  %al
add    %eax,%eax
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [5 x i8] c"LANG\00"
@.str.1 = [3 x i8] c"de\00"
@.str.2 = [3 x i8] c"es\00"
define i32 @Get_LANG() {
%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 %10, label %3
3: ; preds = %0
%4 = tail call i32* @strstr(i8* %1, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i32* @strstr(i8* %1, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i32* %7, null
%9 = select i1 %8, i32 0, i32 2
br label %10
10: ; preds = %0, %6, %3
%11 = phi i32 [ 1, %3 ], [ %9, %6 ], [ 0, %0 ]
ret i32 %11
}