#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 *dgettext(char const *, char *);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
int strlen(char const *);
const char *b_dpgettext(const char *domain, const char *context,
                        const char *msgId) {
  size_t context_len = strlen(context) + 1;
  size_t msgId_len = strlen(msgId) + 1;
  char ctxMsgId[context_len + msgId_len];
  memcpy(ctxMsgId, context, context_len - 1);
  ctxMsgId[context_len - 1] = '\004';
  memcpy(ctxMsgId + context_len, msgId, msgId_len);
  const char *const translation = dgettext(domain, ctxMsgId);
  if (translation == ctxMsgId)
    return msgId;
  return translation;
}


x86 assembly (clang, -O0):
<b_dpgettext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%rdx
mov    %rcx,%rax
add    %rdx,%rax
mov    %rsp,%rsi
mov    %rsi,-0x38(%rbp)
lea    0xf(%rcx,%rdx,1),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x58(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
sub    $0x1,%rdx
call   1050 <memcpy@plt>
mov    -0x58(%rbp),%rdi
mov    -0x28(%rbp),%rax
sub    $0x1,%rax
movb   $0x4,(%rdi,%rax,1)
add    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x58(%rbp),%rsi
mov    -0x10(%rbp),%rdi
call   1040 <dgettext@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
mov    %rcx,-0x48(%rbp)
cmp    %rax,-0x48(%rbp)
jne    11ff <b_dpgettext+0xcf>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x4c(%rbp)
jmp    120e <b_dpgettext+0xde>
mov    -0x48(%rbp),%rax
mov    %rax,-0x8(%rbp)
movl   $0x1,-0x4c(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<b_dpgettext>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,-0x30(%rbp)
mov    %rsi,%rdi
call   1030 <strlen@plt>
movslq %eax,%r13
mov    %r15,%rdi
call   1030 <strlen@plt>
movslq %eax,%rbx
lea    (%rbx,%r13,1),%rax
add    $0x11,%rax
add    $0x1,%rbx
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <memcpy@plt>
movb   $0x4,0x0(%r13,%r14,1)
lea    (%r14,%r13,1),%rdi
add    $0x1,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <memcpy@plt>
mov    -0x30(%rbp),%rdi
mov    %r14,%rsi
call   1040 <dgettext@plt>
cmp    %r14,%rax
cmove  %r15,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @b_dpgettext(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i8*
%13 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%14 = load i8*, i8** %6
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %15, 1
%17 = sext i32 %16 to i64
store i64 %17, i64* %8
%18 = load i8*, i8** %7
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 1
%21 = sext i32 %20 to i64
store i64 %21, i64* %9
%22 = load i64, i64* %8
%23 = load i64, i64* %9
%24 = add i64 %22, %23
%25 = call i8* @llvm.stacksave()
store i8* %25, i8** %10
%26 = alloca i8, i64 %24
store i64 %24, i64* %11
%27 = load i8*, i8** %6
%28 = load i64, i64* %8
%29 = sub i64 %28, 1
%30 = call i32 @memcpy(i8* %26, i8* %27, i64 %29)
%31 = load i64, i64* %8
%32 = sub i64 %31, 1
%33 = getelementptr inbounds i8, i8* %26, i64 %32
store i8 4, i8* %33
%34 = load i64, i64* %8
%35 = getelementptr inbounds i8, i8* %26, i64 %34
%36 = load i8*, i8** %7
%37 = load i64, i64* %9
%38 = call i32 @memcpy(i8* %35, i8* %36, i64 %37)
%39 = load i8*, i8** %5
%40 = call i8* @dgettext(i8* %39, i8* %26)
store i8* %40, i8** %12
%41 = load i8*, i8** %12
%42 = icmp eq i8* %41, %26
br i1 %42, label %43, label %45
43: ; preds = %3
%44 = load i8*, i8** %7
store i8* %44, i8** %4
store i32 1, i32* %13
br label %47
45: ; preds = %3
%46 = load i8*, i8** %12
store i8* %46, i8** %4
store i32 1, i32* %13
br label %47
47: ; preds = %45, %43
%48 = load i8*, i8** %10
%49 = load i8*, i8** %4
ret i8* %49
}

LLVM IR (-O2):
define i8* @b_dpgettext(i8* %0, i8* %1, i8* %2) {
%4 = tail call i32 @strlen(i8* %1)
%5 = add nsw i32 %4, 1
%6 = sext i32 %5 to i64
%7 = tail call i32 @strlen(i8* %2)
%8 = add nsw i32 %7, 1
%9 = sext i32 %8 to i64
%10 = add nsw i64 %9, %6
%11 = alloca i8, i64 %10
%12 = add nsw i64 %6, -1
%13 = call i32 @memcpy(i8* %11, i8* %1, i64 %12)
%14 = getelementptr inbounds i8, i8* %11, i64 %12
store i8 4, i8* %14
%15 = getelementptr inbounds i8, i8* %11, i64 %6
%16 = call i32 @memcpy(i8* %15, i8* %2, i64 %9)
%17 = call i8* @dgettext(i8* %0, i8* %11)
%18 = icmp eq i8* %17, %11
%19 = select i1 %18, i8* %2, i8* %17
ret i8* %19
}