#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ keys;
struct TYPE_3__ {
  char *addr;
};
typedef TYPE_1__ XrmValue;
typedef int /*<<< orphan*/ *XrmDatabase;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
char *XResourceManagerString(int /*<<< orphan*/ *);
char *XSetLocaleModifiers(char *);
scalar_t__ XSupportsLocale();
int /*<<< orphan*/ XrmDestroyDatabase(int /*<<< orphan*/ *);
int /*<<< orphan*/ XrmGetResource(int /*<<< orphan*/ *, char const *, char *,
                                  char **, TYPE_1__ *);
int /*<<< orphan*/ *XrmGetStringDatabase(char *);
int /*<<< orphan*/ XrmInitialize();
int /*<<< orphan*/ errx(int, char *);
int /*<<< orphan*/ printf(char *, char const *, ...);
int main(void) {
  static const char *keys[] = {
      "Xft.dpi",        "Xft.antialias",           "Xcursor.theme",
      "*customization", "xscreensaver.dateFormat", "xscreensaver.*",
  };
  char *resmgr, *type;
  XrmDatabase db;
  XrmValue ret;
  Display *dpy;
  size_t i;
  if (XSupportsLocale())
    printf("locale: '%s'\n", XSetLocaleModifiers(""));
  dpy = XOpenDisplay(NULL);
  if (!dpy)
    errx(1, "failed to open display");
  XrmInitialize();
  resmgr = XResourceManagerString(dpy);
  printf("%s\n\n\n", resmgr);
  db = XrmGetStringDatabase(resmgr);
  if (db == NULL)
    errx(1, "failed to open database");
  for (i = 0; i < (sizeof(keys) / sizeof(keys[0])); i++) {
    XrmGetResource(db, keys[i], "String", &type, &ret);
    printf("[%s] (%s) = %s\n", keys[i], type, ret.addr);
  }
  XrmDestroyDatabase(db);
  XCloseDisplay(dpy);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1090 <XSupportsLocale@plt>
cmp    $0x0,%rax
je     11ed <main+0x3d>
lea    0xead(%rip),%rdi
call   10b0 <XSetLocaleModifiers@plt>
mov    %rax,%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <XOpenDisplay@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1216 <main+0x66>
mov    $0x1,%edi
lea    0xe57(%rip),%rsi
call   1050 <errx@plt>
mov    $0x0,%al
call   1040 <XrmInitialize@plt>
mov    -0x30(%rbp),%rdi
call   10a0 <XResourceManagerString@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe4a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1070 <XrmGetStringDatabase@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1265 <main+0xb5>
mov    $0x1,%edi
lea    0xe25(%rip),%rsi
call   1050 <errx@plt>
movq   $0x0,-0x38(%rbp)
cmpq   $0x6,-0x38(%rbp)
jae    12d5 <main+0x125>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rcx
lea    0x2df9(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xe0b(%rip),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x28(%rbp),%r8
call   1030 <XrmGetResource@plt>
mov    -0x38(%rbp),%rcx
lea    0x2dd6(%rip),%rax
mov    (%rax,%rcx,8),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    126d <main+0xbd>
mov    -0x20(%rbp),%rdi
call   10c0 <XrmDestroyDatabase@plt>
mov    -0x30(%rbp),%rdi
call   10d0 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1090 <XSupportsLocale@plt>
test   %rax,%rax
je     11e7 <main+0x37>
lea    0xeb3(%rip),%rdi
call   10b0 <XSetLocaleModifiers@plt>
lea    0xe7d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1080 <XOpenDisplay@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1207 <main+0x57>
lea    0xe6b(%rip),%rsi
mov    $0x1,%edi
call   1050 <errx@plt>
xor    %eax,%eax
call   1040 <XrmInitialize@plt>
mov    %rbx,%rdi
call   10a0 <XResourceManagerString@plt>
mov    %rbx,0x10(%rsp)
mov    %rax,%rbx
lea    0xe5a(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1070 <XrmGetStringDatabase@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1250 <main+0xa0>
lea    0xe3f(%rip),%rsi
mov    $0x1,%edi
call   1050 <errx@plt>
lea    0xda9(%rip),%r14
lea    0xe3f(%rip),%r12
lea    0x8(%rsp),%r13
mov    %rsp,%r8
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
call   1030 <XrmGetResource@plt>
mov    0x8(%rsp),%rdx
mov    (%rsp),%rcx
lea    0xe1d(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd6d(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r12,%rdx
mov    %r12,%r14
mov    %r13,%rcx
mov    %r13,%r12
mov    %rsp,%r8
mov    %r8,%r13
call   1030 <XrmGetResource@plt>
mov    0x8(%rsp),%rdx
mov    (%rsp),%rcx
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd41(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1030 <XrmGetResource@plt>
mov    0x8(%rsp),%rdx
mov    (%rsp),%rcx
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd1e(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1030 <XrmGetResource@plt>
mov    0x8(%rsp),%rdx
mov    (%rsp),%rcx
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xcfc(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1030 <XrmGetResource@plt>
mov    0x8(%rsp),%rdx
mov    (%rsp),%rcx
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xce3(%rip),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
mov    %r12,%rcx
mov    %r13,%r8
call   1030 <XrmGetResource@plt>
mov    0x8(%rsp),%rdx
mov    (%rsp),%rcx
mov    %r15,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   10c0 <XrmDestroyDatabase@plt>
mov    0x10(%rsp),%rdi
call   10d0 <XCloseDisplay@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8* }
@main.keys = internal global [6 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i32 0, i32 0)]
@.str = [8 x i8] c"Xft.dpi\00"
@.str.1 = [14 x i8] c"Xft.antialias\00"
@.str.2 = [14 x i8] c"Xcursor.theme\00"
@.str.3 = [15 x i8] c"*customization\00"
@.str.4 = [24 x i8] c"xscreensaver.dateFormat\00"
@.str.5 = [15 x i8] c"xscreensaver.*\00"
@.str.6 = [14 x i8] c"locale: '%s'\0A\00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [23 x i8] c"failed to open display\00"
@.str.9 = [6 x i8] c"%s\0A\0A\0A\00"
@.str.10 = [24 x i8] c"failed to open database\00"
@.str.11 = [7 x i8] c"String\00"
@.str.12 = [16 x i8] c"[%s] (%s) = %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca %struct.TYPE_3__
%6 = alloca i32*
%7 = alloca i64
store i32 0, i32* %1
%8 = call i64 (...) @XSupportsLocale()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i8* @XSetLocaleModifiers(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %11)
br label %13
13: ; preds = %10, %0
%14 = call i32* @XOpenDisplay(i32* null)
store i32* %14, i32** %6
%15 = load i32*, i32** %6
%16 = icmp ne i32* %15, null
br i1 %16, label %19, label %17
17: ; preds = %13
%18 = call i32 @errx(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %19
19: ; preds = %17, %13
%20 = call i32 (...) @XrmInitialize()
%21 = load i32*, i32** %6
%22 = call i8* @XResourceManagerString(i32* %21)
store i8* %22, i8** %2
%23 = load i8*, i8** %2
%24 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* %23)
%25 = load i8*, i8** %2
%26 = call i32* @XrmGetStringDatabase(i8* %25)
store i32* %26, i32** %4
%27 = load i32*, i32** %4
%28 = icmp eq i32* %27, null
br i1 %28, label %29, label %31
29: ; preds = %19
%30 = call i32 @errx(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
br label %31
31: ; preds = %29, %19
store i64 0, i64* %7
br label %32
32: ; preds = %48, %31
%33 = load i64, i64* %7
%34 = icmp ult i64 %33, 6
br i1 %34, label %35, label %51
35: ; preds = %32
%36 = load i32*, i32** %4
%37 = load i64, i64* %7
%38 = getelementptr inbounds [6 x i8*], [6 x i8*]* @main.keys, i64 0, i64 %37
%39 = load i8*, i8** %38
%40 = call i32 @XrmGetResource(i32* %36, i8* %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8** %3, %struct.TYPE_3__* %5)
%41 = load i64, i64* %7
%42 = getelementptr inbounds [6 x i8*], [6 x i8*]* @main.keys, i64 0, i64 %41
%43 = load i8*, i8** %42
%44 = load i8*, i8** %3
%45 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i32 0, i32 0
%46 = load i8*, i8** %45
%47 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* %43, i8* %44, i8* %46)
br label %48
48: ; preds = %35
%49 = load i64, i64* %7
%50 = add i64 %49, 1
store i64 %50, i64* %7
br label %32
51: ; preds = %32
%52 = load i32*, i32** %4
%53 = call i32 @XrmDestroyDatabase(i32* %52)
%54 = load i32*, i32** %6
%55 = call i32 @XCloseDisplay(i32* %54)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8* }
@.str = [8 x i8] c"Xft.dpi\00"
@.str.1 = [14 x i8] c"Xft.antialias\00"
@.str.2 = [14 x i8] c"Xcursor.theme\00"
@.str.3 = [15 x i8] c"*customization\00"
@.str.4 = [24 x i8] c"xscreensaver.dateFormat\00"
@.str.5 = [15 x i8] c"xscreensaver.*\00"
@.str.6 = [14 x i8] c"locale: '%s'\0A\00"
@.str.7 = [1 x i8] zeroinitializer
@.str.8 = [23 x i8] c"failed to open display\00"
@.str.9 = [6 x i8] c"%s\0A\0A\0A\00"
@.str.10 = [24 x i8] c"failed to open database\00"
@.str.11 = [7 x i8] c"String\00"
@.str.12 = [16 x i8] c"[%s] (%s) = %s\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca %struct.TYPE_3__
%3 = bitcast i8** %1 to i8*
%4 = bitcast %struct.TYPE_3__* %2 to i8*
%5 = tail call i64 (...) @XSupportsLocale()
%6 = icmp eq i64 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = tail call i8* @XSetLocaleModifiers(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.7, i64 0, i64 0))
%9 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0), i8* %8)
br label %10
10: ; preds = %7, %0
%11 = tail call i32* @XOpenDisplay(i32* null)
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.8, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = tail call i32 (...) @XrmInitialize()
%17 = tail call i8* @XResourceManagerString(i32* %11)
%18 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i8* %17)
%19 = tail call i32* @XrmGetStringDatabase(i8* %17)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = tail call i32 @errx(i32 1, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0))
br label %23
23: ; preds = %21, %15
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %2, i64 0, i32 0
%25 = call i32 @XrmGetResource(i32* %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8** %1, %struct.TYPE_3__* %2)
%26 = load i8*, i8** %1
%27 = load i8*, i8** %24
%28 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27)
%29 = call i32 @XrmGetResource(i32* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8** %1, %struct.TYPE_3__* %2)
%30 = load i8*, i8** %1
%31 = load i8*, i8** %24
%32 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %30, i8* %31)
%33 = call i32 @XrmGetResource(i32* %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8** %1, %struct.TYPE_3__* %2)
%34 = load i8*, i8** %1
%35 = load i8*, i8** %24
%36 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8* %34, i8* %35)
%37 = call i32 @XrmGetResource(i32* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8** %1, %struct.TYPE_3__* %2)
%38 = load i8*, i8** %1
%39 = load i8*, i8** %24
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i8* %38, i8* %39)
%41 = call i32 @XrmGetResource(i32* %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8** %1, %struct.TYPE_3__* %2)
%42 = load i8*, i8** %1
%43 = load i8*, i8** %24
%44 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0), i8* %42, i8* %43)
%45 = call i32 @XrmGetResource(i32* %19, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0), i8** %1, %struct.TYPE_3__* %2)
%46 = load i8*, i8** %1
%47 = load i8*, i8** %24
%48 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %46, i8* %47)
%49 = call i32 @XrmDestroyDatabase(i32* %19)
%50 = call i32 @XCloseDisplay(i32* %11)
ret i32 0
}