#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*/ LC_CTYPE;
int /*<<< orphan*/ LC_MESSAGES;
int atoi(char *);
int /*<<< orphan*/ bindtextdomain(char *, char *);
char *gettext(char *);
char *ngettext(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ textdomain(char *);
int main(int argc, char *argv[]) {
  int n = atoi(argv[1]);
  if (setlocale(LC_ALL, "") == NULL) {
    setlocale(LC_CTYPE, "");
    setlocale(LC_MESSAGES, "");
  }
  textdomain("cake");
  bindtextdomain("cake", "/tmp/gettext");
  if (n == -1)
    printf(gettext("a piece of cake"));
  else
    printf(ngettext("a piece of cake", "%d pieces of cake", n), n);
  printf("\n");
  return 0;
}


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)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1070 <setlocale@plt>
cmp    $0x0,%rax
jne    11df <main+0x6f>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
lea    0xe6b(%rip),%rsi
call   1070 <setlocale@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
lea    0xe56(%rip),%rsi
call   1070 <setlocale@plt>
lea    0xe32(%rip),%rdi
call   1030 <textdomain@plt>
lea    0xe26(%rip),%rdi
lea    0xe07(%rip),%rsi
call   1040 <bindtextdomain@plt>
cmpl   $0xffffffff,-0x14(%rbp)
jne    1223 <main+0xb3>
lea    0xdfe(%rip),%rdi
call   1050 <gettext@plt>
mov    %rax,%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1246 <main+0xd6>
mov    -0x14(%rbp),%edx
lea    0xde0(%rip),%rdi
lea    0xde9(%rip),%rsi
call   1090 <ngettext@plt>
mov    %rax,%rdi
mov    -0x14(%rbp),%esi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    0x8(%rsi),%rdi
call   1090 <atoi@plt>
mov    %eax,%ebp
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
call   1080 <setlocale@plt>
test   %rax,%rax
jne    11d2 <main+0x52>
mov    0x2e38(%rip),%rax
mov    (%rax),%edi
lea    0xe63(%rip),%r14
mov    %r14,%rsi
call   1080 <setlocale@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    %r14,%rsi
call   1080 <setlocale@plt>
lea    0xe3f(%rip),%rbx
mov    %rbx,%rdi
call   1040 <textdomain@plt>
lea    0xe18(%rip),%rsi
mov    %rbx,%rdi
call   1050 <bindtextdomain@plt>
lea    0xe16(%rip),%rdi
cmp    $0xffffffff,%ebp
je     1218 <main+0x98>
lea    0xe1a(%rip),%rsi
mov    %ebp,%edx
call   10a0 <ngettext@plt>
mov    %rax,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1227 <main+0xa7>
call   1060 <gettext@plt>
mov    %rax,%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@LC_CTYPE = global i32 0
@LC_MESSAGES = global i32 0
@.str.1 = [5 x i8] c"cake\00"
@.str.2 = [13 x i8] c"/tmp/gettext\00"
@.str.3 = [16 x i8] c"a piece of cake\00"
@.str.4 = [18 x i8] c"%d pieces of cake\00"
@.str.5 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i8**, i8*** %5
%8 = getelementptr inbounds i8*, i8** %7, i64 1
%9 = load i8*, i8** %8
%10 = call i32 @atoi(i8* %9)
store i32 %10, i32* %6
%11 = load i32, i32* @LC_ALL
%12 = call i32* @setlocale(i32 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %19
14: ; preds = %2
%15 = load i32, i32* @LC_CTYPE
%16 = call i32* @setlocale(i32 %15, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @LC_MESSAGES
%18 = call i32* @setlocale(i32 %17, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %14, %2
%20 = call i32 @textdomain(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @bindtextdomain(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%22 = load i32, i32* %6
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %27
24: ; preds = %19
%25 = call i8* @gettext(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* %25)
br label %32
27: ; preds = %19
%28 = load i32, i32* %6
%29 = call i8* @ngettext(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %6
%31 = call i32 (i8*, ...) @printf(i8* %29, i32 %30)
br label %32
32: ; preds = %27, %24
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@LC_CTYPE = global i32 0
@LC_MESSAGES = global i32 0
@.str.1 = [5 x i8] c"cake\00"
@.str.2 = [13 x i8] c"/tmp/gettext\00"
@.str.3 = [16 x i8] c"a piece of cake\00"
@.str.4 = [18 x i8] c"%d pieces of cake\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = load i32, i32* @LC_ALL
%7 = tail call i32* @setlocale(i32 %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %14
9: ; preds = %2
%10 = load i32, i32* @LC_CTYPE
%11 = tail call i32* @setlocale(i32 %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @LC_MESSAGES
%13 = tail call i32* @setlocale(i32 %12, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %9, %2
%15 = tail call i32 @textdomain(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%16 = tail call i32 @bindtextdomain(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32 %5, -1
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = tail call i8* @gettext(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %19)
br label %24
21: ; preds = %14
%22 = tail call i8* @ngettext(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %5)
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %22, i32 %5)
br label %24
24: ; preds = %21, %18
%25 = tail call i32 @putchar(i32 10)
ret i32 0
}