#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 scalar_t__ nl_catd;

/* Variables and functions */
scalar_t__ getenv(char *);
int /*<<< orphan*/ strcmp(char *, char *);
char *strdup(char *);
char *_DtHPrGetMessage(int set, int n, char *s) {
  char *msg;
  char *lang;
  nl_catd catopen();
  char *catgets();
  static int s_First = 1;
  static nl_catd s_Nlmsg_fd;
  static char *s_CatFileName = NULL;
  if (s_First) {
    if (s_CatFileName == NULL) {
      s_CatFileName = strdup("dthelpprint");
    }
    s_First = 0;
    lang = (char *)getenv("LANG");
    if (!lang || !(strcmp(lang, "C")))
      s_Nlmsg_fd = (nl_catd)-1;
    else
      s_Nlmsg_fd = catopen(s_CatFileName, 0);
  }
  msg = catgets(s_Nlmsg_fd, set, n, s);
  return (msg);
}


x86 assembly (clang, -O0):
<_DtHPrGetMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
cmpl   $0x0,0x2edf(%rip)
je     11fa <_DtHPrGetMessage+0xaa>
cmpq   $0x0,0x2ee9(%rip)
jne    1190 <_DtHPrGetMessage+0x40>
lea    0xe7c(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,0x2ed0(%rip)
movl   $0x0,0x2eae(%rip)
lea    0xe6b(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ce <_DtHPrGetMessage+0x7e>
mov    -0x20(%rbp),%rdi
lea    0xe51(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11de <_DtHPrGetMessage+0x8e>
movq   $0xffffffffffffffff,0x2e7f(%rip)
ff ff ff ff
jmp    11f5 <_DtHPrGetMessage+0xa5>
mov    0x2e7b(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1050 <catopen@plt>
mov    %rax,0x2e63(%rip)
jmp    11fa <_DtHPrGetMessage+0xaa>
mov    0x2e57(%rip),%rdi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1060 <catgets@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_DtHPrGetMessage>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%r15d
mov    %edi,%ebx
cmpb   $0x1,0x2eea(%rip)
jne    1171 <_DtHPrGetMessage+0x21>
mov    0x2ee9(%rip),%rdi
jmp    11e8 <_DtHPrGetMessage+0x98>
mov    0x2ee8(%rip),%rbp
test   %rbp,%rbp
jne    1193 <_DtHPrGetMessage+0x43>
lea    0xe7c(%rip),%rdi
call   1070 <strdup@plt>
mov    %rax,%rbp
mov    %rax,0x2ecd(%rip)
movb   $0x1,0x2eb6(%rip)
lea    0xe6b(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11d6 <_DtHPrGetMessage+0x86>
lea    0xe5f(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11d6 <_DtHPrGetMessage+0x86>
mov    %rbp,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <catopen@plt>
mov    %rax,%rdi
mov    %rax,0x2e84(%rip)
jmp    11e8 <_DtHPrGetMessage+0x98>
movq   $0xffffffffffffffff,0x2e77(%rip)
ff ff ff ff
mov    $0xffffffffffffffff,%rdi
mov    %ebx,%esi
mov    %r15d,%edx
mov    %r14,%rcx
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <catgets@plt>

LLVM IR (-O0):
@_DtHPrGetMessage.s_First = internal global i32 1
@_DtHPrGetMessage.s_Nlmsg_fd = internal global i64 0
@_DtHPrGetMessage.s_CatFileName = internal global i8* null
@.str = [12 x i8] c"dthelpprint\00"
@.str.1 = [5 x i8] c"LANG\00"
@.str.2 = [2 x i8] c"C\00"
define i8* @_DtHPrGetMessage(i32 %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = load i32, i32* @_DtHPrGetMessage.s_First
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %30
11: ; preds = %3
%12 = load i8*, i8** @_DtHPrGetMessage.s_CatFileName
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i8* @strdup(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %15, i8** @_DtHPrGetMessage.s_CatFileName
br label %16
16: ; preds = %14, %11
store i32 0, i32* @_DtHPrGetMessage.s_First
%17 = call i64 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %25
21: ; preds = %16
%22 = load i8*, i8** %8
%23 = call i32 @strcmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp ne i32 %23, 0
br i1 %24, label %26, label %25
25: ; preds = %21, %16
store i64 -1, i64* @_DtHPrGetMessage.s_Nlmsg_fd
br label %29
26: ; preds = %21
%27 = load i8*, i8** @_DtHPrGetMessage.s_CatFileName
%28 = call i64 (i8*, i32, ...) bitcast (i64 (...)* @catopen to i64 (i8*, i32, ...)*)(i8* %27, i32 0)
store i64 %28, i64* @_DtHPrGetMessage.s_Nlmsg_fd
br label %29
29: ; preds = %26, %25
br label %30
30: ; preds = %29, %3
%31 = load i64, i64* @_DtHPrGetMessage.s_Nlmsg_fd
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = load i8*, i8** %6
%35 = call i8* (i64, i32, i32, i8*, ...) bitcast (i8* (...)* @catgets to i8* (i64, i32, i32, i8*, ...)*)(i64 %31, i32 %32, i32 %33, i8* %34)
store i8* %35, i8** %7
%36 = load i8*, i8** %7
ret i8* %36
}

LLVM IR (-O2):
@_DtHPrGetMessage.s_First = internal unnamed_addr global i1 false
@_DtHPrGetMessage.s_Nlmsg_fd = internal unnamed_addr global i64 0
@_DtHPrGetMessage.s_CatFileName = internal unnamed_addr global i8* null
@.str = [12 x i8] c"dthelpprint\00"
@.str.1 = [5 x i8] c"LANG\00"
@.str.2 = [2 x i8] c"C\00"
define i8* @_DtHPrGetMessage(i32 %0, i32 %1, i8* %2) {
%4 = load i1, i1* @_DtHPrGetMessage.s_First
br i1 %4, label %5, label %7
5: ; preds = %3
%6 = load i64, i64* @_DtHPrGetMessage.s_Nlmsg_fd
br label %23
7: ; preds = %3
%8 = load i8*, i8** @_DtHPrGetMessage.s_CatFileName
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call dereferenceable_or_null(12) i8* @strdup(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i8* %11, i8** @_DtHPrGetMessage.s_CatFileName
br label %12
12: ; preds = %10, %7
%13 = phi i8* [ %11, %10 ], [ %8, %7 ]
store i1 true, i1* @_DtHPrGetMessage.s_First
%14 = tail call i64 @getenv(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = inttoptr i64 %14 to i8*
%18 = tail call i32 @strcmp(i8* %17, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16, %12
store i64 -1, i64* @_DtHPrGetMessage.s_Nlmsg_fd
br label %23
21: ; preds = %16
%22 = tail call i64 (i8*, i32, ...) bitcast (i64 (...)* @catopen to i64 (i8*, i32, ...)*)(i8* %13, i32 0)
store i64 %22, i64* @_DtHPrGetMessage.s_Nlmsg_fd
br label %23
23: ; preds = %5, %20, %21
%24 = phi i64 [ %6, %5 ], [ -1, %20 ], [ %22, %21 ]
%25 = tail call i8* (i64, i32, i32, i8*, ...) bitcast (i8* (...)* @catgets to i8* (i64, i32, i32, i8*, ...)*)(i64 %24, i32 %0, i32 %1, i8* %2)
ret i8* %25
}