#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*/ abort();
int /*<<< orphan*/ bindtextdomain(char *, char *);
char *getcwd(char *, int);
char *gettext(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ textdomain(char *);
int main() {
  char pwd[256], *p;
  printf("see: %s\n",
         "http://fedoraproject.org/wiki/How_to_do_I18N_through_gettext");
  setlocale(LC_ALL, "");
  if ((p = getcwd(pwd, 256)) == NULL) {
    perror("getcwd");
    abort();
  }
  bindtextdomain("helloworld", p);
  textdomain("helloworld");
  printf("%s\n", gettext("hello"));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rdi
lea    0xe69(%rip),%rsi
call   1070 <printf@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
call   1090 <setlocale@plt>
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
call   1080 <getcwd@plt>
mov    %rax,-0x118(%rbp)
cmp    $0x0,%rax
jne    11ef <main+0x6f>
lea    0xe63(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x118(%rbp),%rsi
lea    0xe50(%rip),%rdi
call   1050 <bindtextdomain@plt>
lea    0xe44(%rip),%rdi
call   1040 <textdomain@plt>
lea    0xe43(%rip),%rdi
call   1060 <gettext@plt>
mov    %rax,%rsi
lea    0xde1(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x100,%rsp
lea    0xe71(%rip),%rdi
lea    0xe73(%rip),%rsi
call   1070 <printf@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
call   1090 <setlocale@plt>
mov    %rsp,%rdi
mov    $0x100,%esi
call   1080 <getcwd@plt>
test   %rax,%rax
je     1202 <main+0x82>
lea    0xe84(%rip),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <bindtextdomain@plt>
mov    %rbx,%rdi
call   1040 <textdomain@plt>
lea    0xe75(%rip),%rdi
call   1060 <gettext@plt>
lea    0xe16(%rip),%rdi
mov    %rax,%rsi
call   1070 <printf@plt>
xor    %eax,%eax
add    $0x100,%rsp
pop    %rbx
ret
lea    0xe3d(%rip),%rdi
call   10a0 <perror@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"see: %s\0A\00"
@.str.1 = [61 x i8] c"http://fedoraproject.org/wiki/How_to_do_I18N_through_gettext\00"
@LC_ALL = global i32 0
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [7 x i8] c"getcwd\00"
@.str.4 = [11 x i8] c"helloworld\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [6 x i8] c"hello\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i8*
store i32 0, i32* %1
%4 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%5 = load i32, i32* @LC_ALL
%6 = call i32 @setlocale(i32 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = call i8* @getcwd(i8* %7, i32 256)
store i8* %8, i8** %3
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 (...) @abort()
unreachable
13: ; preds = %0
%14 = load i8*, i8** %3
%15 = call i32 @bindtextdomain(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%16 = call i32 @textdomain(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%17 = call i8* @gettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"see: %s\0A\00"
@.str.1 = [61 x i8] c"http://fedoraproject.org/wiki/How_to_do_I18N_through_gettext\00"
@LC_ALL = global i32 0
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [7 x i8] c"getcwd\00"
@.str.4 = [11 x i8] c"helloworld\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [6 x i8] c"hello\00"
define i32 @main() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @LC_ALL
%5 = tail call i32 @setlocale(i32 %4, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%6 = call i8* @getcwd(i8* %2, i32 256)
%7 = icmp eq i8* %6, null
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%10 = call i32 (...) @abort()
unreachable
11: ; preds = %0
%12 = call i32 @bindtextdomain(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%13 = call i32 @textdomain(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%14 = call i8* @gettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %14)
ret i32 0
}