#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*/ remove(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
char *strchr(char *, char);
void delete_file(char *name, int i) {
  char folder[255];
  char *tmp = strchr(name, '/');
  while (tmp != NULL) {
    name = tmp + 1;
    tmp = strchr(name, '/');
  }
  sprintf(folder, "/tmp/%s%d.pid", name, i);
  remove(folder);
}


x86 assembly (clang, -O0):
<delete_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x118(%rbp)
cmpq   $0x0,-0x118(%rbp)
je     118e <delete_file+0x5e>
mov    -0x118(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,-0x118(%rbp)
jmp    1157 <delete_file+0x27>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xe5d(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <remove@plt>
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<delete_file>:
push   %rbp
push   %r14
push   %rbx
sub    $0x100,%rsp
mov    %esi,%r14d
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2f,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     116b <delete_file+0x3b>
mov    %rax,%rbx
add    $0x1,%rbx
mov    %rbx,%rdi
jmp    1150 <delete_file+0x20>
lea    0xe8e(%rip),%rsi
mov    %rsp,%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1050 <sprintf@plt>
mov    %rbp,%rdi
call   1030 <remove@plt>
add    $0x100,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"/tmp/%s%d.pid\00"
define void @delete_file(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca [255 x i8]
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = call i8* @strchr(i8* %7, i8 signext 47)
store i8* %8, i8** %6
br label %9
9: ; preds = %12, %2
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8* %14, i8** %3
%15 = load i8*, i8** %3
%16 = call i8* @strchr(i8* %15, i8 signext 47)
store i8* %16, i8** %6
br label %9
17: ; preds = %9
%18 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%19 = load i8*, i8** %3
%20 = load i32, i32* %4
%21 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %19, i32 %20)
%22 = getelementptr inbounds [255 x i8], [255 x i8]* %5, i64 0, i64 0
%23 = call i32 @remove(i8* %22)
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"/tmp/%s%d.pid\00"
define void @delete_file(i8* %0, i32 %1) {
%3 = alloca [255 x i8]
%4 = getelementptr inbounds [255 x i8], [255 x i8]* %3, i64 0, i64 0
%5 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 47)
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %2, %7
%8 = phi i8* [ %10, %7 ], [ %5, %2 ]
%9 = getelementptr inbounds i8, i8* %8, i64 1
%10 = tail call i8* @strchr(i8* %9, i8 signext 47)
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %7
12: ; preds = %7, %2
%13 = phi i8* [ %0, %2 ], [ %9, %7 ]
%14 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %1)
%15 = call i32 @remove(i8* %4)
ret void
}