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

/* Variables and functions */
int /*<<< orphan*/ XFree(char *);
int /*<<< orphan*/ XNVCTRLQueryTargetStringAttribute(int /*<<< orphan*/ *, int,
                                                     int, int /*<<< orphan*/,
                                                     int, char **);
int /*<<< orphan*/ printf(char *, char *, ...);
void print_display_name(Display *dpy, int target_id, int attr, char *name) {
  Bool ret;
  char *str;
  ret = XNVCTRLQueryTargetStringAttribute(dpy, 8, target_id, 0, attr, &str);
  if (!ret) {
    printf("    %18s : N/A\n", name);
    return;
  }
  printf("    %18s : %s\n", name, str);
  XFree(str);
}


x86 assembly (clang, -O0):
<print_display_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%r8d
mov    $0x8,%esi
xor    %ecx,%ecx
lea    -0x28(%rbp),%r9
call   1050 <XNVCTRLQueryTargetStringAttribute@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1185 <print_display_name+0x55>
mov    -0x18(%rbp),%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11a4 <print_display_name+0x74>
mov    -0x18(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1040 <XFree@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_display_name>:
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%rbx
mov    %edx,%r8d
mov    %esi,%edx
lea    0x8(%rsp),%r9
mov    $0x8,%esi
xor    %ecx,%ecx
call   1050 <XNVCTRLQueryTargetStringAttribute@plt>
test   %eax,%eax
je     1174 <print_display_name+0x44>
mov    0x8(%rsp),%rdx
lea    0xeb2(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rsp),%rdi
call   1040 <XFree@plt>
jmp    1185 <print_display_name+0x55>
lea    0xe85(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c" %18s : N/A\0A\00"
@.str.1 = [15 x i8] c" %18s : %s\0A\00"
define void @print_display_name(i32* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%11 = load i32*, i32** %5
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = call i32 @XNVCTRLQueryTargetStringAttribute(i32* %11, i32 8, i32 %12, i32 0, i32 %13, i8** %10)
store i32 %14, i32* %9
%15 = load i32, i32* %9
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %4
%18 = load i8*, i8** %8
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %26
20: ; preds = %4
%21 = load i8*, i8** %8
%22 = load i8*, i8** %10
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %22)
%24 = load i8*, i8** %10
%25 = call i32 @XFree(i8* %24)
br label %26
26: ; preds = %20, %17
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c" %18s : N/A\0A\00"
@.str.1 = [15 x i8] c" %18s : %s\0A\00"
define void @print_display_name(i32* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = call i32 @XNVCTRLQueryTargetStringAttribute(i32* %0, i32 8, i32 %1, i32 0, i32 %2, i8** %5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %16
11: ; preds = %4
%12 = load i8*, i8** %5
%13 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %12)
%14 = load i8*, i8** %5
%15 = call i32 @XFree(i8* %14)
br label %16
16: ; preds = %11, %9
ret void
}