#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*/ nl_catd;

/* Variables and functions */
int /*<<< orphan*/ NL_CAT_LOCALE;
char *catgets(int /*<<< orphan*/, int, int, char *);
int /*<<< orphan*/ catopen(char *, int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
char *Dt11GetMessage(char *filename, int set, int n, char *s) {
  char *msg;
  static int first = 1;
  static nl_catd nlmsg_fd;
  static char *nlmsg_filename = NULL;
  ;
  if (NULL == nlmsg_filename || 0 != strcmp(nlmsg_filename, filename)) {
    nlmsg_fd = catopen(filename, NL_CAT_LOCALE);
    if (nlmsg_filename) {
      free(nlmsg_filename);
      nlmsg_filename = NULL;
    }
    nlmsg_filename = strdup(filename);
  }
  msg = catgets(nlmsg_fd, set, n, s);
  ;
  return (msg);
}


x86 assembly (clang, -O0):
<Dt11GetMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
xor    %eax,%eax
cmp    0x2ef1(%rip),%rax
je     1193 <Dt11GetMessage+0x43>
mov    0x2ee4(%rip),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
je     11e0 <Dt11GetMessage+0x90>
mov    -0x8(%rbp),%rdi
mov    0x2e42(%rip),%rax
mov    (%rax),%esi
call   1050 <catopen@plt>
mov    %eax,0x2ead(%rip)
cmpq   $0x0,0x2ead(%rip)
je     11d0 <Dt11GetMessage+0x80>
mov    0x2ea0(%rip),%rdi
call   1030 <free@plt>
movq   $0x0,0x2e90(%rip)
mov    -0x8(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,0x2e80(%rip)
mov    0x2e72(%rip),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1060 <catgets@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Dt11GetMessage>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbp
mov    0x2eed(%rip),%rdi
test   %rdi,%rdi
je     117d <Dt11GetMessage+0x2d>
mov    %rbp,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b8 <Dt11GetMessage+0x68>
mov    0x2e5c(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1050 <catopen@plt>
mov    %eax,%ebx
mov    %eax,0x2eba(%rip)
mov    0x2ebb(%rip),%rdi
test   %rdi,%rdi
je     11a7 <Dt11GetMessage+0x57>
call   1030 <free@plt>
mov    %rbp,%rdi
call   1070 <strdup@plt>
mov    %rax,0x2ea2(%rip)
jmp    11be <Dt11GetMessage+0x6e>
mov    0x2e92(%rip),%ebx
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %r14,%rcx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <catgets@plt>

LLVM IR (-O0):
@Dt11GetMessage.first = internal global i32 1
@Dt11GetMessage.nlmsg_fd = internal global i32 0
@Dt11GetMessage.nlmsg_filename = internal global i8* null
@NL_CAT_LOCALE = global i32 0
define i8* @Dt11GetMessage(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%10 = load i8*, i8** @Dt11GetMessage.nlmsg_filename
%11 = icmp eq i8* null, %10
br i1 %11, label %17, label %12
12: ; preds = %4
%13 = load i8*, i8** @Dt11GetMessage.nlmsg_filename
%14 = load i8*, i8** %5
%15 = call i64 @strcmp(i8* %13, i8* %14)
%16 = icmp ne i64 0, %15
br i1 %16, label %17, label %29
17: ; preds = %12, %4
%18 = load i8*, i8** %5
%19 = load i32, i32* @NL_CAT_LOCALE
%20 = call i32 @catopen(i8* %18, i32 %19)
store i32 %20, i32* @Dt11GetMessage.nlmsg_fd
%21 = load i8*, i8** @Dt11GetMessage.nlmsg_filename
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = load i8*, i8** @Dt11GetMessage.nlmsg_filename
%25 = call i32 @free(i8* %24)
store i8* null, i8** @Dt11GetMessage.nlmsg_filename
br label %26
26: ; preds = %23, %17
%27 = load i8*, i8** %5
%28 = call i8* @strdup(i8* %27)
store i8* %28, i8** @Dt11GetMessage.nlmsg_filename
br label %29
29: ; preds = %26, %12
%30 = load i32, i32* @Dt11GetMessage.nlmsg_fd
%31 = load i32, i32* %6
%32 = load i32, i32* %7
%33 = load i8*, i8** %8
%34 = call i8* @catgets(i32 %30, i32 %31, i32 %32, i8* %33)
store i8* %34, i8** %9
%35 = load i8*, i8** %9
ret i8* %35
}

LLVM IR (-O2):
@Dt11GetMessage.nlmsg_fd = internal unnamed_addr global i32 0
@Dt11GetMessage.nlmsg_filename = internal unnamed_addr global i8* null
@NL_CAT_LOCALE = global i32 0
define i8* @Dt11GetMessage(i8* %0, i32 %1, i32 %2, i8* %3) {
%5 = load i8*, i8** @Dt11GetMessage.nlmsg_filename
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %5, i8* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = load i32, i32* @Dt11GetMessage.nlmsg_fd
br label %21
12: ; preds = %7, %4
%13 = load i32, i32* @NL_CAT_LOCALE
%14 = tail call i32 @catopen(i8* %0, i32 %13)
store i32 %14, i32* @Dt11GetMessage.nlmsg_fd
%15 = load i8*, i8** @Dt11GetMessage.nlmsg_filename
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %12
%18 = tail call i32 @free(i8* %15)
br label %19
19: ; preds = %17, %12
%20 = tail call i8* @strdup(i8* %0)
store i8* %20, i8** @Dt11GetMessage.nlmsg_filename
br label %21
21: ; preds = %10, %19
%22 = phi i32 [ %11, %10 ], [ %14, %19 ]
%23 = tail call i8* @catgets(i32 %22, i32 %1, i32 %2, i8* %3)
ret i8* %23
}