#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*/ bindtextdomain(char *, char *);
char *gettext(char *);
int /*<<< orphan*/ printf(char *);
char *setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ textdomain(char *);
int main(void) {
  char *ptr;
  if ((ptr = setlocale(LC_ALL, "")) == NULL) {
    printf(gettext("Can't set locale!\n"));
    return 1;
  }
  bindtextdomain("hello", "locale");
  textdomain("hello");
  printf(gettext("Hello, World!\n"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xebf(%rip),%rsi
call   1070 <setlocale@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    11a2 <main+0x52>
lea    0xe77(%rip),%rdi
call   1050 <gettext@plt>
mov    %rax,%rdi
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11dc <main+0x8c>
lea    0xe6a(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1040 <bindtextdomain@plt>
lea    0xe57(%rip),%rdi
call   1030 <textdomain@plt>
lea    0xe58(%rip),%rdi
call   1050 <gettext@plt>
mov    %rax,%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    0xecd(%rip),%rsi
call   1070 <setlocale@plt>
test   %rax,%rax
je     1194 <main+0x44>
lea    0xea1(%rip),%rbx
lea    0xea0(%rip),%rsi
mov    %rbx,%rdi
call   1040 <bindtextdomain@plt>
mov    %rbx,%rdi
call   1030 <textdomain@plt>
xor    %ebx,%ebx
lea    0xe8e(%rip),%rdi
jmp    11a0 <main+0x50>
mov    $0x1,%ebx
lea    0xe60(%rip),%rdi
call   1050 <gettext@plt>
mov    %rax,%rdi
call   1060 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [19 x i8] c"Can't set locale!\0A\00"
@.str.2 = [6 x i8] c"hello\00"
@.str.3 = [7 x i8] c"locale\00"
@.str.4 = [15 x i8] c"Hello, World!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
%3 = load i32, i32* @LC_ALL
%4 = call i8* @setlocale(i32 %3, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store i8* %4, i8** %2
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i8* @gettext(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @printf(i8* %7)
store i32 1, i32* %1
br label %14
9: ; preds = %0
%10 = call i32 @bindtextdomain(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @textdomain(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%12 = call i8* @gettext(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* %12)
store i32 0, i32* %1
br label %14
14: ; preds = %9, %6
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [19 x i8] c"Can't set locale!\0A\00"
@.str.2 = [6 x i8] c"hello\00"
@.str.3 = [7 x i8] c"locale\00"
@.str.4 = [15 x i8] c"Hello, World!\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 = icmp eq i8* %2, null
br i1 %3, label %7, label %4
4: ; preds = %0
%5 = tail call i32 @bindtextdomain(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @textdomain(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %0, %4
%8 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), %4 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), %0 ]
%9 = phi i32 [ 0, %4 ], [ 1, %0 ]
%10 = tail call i8* @gettext(i8* %8)
%11 = tail call i32 @printf(i8* dereferenceable(1) %10)
ret i32 %9
}