#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*/ name;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int get_display_name(char *, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
bool show_display_name(void) {
  char name[32];
  int res = get_display_name(name, sizeof(name));
  if (res < 0) {
    fprintf(stderr, "ERROR: Cannot determine display name\n");
    return false;
  }
  printf("Display name: %s\n", name);
  return true;
}


x86 assembly (clang, -O0):
<show_display_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x30(%rbp),%rdi
mov    $0x20,%esi
call   1030 <get_display_name@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jge    1174 <show_display_name+0x44>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
lea    0xe9d(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    118b <show_display_name+0x5b>
lea    -0x30(%rbp),%rsi
lea    0xea7(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_display_name>:
sub    $0x28,%rsp
mov    %rsp,%rdi
mov    $0x20,%esi
call   1030 <get_display_name@plt>
test   %eax,%eax
js     115e <show_display_name+0x2e>
lea    0xeda(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x28,%rsp
ret
mov    0x2e7b(%rip),%rax
mov    (%rax),%edi
lea    0xe92(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [38 x i8] c"ERROR: Cannot determine display name\0A\00"
@.str.1 = [18 x i8] c"Display name: %s\0A\00"
define i32 @show_display_name() {
%1 = alloca i32
%2 = alloca [32 x i8]
%3 = alloca i32
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%5 = call i32 @get_display_name(i8* %4, i32 32)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %14
11: ; preds = %0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i32 1, i32* %1
br label %14
14: ; preds = %11, %8
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [38 x i8] c"ERROR: Cannot determine display name\0A\00"
@.str.1 = [18 x i8] c"Display name: %s\0A\00"
define i32 @show_display_name() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%3 = call i32 @get_display_name(i8* %2, i32 32)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %10
8: ; preds = %0
%9 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %10
10: ; preds = %8, %5
%11 = phi i32 [ 0, %5 ], [ 1, %8 ]
ret i32 %11
}