#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*/ printf(char *, char *, ...);
int /*<<< orphan*/ puts(char *);
int _locale_default(void) {
  char *vars[] = {"LANG", NULL};
  char **p;
  char *e;
  for (p = vars; *p != NULL; p++) {
    printf("%s=", *p);
    if ((e = getenv(*p)) == NULL)
      puts("\"\"");
    else
      puts(e);
  }
  if ((e = getenv("LC_ALL")) == NULL)
    e = "";
  printf("%s%s\n", "LC_ALL=", e);
  return 0;
}


x86 assembly (clang, -O0):
<_locale_default>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2cd1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0x2cce(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     11c3 <_locale_default+0x93>
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11a4 <_locale_default+0x74>
lea    0xe6f(%rip),%rdi
call   1040 <puts@plt>
jmp    11ad <_locale_default+0x7d>
mov    -0x20(%rbp),%rdi
call   1040 <puts@plt>
jmp    11b2 <_locale_default+0x82>
mov    -0x18(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x18(%rbp)
jmp    1156 <_locale_default+0x26>
lea    0xe42(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11e8 <_locale_default+0xb8>
lea    0xe34(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdx
lea    0xe20(%rip),%rdi
lea    0xe1f(%rip),%rsi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_locale_default>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movaps 0x2cd0(%rip),%xmm0
movaps %xmm0,(%rsp)
lea    0x8(%rsp),%rbx
lea    0xeb0(%rip),%rsi
lea    0xeae(%rip),%r15
lea    0xeab(%rip),%r14
jmp    1174 <_locale_default+0x44>
mov    %rax,%rdi
call   1040 <puts@plt>
mov    (%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
je     1191 <_locale_default+0x61>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    -0x8(%rbx),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1160 <_locale_default+0x30>
mov    %r14,%rdi
jmp    1163 <_locale_default+0x33>
lea    0xe74(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
lea    0xe71(%rip),%rdx
cmovne %rax,%rdx
lea    0xe61(%rip),%rdi
lea    0xe60(%rip),%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"LANG\00"
@__const._locale_default.vars = [2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [4 x i8] c"%s=\00"
@.str.2 = [3 x i8] c"\22\22\00"
@.str.3 = [7 x i8] c"LC_ALL\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [6 x i8] c"%s%s\0A\00"
@.str.6 = [8 x i8] c"LC_ALL=\00"
define i32 @_locale_default() {
%1 = alloca [2 x i8*]
%2 = alloca i8**
%3 = alloca i8*
%4 = bitcast [2 x i8*]* %1 to i8*
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
store i8** %5, i8*** %2
br label %6
6: ; preds = %24, %0
%7 = load i8**, i8*** %2
%8 = load i8*, i8** %7
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %27
10: ; preds = %6
%11 = load i8**, i8*** %2
%12 = load i8*, i8** %11
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i8**, i8*** %2
%15 = load i8*, i8** %14
%16 = call i8* @getenv(i8* %15)
store i8* %16, i8** %3
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %20
18: ; preds = %10
%19 = call i32 @puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %23
20: ; preds = %10
%21 = load i8*, i8** %3
%22 = call i32 @puts(i8* %21)
br label %23
23: ; preds = %20, %18
br label %24
24: ; preds = %23
%25 = load i8**, i8*** %2
%26 = getelementptr inbounds i8*, i8** %25, i32 1
store i8** %26, i8*** %2
br label %6
27: ; preds = %6
%28 = call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
store i8* %28, i8** %3
%29 = icmp eq i8* %28, null
br i1 %29, label %30, label %31
30: ; preds = %27
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8** %3
br label %31
31: ; preds = %30, %27
%32 = load i8*, i8** %3
%33 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"LANG\00"
@__const._locale_default.vars = [2 x i8*] [i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [4 x i8] c"%s=\00"
@.str.2 = [3 x i8] c"\22\22\00"
@.str.3 = [7 x i8] c"LC_ALL\00"
@.str.4 = [1 x i8] zeroinitializer
@.str.5 = [6 x i8] c"%s%s\0A\00"
@.str.6 = [8 x i8] c"LC_ALL=\00"
define i32 @_locale_default() {
%1 = alloca [2 x i8*]
%2 = bitcast [2 x i8*]* %1 to i8*
%3 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
br label %4
4: ; preds = %0, %15
%5 = phi i8* [ %17, %15 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %0 ]
%6 = phi i8** [ %16, %15 ], [ %3, %0 ]
%7 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%8 = load i8*, i8** %6
%9 = tail call i8* @getenv(i8* %8)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %13
11: ; preds = %4
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %15
13: ; preds = %4
%14 = tail call i32 @puts(i8* %9)
br label %15
15: ; preds = %11, %13
%16 = getelementptr inbounds i8*, i8** %6, i64 1
%17 = load i8*, i8** %16
%18 = icmp eq i8* %17, null
br i1 %18, label %19, label %4
19: ; preds = %15
%20 = tail call i8* @getenv(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i8* %20, null
%22 = select i1 %21, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.4, i64 0, i64 0), i8* %20
%23 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i8* %22)
ret i32 0
}