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

/* Variables and functions */
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XFlush(int /*<<< orphan*/ *);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
char *XResourceManagerString(int /*<<< orphan*/ *);
int /*<<< orphan*/ XrmDestroyDatabase(int /*<<< orphan*/);
int /*<<< orphan*/ XrmGetStringDatabase(char *);
int /*<<< orphan*/ XrmInitialize();
int /*<<< orphan*/ errx(int, char *, ...);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ warnx(char *);
int /*<<< orphan*/ xrdb_print_value(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  XrmDatabase xrdb;
  Display *dpy;
  char *xrm;
  size_t i;
  int ret_code;
  if (argv[1] == NULL || !strcmp(argv[1], "-h")) {
    errx(1, "usage: %s <resource names>...", argv[0]);
  } else {
    ++argv;
    --argc;
  }
  if (!(dpy = XOpenDisplay(NULL))) {
    errx(1, "could not open the display!");
  }
  XrmInitialize();
  xrm = XResourceManagerString(dpy);
  if (xrm != NULL) {
    xrdb = XrmGetStringDatabase(xrm);
    for (i = 0; i < argc; i++) {
      xrdb_print_value(xrdb, argv[i]);
    }
    XrmDestroyDatabase(xrdb);
    ret_code = 0;
  } else {
    warnx("could not get the resource properties.");
    ret_code = 1;
  }
  XFlush(dpy);
  XCloseDisplay(dpy);
  return ret_code;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11f2 <main+0x42>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1c(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    1211 <main+0x61>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    $0x1,%edi
lea    0xdfe(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
jmp    1226 <main+0x76>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <XOpenDisplay@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1250 <main+0xa0>
mov    $0x1,%edi
lea    0xdd8(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    $0x0,%al
call   1030 <XrmInitialize@plt>
mov    -0x20(%rbp),%rdi
call   1090 <XResourceManagerString@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12cd <main+0x11d>
mov    -0x28(%rbp),%rdi
call   1060 <XrmGetStringDatabase@plt>
mov    %eax,-0x14(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x8(%rbp),%rcx
cmp    %rcx,%rax
jae    12b9 <main+0x109>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
call   10c0 <xrdb_print_value@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    1283 <main+0xd3>
mov    -0x14(%rbp),%edi
call   10b0 <XrmDestroyDatabase@plt>
movl   $0x0,-0x34(%rbp)
jmp    12e0 <main+0x130>
lea    0xd69(%rip),%rdi
call   1050 <warnx@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
call   10a0 <XFlush@plt>
mov    -0x20(%rbp),%rdi
call   10d0 <XCloseDisplay@plt>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%r14d
mov    0x8(%rsi),%rdi
test   %rdi,%rdi
je     11e4 <main+0x34>
lea    0xe2f(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     11e4 <main+0x34>
add    $0x8,%r12
add    $0xffffffff,%r14d
jmp    11fb <main+0x4b>
mov    (%r12),%rdx
lea    0xe14(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1040 <errx@plt>
xor    %edi,%edi
call   1080 <XOpenDisplay@plt>
mov    %rax,%r15
test   %rax,%rax
jne    121d <main+0x6d>
lea    0xe10(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1040 <errx@plt>
xor    %eax,%eax
call   1030 <XrmInitialize@plt>
mov    %r15,%rdi
call   1090 <XResourceManagerString@plt>
test   %rax,%rax
je     1271 <main+0xc1>
mov    %rax,%rdi
call   1060 <XrmGetStringDatabase@plt>
mov    %eax,%r13d
test   %r14d,%r14d
je     1265 <main+0xb5>
movslq %r14d,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
mov    (%r12,%rbp,8),%rsi
mov    %r13d,%edi
call   10c0 <xrdb_print_value@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1250 <main+0xa0>
mov    %r13d,%edi
call   10b0 <XrmDestroyDatabase@plt>
xor    %ebx,%ebx
jmp    1282 <main+0xd2>
lea    0xdc5(%rip),%rdi
call   1050 <warnx@plt>
mov    $0x1,%ebx
mov    %r15,%rdi
call   10a0 <XFlush@plt>
mov    %r15,%rdi
call   10d0 <XCloseDisplay@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [30 x i8] c"usage: %s <resource names>...\00"
@.str.2 = [28 x i8] c"could not open the display!\00"
@.str.3 = [39 x i8] c"could not get the resource properties.\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = icmp eq i8* %13, null
br i1 %14, label %21, label %15
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %15, %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %31
26: ; preds = %15
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i32 1
store i8** %28, i8*** %5
%29 = load i32, i32* %4
%30 = add nsw i32 %29, -1
store i32 %30, i32* %4
br label %31
31: ; preds = %26, %21
%32 = call i32* @XOpenDisplay(i32* null)
store i32* %32, i32** %7
%33 = icmp ne i32* %32, null
br i1 %33, label %36, label %34
34: ; preds = %31
%35 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %31
%37 = call i32 (...) @XrmInitialize()
%38 = load i32*, i32** %7
%39 = call i8* @XResourceManagerString(i32* %38)
store i8* %39, i8** %8
%40 = load i8*, i8** %8
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %63
42: ; preds = %36
%43 = load i8*, i8** %8
%44 = call i32 @XrmGetStringDatabase(i8* %43)
store i32 %44, i32* %6
store i64 0, i64* %9
br label %45
45: ; preds = %57, %42
%46 = load i64, i64* %9
%47 = load i32, i32* %4
%48 = sext i32 %47 to i64
%49 = icmp ult i64 %46, %48
br i1 %49, label %50, label %60
50: ; preds = %45
%51 = load i32, i32* %6
%52 = load i8**, i8*** %5
%53 = load i64, i64* %9
%54 = getelementptr inbounds i8*, i8** %52, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @xrdb_print_value(i32 %51, i8* %55)
br label %57
57: ; preds = %50
%58 = load i64, i64* %9
%59 = add i64 %58, 1
store i64 %59, i64* %9
br label %45
60: ; preds = %45
%61 = load i32, i32* %6
%62 = call i32 @XrmDestroyDatabase(i32 %61)
store i32 0, i32* %10
br label %65
63: ; preds = %36
%64 = call i32 @warnx(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %10
br label %65
65: ; preds = %63, %60
%66 = load i32*, i32** %7
%67 = call i32 @XFlush(i32* %66)
%68 = load i32*, i32** %7
%69 = call i32 @XCloseDisplay(i32* %68)
%70 = load i32, i32* %10
ret i32 %70
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [30 x i8] c"usage: %s <resource names>...\00"
@.str.2 = [28 x i8] c"could not open the display!\00"
@.str.3 = [39 x i8] c"could not get the resource properties.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %12
9: ; preds = %6, %2
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %10)
br label %14
12: ; preds = %6
%13 = add nsw i32 %0, -1
br label %14
14: ; preds = %12, %9
%15 = phi i8** [ %1, %9 ], [ %3, %12 ]
%16 = phi i32 [ %0, %9 ], [ %13, %12 ]
%17 = tail call i32* @XOpenDisplay(i32* null)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = tail call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %14
%22 = tail call i32 (...) @XrmInitialize()
%23 = tail call i8* @XResourceManagerString(i32* %17)
%24 = icmp eq i8* %23, null
br i1 %24, label %39, label %25
25: ; preds = %21
%26 = tail call i32 @XrmGetStringDatabase(i8* %23)
%27 = icmp eq i32 %16, 0
br i1 %27, label %37, label %28
28: ; preds = %25
%29 = sext i32 %16 to i64
br label %30
30: ; preds = %28, %30
%31 = phi i64 [ %35, %30 ], [ 0, %28 ]
%32 = getelementptr inbounds i8*, i8** %15, i64 %31
%33 = load i8*, i8** %32
%34 = tail call i32 @xrdb_print_value(i32 %26, i8* %33)
%35 = add nuw i64 %31, 1
%36 = icmp eq i64 %35, %29
br i1 %36, label %37, label %30
37: ; preds = %30, %25
%38 = tail call i32 @XrmDestroyDatabase(i32 %26)
br label %41
39: ; preds = %21
%40 = tail call i32 @warnx(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %37
%42 = phi i32 [ 0, %37 ], [ 1, %39 ]
%43 = tail call i32 @XFlush(i32* %17)
%44 = tail call i32 @XCloseDisplay(i32* %17)
ret i32 %42
}