#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char *gettext(char *);
scalar_t__ malloc(size_t);
int /*<<< orphan*/ memcpy(char *, char const *, size_t);
int strlen(char const *);
const char *__pgettext_expr(const char *msgctxt, const char *msgid) {
  size_t msgctxt_len = strlen(msgctxt) + 1;
  size_t msgid_len = strlen(msgid) + 1;
  const char *translation;
  char buf[1024];
  char *msg_ctxt_id = (msgctxt_len + msgid_len <= sizeof(buf)
                           ? buf
                           : (char *)malloc(msgctxt_len + msgid_len));
  if (msg_ctxt_id != NULL) {
    int found_translation;
    memcpy(msg_ctxt_id, msgctxt, msgctxt_len - 1);
    msg_ctxt_id[msgctxt_len - 1] = '\004';
    memcpy(msg_ctxt_id + msgctxt_len, msgid, msgid_len);
    translation = gettext(msg_ctxt_id);
    found_translation = (translation != msg_ctxt_id);
    if (msg_ctxt_id != buf)
      free(msg_ctxt_id);
    if (found_translation)
      return translation;
  }
  return msgid;
}


x86 assembly (clang, -O0):
<__pgettext_expr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
add    -0x28(%rbp),%rax
cmp    $0x400,%rax
ja     11ae <__pgettext_expr+0x5e>
lea    -0x430(%rbp),%rax
mov    %rax,-0x448(%rbp)
jmp    11c2 <__pgettext_expr+0x72>
mov    -0x20(%rbp),%rdi
add    -0x28(%rbp),%rdi
call   1070 <malloc@plt>
mov    %rax,-0x448(%rbp)
mov    -0x448(%rbp),%rax
mov    %rax,-0x438(%rbp)
cmpq   $0x0,-0x438(%rbp)
je     128c <__pgettext_expr+0x13c>
mov    -0x438(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
sub    $0x1,%rdx
call   1060 <memcpy@plt>
mov    -0x438(%rbp),%rax
mov    -0x20(%rbp),%rcx
sub    $0x1,%rcx
movb   $0x4,(%rax,%rcx,1)
mov    -0x438(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1060 <memcpy@plt>
mov    -0x438(%rbp),%rdi
call   1050 <gettext@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x438(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x43c(%rbp)
mov    -0x438(%rbp),%rax
lea    -0x430(%rbp),%rcx
cmp    %rcx,%rax
je     126d <__pgettext_expr+0x11d>
mov    -0x438(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x43c(%rbp)
je     1287 <__pgettext_expr+0x137>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1294 <__pgettext_expr+0x144>
jmp    128c <__pgettext_expr+0x13c>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__pgettext_expr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
call   1040 <strlen@plt>
movslq %eax,%rbx
mov    %r14,%rdi
call   1040 <strlen@plt>
movslq %eax,%r13
mov    %rsp,%rbp
lea    (%rbx,%r13,1),%rdi
add    $0x2,%rdi
mov    %rbp,%r15
cmp    $0x401,%rdi
jb     119e <__pgettext_expr+0x4e>
call   1070 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
je     11e9 <__pgettext_expr+0x99>
add    $0x1,%rbx
add    $0x1,%r13
lea    -0x1(%rbx),%rdx
mov    %r15,%rdi
mov    %r12,%rsi
call   1060 <memcpy@plt>
movb   $0x4,-0x1(%r15,%rbx,1)
add    %r15,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r13,%rdx
call   1060 <memcpy@plt>
mov    %r15,%rdi
call   1050 <gettext@plt>
mov    %rax,%rbx
cmp    %rbp,%r15
je     11e4 <__pgettext_expr+0x94>
mov    %r15,%rdi
call   1030 <free@plt>
cmp    %r15,%rbx
jne    11ec <__pgettext_expr+0x9c>
mov    %r14,%rbx
mov    %rbx,%rax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @__pgettext_expr(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca [1024 x i8]
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
%12 = load i8*, i8** %4
%13 = call i32 @strlen(i8* %12)
%14 = add nsw i32 %13, 1
%15 = sext i32 %14 to i64
store i64 %15, i64* %6
%16 = load i8*, i8** %5
%17 = call i32 @strlen(i8* %16)
%18 = add nsw i32 %17, 1
%19 = sext i32 %18 to i64
store i64 %19, i64* %7
%20 = load i64, i64* %6
%21 = load i64, i64* %7
%22 = add i64 %20, %21
%23 = icmp ule i64 %22, 1024
br i1 %23, label %24, label %26
24: ; preds = %2
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
br label %32
26: ; preds = %2
%27 = load i64, i64* %6
%28 = load i64, i64* %7
%29 = add i64 %27, %28
%30 = call i64 @malloc(i64 %29)
%31 = inttoptr i64 %30 to i8*
br label %32
32: ; preds = %26, %24
%33 = phi i8* [ %25, %24 ], [ %31, %26 ]
store i8* %33, i8** %10
%34 = load i8*, i8** %10
%35 = icmp ne i8* %34, null
br i1 %35, label %36, label %70
36: ; preds = %32
%37 = load i8*, i8** %10
%38 = load i8*, i8** %4
%39 = load i64, i64* %6
%40 = sub i64 %39, 1
%41 = call i32 @memcpy(i8* %37, i8* %38, i64 %40)
%42 = load i8*, i8** %10
%43 = load i64, i64* %6
%44 = sub i64 %43, 1
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8 4, i8* %45
%46 = load i8*, i8** %10
%47 = load i64, i64* %6
%48 = getelementptr inbounds i8, i8* %46, i64 %47
%49 = load i8*, i8** %5
%50 = load i64, i64* %7
%51 = call i32 @memcpy(i8* %48, i8* %49, i64 %50)
%52 = load i8*, i8** %10
%53 = call i8* @gettext(i8* %52)
store i8* %53, i8** %8
%54 = load i8*, i8** %8
%55 = load i8*, i8** %10
%56 = icmp ne i8* %54, %55
%57 = zext i1 %56 to i32
store i32 %57, i32* %11
%58 = load i8*, i8** %10
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%60 = icmp ne i8* %58, %59
br i1 %60, label %61, label %64
61: ; preds = %36
%62 = load i8*, i8** %10
%63 = call i32 @free(i8* %62)
br label %64
64: ; preds = %61, %36
%65 = load i32, i32* %11
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = load i8*, i8** %8
store i8* %68, i8** %3
br label %72
69: ; preds = %64
br label %70
70: ; preds = %69, %32
%71 = load i8*, i8** %5
store i8* %71, i8** %3
br label %72
72: ; preds = %70, %67
%73 = load i8*, i8** %3
ret i8* %73
}

LLVM IR (-O2):
define i8* @__pgettext_expr(i8* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = tail call i32 @strlen(i8* %0)
%5 = add nsw i32 %4, 1
%6 = sext i32 %5 to i64
%7 = tail call i32 @strlen(i8* %1)
%8 = add nsw i32 %7, 1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%11 = add nsw i64 %9, %6
%12 = icmp ult i64 %11, 1025
br i1 %12, label %17, label %13
13: ; preds = %2
%14 = tail call i64 @malloc(i64 %11)
%15 = inttoptr i64 %14 to i8*
%16 = icmp eq i64 %14, 0
br i1 %16, label %30, label %17
17: ; preds = %2, %13
%18 = phi i8* [ %15, %13 ], [ %10, %2 ]
%19 = add nsw i64 %6, -1
%20 = call i32 @memcpy(i8* %18, i8* %0, i64 %19)
%21 = getelementptr inbounds i8, i8* %18, i64 %19
store i8 4, i8* %21
%22 = getelementptr inbounds i8, i8* %18, i64 %6
%23 = call i32 @memcpy(i8* %22, i8* %1, i64 %9)
%24 = call i8* @gettext(i8* %18)
%25 = icmp eq i8* %24, %18
%26 = icmp eq i8* %18, %10
br i1 %26, label %29, label %27
27: ; preds = %17
%28 = call i32 @free(i8* %18)
br label %29
29: ; preds = %17, %27
br i1 %25, label %30, label %31
30: ; preds = %29, %13
br label %31
31: ; preds = %29, %30
%32 = phi i8* [ %1, %30 ], [ %24, %29 ]
ret i8* %32
}