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

/* Variables and functions */
int /*<<< orphan*/ print_display_name(int /*<<< orphan*/ *, int, int, char *);
int snprintf(char *, int, char *, char const *, int);
void print_display_id_and_name(Display *dpy, int target_id, const char *tab) {
  char name_str[64];
  int len;
  len = snprintf(name_str, sizeof(name_str), "%sDPY-%d", tab, target_id);
  if ((len < 0) || (len >= sizeof(name_str))) {
    return;
  }
  print_display_name(dpy, target_id, 4, name_str);
}


x86 assembly (clang, -O0):
<print_display_id_and_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    -0xc(%rbp),%r8d
mov    $0x40,%esi
lea    0xeb5(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0x0,-0x64(%rbp)
jl     116b <print_display_id_and_name+0x4b>
movslq -0x64(%rbp),%rax
cmp    $0x40,%rax
jb     1170 <print_display_id_and_name+0x50>
jmp    1185 <print_display_id_and_name+0x65>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
lea    -0x60(%rbp),%rcx
mov    $0x4,%edx
call   1040 <print_display_name@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_display_id_and_name>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%rcx
mov    %esi,%ebx
mov    %rdi,%r14
lea    0xeca(%rip),%rdx
mov    %rsp,%rdi
mov    $0x40,%esi
mov    %ebx,%r8d
call   1030 <snprintf@plt>
cmp    $0x3f,%eax
ja     115d <print_display_id_and_name+0x3d>
mov    %rsp,%rcx
mov    %r14,%rdi
mov    %ebx,%esi
mov    $0x4,%edx
call   1040 <print_display_name@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%sDPY-%d\00"
define void @print_display_id_and_name(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca [64 x i8]
%8 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%10 = load i8*, i8** %6
%11 = load i32, i32* %5
%12 = call i32 @snprintf(i8* %9, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %10, i32 %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp slt i32 %13, 0
br i1 %14, label %19, label %15
15: ; preds = %3
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = icmp uge i64 %17, 64
br i1 %18, label %19, label %20
19: ; preds = %15, %3
br label %25
20: ; preds = %15
%21 = load i32*, i32** %4
%22 = load i32, i32* %5
%23 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%24 = call i32 @print_display_name(i32* %21, i32 %22, i32 4, i8* %23)
br label %25
25: ; preds = %20, %19
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%sDPY-%d\00"
define void @print_display_id_and_name(i32* %0, i32 %1, i8* %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %1)
%7 = icmp ugt i32 %6, 63
br i1 %7, label %10, label %8
8: ; preds = %3
%9 = call i32 @print_display_name(i32* %0, i32 %1, i32 4, i8* %5)
br label %10
10: ; preds = %3, %8
ret void
}