#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 */
int /*<<< orphan*/ LC_ALL;
int /*<<< orphan*/ printf(char *, ...);
char *setlocale(int /*<<< orphan*/, char *);
int main(int argc, char **argv) {
  int iret = 0;
  char *result = NULL;
  result = setlocale(LC_ALL, "");
  if (result != NULL) {
    printf("setlocale=%s\n", result);
  } else {
    printf("setlocale returns NULL.\n");
    iret = 1;
  }
  return iret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2e94(%rip),%rax
mov    (%rax),%edi
lea    0xed1(%rip),%rsi
call   1040 <setlocale@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1180 <main+0x60>
mov    -0x20(%rbp),%rsi
lea    0xe8c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1195 <main+0x75>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
call   1050 <setlocale@plt>
test   %rax,%rax
je     1160 <main+0x30>
lea    0xeae(%rip),%rdi
xor    %ebx,%ebx
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1171 <main+0x41>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [14 x i8] c"setlocale=%s\0A\00"
@.str.2 = [25 x i8] c"setlocale returns NULL.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i8* null, i8** %7
%8 = load i32, i32* @LC_ALL
%9 = call i8* @setlocale(i32 %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %9, i8** %7
%10 = load i8*, i8** %7
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = load i8*, i8** %7
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %17
15: ; preds = %2
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %6
br label %17
17: ; preds = %15, %12
%18 = load i32, i32* %6
ret i32 %18
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [14 x i8] c"setlocale=%s\0A\00"
@str = [24 x i8] c"setlocale returns NULL.\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @LC_ALL
%4 = tail call i8* @setlocale(i32 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
%11 = phi i32 [ 0, %6 ], [ 1, %8 ]
ret i32 %11
}