#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 */
char *ngettext(char *, char *, int);
int /*<<< orphan*/ printf(char *, int);
void foo(long l, int nfoo) {
  printf(ngettext("%d foo", "%d foos", nfoo), nfoo);
  printf(ngettext("%d foo", "%d foos", l), l);
  printf(ngettext("%d foo", "%ld foos", l), l);
  printf(ngettext("%ld foo", "%d foos", l), l);
  printf(ngettext("1 foo", "%d foos", nfoo), nfoo);
  printf(ngettext("1 foo", "many foos", nfoo), nfoo);
  printf(ngettext("", "%d foos", nfoo), nfoo);
  printf(ngettext("1 foo", (nfoo > 0) ? "%d foos" : "no foos", nfoo), nfoo);
  printf(ngettext("%d foo", (nfoo > 0) ? "%d foos" : "no foos", nfoo), nfoo);
  printf(ngettext("%ld foo", (nfoo > 0) ? "%d foos" : "no foos", nfoo), nfoo);
  printf(ngettext("%d foo", (nfoo > 0) ? "%ld foos" : "no foos", nfoo), nfoo);
  printf(ngettext("%d foo", (nfoo > 0) ? "%d foos" : "%ld foos", nfoo), nfoo);
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edx
lea    0xec7(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %eax,%edx
lea    0xea3(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0x8(%rbp),%rax
mov    %eax,%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %eax,%edx
lea    0xe7c(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0x8(%rbp),%rax
mov    %eax,%esi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %eax,%edx
lea    0xe6d(%rip),%rdi
lea    0xe55(%rip),%rsi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0x8(%rbp),%rax
mov    %eax,%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edx
lea    0xe51(%rip),%rdi
lea    0xe31(%rip),%rsi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edx
lea    0xe30(%rip),%rdi
lea    0xe2f(%rip),%rsi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%edx
lea    0xe14(%rip),%rdi
lea    0xdef(%rip),%rsi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
lea    0xdfe(%rip),%rsi
lea    0xdce(%rip),%rax
cmp    $0x0,%ecx
cmovg  %rax,%rsi
mov    -0xc(%rbp),%edx
lea    0xdd6(%rip),%rdi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
lea    0xdcc(%rip),%rsi
lea    0xd9c(%rip),%rax
cmp    $0x0,%ecx
cmovg  %rax,%rsi
mov    -0xc(%rbp),%edx
lea    0xd84(%rip),%rdi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
lea    0xd9a(%rip),%rsi
lea    0xd6a(%rip),%rax
cmp    $0x0,%ecx
cmovg  %rax,%rsi
mov    -0xc(%rbp),%edx
lea    0xd6a(%rip),%rdi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
lea    0xd68(%rip),%rsi
lea    0xd40(%rip),%rax
cmp    $0x0,%ecx
cmovg  %rax,%rsi
mov    -0xc(%rbp),%edx
lea    0xd20(%rip),%rdi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <printf@plt>
mov    -0xc(%rbp),%ecx
lea    0xd15(%rip),%rsi
lea    0xd06(%rip),%rax
cmp    $0x0,%ecx
cmovg  %rax,%rsi
mov    -0xc(%rbp),%edx
lea    0xcee(%rip),%rdi
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    -0xc(%rbp),%esi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %rdi,%rbp
lea    0xec9(%rip),%r14
lea    0xec9(%rip),%r12
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0xe9c(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
mov    %r12,%rsi
mov    %ebp,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0xe74(%rip),%rbp
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xe5c(%rip),%rsi
mov    %rbp,%rdi
mov    %ebx,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xe40(%rip),%rdi
mov    %r12,%rsi
mov    %ebx,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
test   %ebx,%ebx
lea    0xe2e(%rip),%r14
mov    %r14,%r13
cmovg  %r12,%r13
cmovg  %r15,%r14
cmovg  %r12,%r15
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xdd1(%rip),%rbp
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xdcb(%rip),%rdi
mov    %r13,%rsi
mov    %ebx,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
call   1040 <ngettext@plt>
mov    %rax,%rdi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%d foo\00"
@.str.1 = [8 x i8] c"%d foos\00"
@.str.2 = [9 x i8] c"%ld foos\00"
@.str.3 = [8 x i8] c"%ld foo\00"
@.str.4 = [6 x i8] c"1 foo\00"
@.str.5 = [10 x i8] c"many foos\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [8 x i8] c"no foos\00"
define void @foo(i64 %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = load i32, i32* %4
%8 = call i32 @printf(i8* %6, i32 %7)
%9 = load i64, i64* %3
%10 = trunc i64 %9 to i32
%11 = call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i64, i64* %3
%13 = trunc i64 %12 to i32
%14 = call i32 @printf(i8* %11, i32 %13)
%15 = load i64, i64* %3
%16 = trunc i64 %15 to i32
%17 = call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = load i64, i64* %3
%19 = trunc i64 %18 to i32
%20 = call i32 @printf(i8* %17, i32 %19)
%21 = load i64, i64* %3
%22 = trunc i64 %21 to i32
%23 = call i8* @ngettext(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i64, i64* %3
%25 = trunc i64 %24 to i32
%26 = call i32 @printf(i8* %23, i32 %25)
%27 = load i32, i32* %4
%28 = call i8* @ngettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %4
%30 = call i32 @printf(i8* %28, i32 %29)
%31 = load i32, i32* %4
%32 = call i8* @ngettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %4
%34 = call i32 @printf(i8* %32, i32 %33)
%35 = load i32, i32* %4
%36 = call i8* @ngettext(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = load i32, i32* %4
%38 = call i32 @printf(i8* %36, i32 %37)
%39 = load i32, i32* %4
%40 = icmp sgt i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0)
%43 = load i32, i32* %4
%44 = call i8* @ngettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %42, i32 %43)
%45 = load i32, i32* %4
%46 = call i32 @printf(i8* %44, i32 %45)
%47 = load i32, i32* %4
%48 = icmp sgt i32 %47, 0
%49 = zext i1 %48 to i64
%50 = select i1 %48, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0)
%51 = load i32, i32* %4
%52 = call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %50, i32 %51)
%53 = load i32, i32* %4
%54 = call i32 @printf(i8* %52, i32 %53)
%55 = load i32, i32* %4
%56 = icmp sgt i32 %55, 0
%57 = zext i1 %56 to i64
%58 = select i1 %56, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0)
%59 = load i32, i32* %4
%60 = call i8* @ngettext(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %58, i32 %59)
%61 = load i32, i32* %4
%62 = call i32 @printf(i8* %60, i32 %61)
%63 = load i32, i32* %4
%64 = icmp sgt i32 %63, 0
%65 = zext i1 %64 to i64
%66 = select i1 %64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0)
%67 = load i32, i32* %4
%68 = call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %66, i32 %67)
%69 = load i32, i32* %4
%70 = call i32 @printf(i8* %68, i32 %69)
%71 = load i32, i32* %4
%72 = icmp sgt i32 %71, 0
%73 = zext i1 %72 to i64
%74 = select i1 %72, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%75 = load i32, i32* %4
%76 = call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %74, i32 %75)
%77 = load i32, i32* %4
%78 = call i32 @printf(i8* %76, i32 %77)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d foo\00"
@.str.1 = [8 x i8] c"%d foos\00"
@.str.2 = [9 x i8] c"%ld foos\00"
@.str.3 = [8 x i8] c"%ld foo\00"
@.str.4 = [6 x i8] c"1 foo\00"
@.str.5 = [10 x i8] c"many foos\00"
@.str.6 = [1 x i8] zeroinitializer
@.str.7 = [8 x i8] c"no foos\00"
define void @foo(i64 %0, i32 %1) {
%3 = tail call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%4 = tail call i32 @printf(i8* %3, i32 %1)
%5 = trunc i64 %0 to i32
%6 = tail call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = tail call i32 @printf(i8* %6, i32 %5)
%8 = tail call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%9 = tail call i32 @printf(i8* %8, i32 %5)
%10 = tail call i8* @ngettext(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%11 = tail call i32 @printf(i8* %10, i32 %5)
%12 = tail call i8* @ngettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%13 = tail call i32 @printf(i8* %12, i32 %1)
%14 = tail call i8* @ngettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %1)
%15 = tail call i32 @printf(i8* %14, i32 %1)
%16 = tail call i8* @ngettext(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%17 = tail call i32 @printf(i8* %16, i32 %1)
%18 = icmp sgt i32 %1, 0
%19 = select i1 %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0)
%20 = tail call i8* @ngettext(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %19, i32 %1)
%21 = tail call i32 @printf(i8* %20, i32 %1)
%22 = tail call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %1)
%23 = tail call i32 @printf(i8* %22, i32 %1)
%24 = tail call i8* @ngettext(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %19, i32 %1)
%25 = tail call i32 @printf(i8* %24, i32 %1)
%26 = select i1 %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0)
%27 = tail call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %26, i32 %1)
%28 = tail call i32 @printf(i8* %27, i32 %1)
%29 = select i1 %18, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0)
%30 = tail call i8* @ngettext(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %29, i32 %1)
%31 = tail call i32 @printf(i8* %30, i32 %1)
ret void
}