#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 */
struct TYPE_3__ {
  int /*<<< orphan*/ *addr;
};
typedef TYPE_1__ XrmValue;
typedef int /*<<< orphan*/ XrmDatabase;

/* Variables and functions */
int /*<<< orphan*/ XrmGetResource(int /*<<< orphan*/, char *, char *, char **,
                                  TYPE_1__ *);
int /*<<< orphan*/ errx(int, char *, char *);
int /*<<< orphan*/ puts(int /*<<< orphan*/ *);
void xrdb_print_value(XrmDatabase db, char *resource) {
  char *type;
  XrmValue xvalue;
  XrmGetResource(db, resource, "*", &type, &xvalue);
  if (xvalue.addr != NULL) {
    puts(xvalue.addr);
  } else {
    errx(1, "failed to get xrdb value '%s'.", resource);
  }
}


x86 assembly (clang, -O0):
<xrdb_print_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xeb3(%rip),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%r8
call   1040 <XrmGetResource@plt>
cmpq   $0x0,-0x20(%rbp)
je     1173 <xrdb_print_value+0x43>
mov    -0x20(%rbp),%rdi
call   1030 <puts@plt>
jmp    1188 <xrdb_print_value+0x58>
mov    -0x10(%rbp),%rdx
mov    $0x1,%edi
lea    0xe7f(%rip),%rsi
call   1050 <errx@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xrdb_print_value>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xec1(%rip),%rdx
lea    0x8(%rsp),%rcx
mov    %rsp,%r8
call   1040 <XrmGetResource@plt>
mov    (%rsp),%rdi
test   %rdi,%rdi
je     115c <xrdb_print_value+0x2c>
call   1030 <puts@plt>
jmp    1170 <xrdb_print_value+0x40>
lea    0xe9f(%rip),%rsi
mov    $0x1,%edi
mov    %rbx,%rdx
call   1050 <errx@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32* }
@.str = [2 x i8] c"*\00"
@.str.1 = [31 x i8] c"failed to get xrdb value '%s'.\00"
define void @xrdb_print_value(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.TYPE_3__
store i32 %0, i32* %3
store i8* %1, i8** %4
%7 = load i32, i32* %3
%8 = load i8*, i8** %4
%9 = call i32 @XrmGetResource(i32 %7, i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %5, %struct.TYPE_3__* %6)
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 0
%11 = load i32*, i32** %10
%12 = icmp ne i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 0
%15 = load i32*, i32** %14
%16 = call i32 @puts(i32* %15)
br label %20
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = call i32 @errx(i32 1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %17, %13
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32* }
@.str = [2 x i8] c"*\00"
@.str.1 = [31 x i8] c"failed to get xrdb value '%s'.\00"
define void @xrdb_print_value(i32 %0, i8* %1) {
%3 = alloca i8*
%4 = alloca %struct.TYPE_3__
%5 = bitcast i8** %3 to i8*
%6 = bitcast %struct.TYPE_3__* %4 to i8*
%7 = call i32 @XrmGetResource(i32 %0, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %3, %struct.TYPE_3__* %4)
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %4, i64 0, i32 0
%9 = load i32*, i32** %8
%10 = icmp eq i32* %9, null
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 @puts(i32* %9)
br label %15
13: ; preds = %2
%14 = call i32 @errx(i32 1, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %15
15: ; preds = %13, %11
ret void
}