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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int snprintf(char *, int, char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ unlink(char *);
int remove_display_ref(char *refid) {
  char ref_file[256];
  if (snprintf(ref_file, 256, "/tmp/slurm-spank-x11.%s", refid) >= 256) {
    fprintf(stderr, "error: unable to build file reference\n");
    return 20;
  }
  if (unlink(ref_file)) {
    fprintf(stderr, "error: unable to remove file %s\n", ref_file);
    return 31;
  }
  return 0;
}


x86 assembly (clang, -O0):
<remove_display_ref>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x100,%esi
lea    0xeaa(%rip),%rdx
call   1040 <snprintf@plt>
cmp    $0x100,%eax
jl     1189 <remove_display_ref+0x59>
mov    0x2e73(%rip),%rax
mov    (%rax),%edi
lea    0xea2(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x14,-0x4(%rbp)
jmp    11d0 <remove_display_ref+0xa0>
lea    -0x110(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     11c9 <remove_display_ref+0x99>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    -0x110(%rbp),%rdx
lea    0xe89(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x1f,-0x4(%rbp)
jmp    11d0 <remove_display_ref+0xa0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_display_ref>:
sub    $0x108,%rsp
mov    %rdi,%rcx
lea    0xebf(%rip),%rdx
mov    %rsp,%rdi
mov    $0x100,%esi
call   1040 <snprintf@plt>
cmp    $0x100,%eax
jl     1179 <remove_display_ref+0x49>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xeb3(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x14,%eax
add    $0x108,%rsp
ret
mov    %rsp,%rdi
call   1030 <unlink@plt>
test   %rax,%rax
je     11ad <remove_display_ref+0x7d>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
mov    %rsp,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0x1f,%eax
add    $0x108,%rsp
ret
xor    %eax,%eax
add    $0x108,%rsp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"/tmp/slurm-spank-x11.%s\00"
@stderr = global i32 0
@.str.1 = [39 x i8] c"error: unable to build file reference\0A\00"
@.str.2 = [33 x i8] c"error: unable to remove file %s\0A\00"
define i32 @remove_display_ref(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [256 x i8]
store i8* %0, i8** %3
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%6 = load i8*, i8** %3
%7 = call i32 @snprintf(i8* %5, i32 256, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp sge i32 %7, 256
br i1 %8, label %9, label %12
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
store i32 20, i32* %2
br label %21
12: ; preds = %1
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%14 = call i64 @unlink(i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* @stderr
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %18)
store i32 31, i32* %2
br label %21
20: ; preds = %12
store i32 0, i32* %2
br label %21
21: ; preds = %20, %16, %9
%22 = load i32, i32* %2
ret i32 %22
}

LLVM IR (-O2):
@.str = [24 x i8] c"/tmp/slurm-spank-x11.%s\00"
@stderr = global i32 0
@.str.1 = [39 x i8] c"error: unable to build file reference\0A\00"
@.str.2 = [33 x i8] c"error: unable to remove file %s\0A\00"
define i32 @remove_display_ref(i8* %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 256, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = icmp sgt i32 %4, 255
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
br label %15
9: ; preds = %1
%10 = call i64 @unlink(i8* %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %9
%13 = load i32, i32* @stderr
%14 = call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %15
15: ; preds = %9, %12, %6
%16 = phi i32 [ 20, %6 ], [ 31, %12 ], [ 0, %9 ]
ret i32 %16
}