#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 */
struct lconv {
  char *decimal_point;
  char *thousands_sep;
};

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ LC_MONETARY;
int /*<<< orphan*/ LC_NUMERIC;
struct lconv *localeconv();
int /*<<< orphan*/ printf(char *, char *);
char *setlocale(int /*<<< orphan*/, char *);
int main(void) {
  char *l;
  struct lconv *lconv;
  l = setlocale(LC_ALL, "");
  printf("%s\n", l);
  l = setlocale(LC_MONETARY, "");
  printf("%s\n", l);
  l = setlocale(LC_NUMERIC, "C");
  printf("%s\n", l);
  lconv = localeconv();
  printf("dec  '%s'\n", lconv->decimal_point);
  printf("thou '%s'\n", lconv->thousands_sep);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
call   1050 <setlocale@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe9d(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1050 <setlocale@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe74(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%rsi
call   1050 <setlocale@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe4b(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <localeconv@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rsi
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe2a(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e95(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%r14
mov    %r14,%rsi
call   1050 <setlocale@plt>
lea    0xead(%rip),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1050 <setlocale@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2e67(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   1050 <setlocale@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1030 <localeconv@plt>
mov    %rax,%rbx
mov    (%rax),%rsi
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rbx),%rsi
lea    0xe53(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.lconv = type { i8*, i8* }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"%s\0A\00"
@LC_MONETARY = global i32 0
@LC_NUMERIC = global i32 0
@.str.2 = [2 x i8] c"C\00"
@.str.3 = [11 x i8] c"dec '%s'\0A\00"
@.str.4 = [11 x i8] c"thou '%s'\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca %struct.lconv*
store i32 0, i32* %1
%4 = load i32, i32* @LC_ALL
%5 = call i8* @setlocale(i32 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%8 = load i32, i32* @LC_MONETARY
%9 = call i8* @setlocale(i32 %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %2
%10 = load i8*, i8** %2
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @LC_NUMERIC
%13 = call i8* @setlocale(i32 %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i8* %13, i8** %2
%14 = load i8*, i8** %2
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call %struct.lconv* (...) @localeconv()
store %struct.lconv* %16, %struct.lconv** %3
%17 = load %struct.lconv*, %struct.lconv** %3
%18 = getelementptr inbounds %struct.lconv, %struct.lconv* %17, i32 0, i32 0
%19 = load i8*, i8** %18
%20 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = load %struct.lconv*, %struct.lconv** %3
%22 = getelementptr inbounds %struct.lconv, %struct.lconv* %21, i32 0, i32 1
%23 = load i8*, i8** %22
%24 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %23)
ret i32 0
}

LLVM IR (-O2):
%struct.lconv = type { i8*, i8* }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [4 x i8] c"%s\0A\00"
@LC_MONETARY = global i32 0
@LC_NUMERIC = global i32 0
@.str.2 = [2 x i8] c"C\00"
@.str.3 = [11 x i8] c"dec '%s'\0A\00"
@.str.4 = [11 x i8] c"thou '%s'\0A\00"
define i32 @main() {
%1 = load i32, i32* @LC_ALL
%2 = tail call i8* @setlocale(i32 %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%4 = load i32, i32* @LC_MONETARY
%5 = tail call i8* @setlocale(i32 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = load i32, i32* @LC_NUMERIC
%8 = tail call i8* @setlocale(i32 %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = tail call %struct.lconv* (...) @localeconv()
%11 = getelementptr inbounds %struct.lconv, %struct.lconv* %10, i64 0, i32 0
%12 = load i8*, i8** %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds %struct.lconv, %struct.lconv* %10, i64 0, i32 1
%15 = load i8*, i8** %14
%16 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %15)
ret i32 0
}