#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*/ g_file_delete(char *);
scalar_t__ g_file_exist(char *);
int /*<<< orphan*/ g_snprintf(char *, int, char *, int);
int chansrv_cleanup(int pid) {
  char text[256];
  g_snprintf(text, 255, "/tmp/.xrdp/xrdp_chansrv_%8.8x_main_term", pid);
  if (g_file_exist(text)) {
    g_file_delete(text);
  }
  g_snprintf(text, 255, "/tmp/.xrdp/xrdp_chansrv_%8.8x_thread_done", pid);
  if (g_file_exist(text)) {
    g_file_delete(text);
  }
  return 0;
}


x86 assembly (clang, -O0):
<chansrv_cleanup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0xff,%esi
lea    0xeac(%rip),%rdx
call   1050 <g_snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <g_file_exist@plt>
cmp    $0x0,%rax
je     117b <chansrv_cleanup+0x4b>
lea    -0x110(%rbp),%rdi
call   1040 <g_file_delete@plt>
lea    -0x110(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0xff,%esi
lea    0xe97(%rip),%rdx
call   1050 <g_snprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <g_file_exist@plt>
cmp    $0x0,%rax
je     11b8 <chansrv_cleanup+0x88>
lea    -0x110(%rbp),%rdi
call   1040 <g_file_delete@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chansrv_cleanup>:
push   %r14
push   %rbx
sub    $0x108,%rsp
mov    %edi,%ebx
lea    0xebd(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xff,%esi
mov    %ebx,%ecx
call   1050 <g_snprintf@plt>
mov    %r14,%rdi
call   1030 <g_file_exist@plt>
test   %rax,%rax
je     116a <chansrv_cleanup+0x3a>
mov    %rsp,%rdi
call   1040 <g_file_delete@plt>
lea    0xeb7(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0xff,%esi
mov    %ebx,%ecx
call   1050 <g_snprintf@plt>
mov    %r14,%rdi
call   1030 <g_file_exist@plt>
test   %rax,%rax
je     1198 <chansrv_cleanup+0x68>
mov    %rsp,%rdi
call   1040 <g_file_delete@plt>
xor    %eax,%eax
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [40 x i8] c"/tmp/.xrdp/xrdp_chansrv_%8.8x_main_term\00"
@.str.1 = [42 x i8] c"/tmp/.xrdp/xrdp_chansrv_%8.8x_thread_done\00"
define i32 @chansrv_cleanup(i32 %0) {
%2 = alloca i32
%3 = alloca [256 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* %2
%6 = call i32 @g_snprintf(i8* %4, i32 255, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%8 = call i64 @g_file_exist(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %1
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%12 = call i32 @g_file_delete(i8* %11)
br label %13
13: ; preds = %10, %1
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%15 = load i32, i32* %2
%16 = call i32 @g_snprintf(i8* %14, i32 255, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%18 = call i64 @g_file_exist(i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%22 = call i32 @g_file_delete(i8* %21)
br label %23
23: ; preds = %20, %13
ret i32 0
}

LLVM IR (-O2):
@.str = [40 x i8] c"/tmp/.xrdp/xrdp_chansrv_%8.8x_main_term\00"
@.str.1 = [42 x i8] c"/tmp/.xrdp/xrdp_chansrv_%8.8x_thread_done\00"
define i32 @chansrv_cleanup(i32 %0) {
%2 = alloca [256 x i8]
%3 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%4 = call i32 @g_snprintf(i8* %3, i32 255, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = call i64 @g_file_exist(i8* %3)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @g_file_delete(i8* %3)
br label %9
9: ; preds = %7, %1
%10 = call i32 @g_snprintf(i8* %3, i32 255, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %0)
%11 = call i64 @g_file_exist(i8* %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = call i32 @g_file_delete(i8* %3)
br label %15
15: ; preds = %13, %9
ret i32 0
}