#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 */
scalar_t__ checkpath(int, char *, char *);
int strlen(char *);
int unlink(char *);
int do_dele(int nr, char *param) {
  char path[2048];
  if (strlen(param) == 0 || checkpath(nr, param, path))
    return 1;
  if (path[strlen(path) - 1] == '/')
    path[strlen(path) - 1] = 0;
  return unlink(path);
}


x86 assembly (clang, -O0):
<do_dele>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x0,%eax
je     1171 <do_dele+0x41>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x810(%rbp),%rdx
call   1050 <checkpath@plt>
cmp    $0x0,%rax
je     117d <do_dele+0x4d>
movl   $0x1,-0x4(%rbp)
jmp    11c7 <do_dele+0x97>
lea    -0x810(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0x810(%rbp,%rax,1),%eax
ff
cmp    $0x2f,%eax
jne    11b8 <do_dele+0x88>
lea    -0x810(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movb   $0x0,-0x810(%rbp,%rax,1)
lea    -0x810(%rbp),%rdi
call   1030 <unlink@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_dele>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x808,%rsp
mov    %rsi,%rbx
mov    %edi,%r15d
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    $0x1,%ebp
test   %eax,%eax
je     1196 <do_dele+0x66>
mov    %rsp,%r14
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1050 <checkpath@plt>
test   %rax,%rax
jne    1196 <do_dele+0x66>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x2f,-0x1(%rax,%r14,1)
jne    118c <do_dele+0x5c>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movb   $0x0,-0x1(%rax,%r14,1)
mov    %rsp,%rdi
call   1030 <unlink@plt>
mov    %eax,%ebp
mov    %ebp,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @do_dele(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [2048 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i32 @strlen(i8* %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %2
%11 = load i32, i32* %4
%12 = load i8*, i8** %5
%13 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%14 = call i64 @checkpath(i32 %11, i8* %12, i8* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %10, %2
store i32 1, i32* %3
br label %35
17: ; preds = %10
%18 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = sub nsw i32 %19, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 47
br i1 %25, label %26, label %32
26: ; preds = %17
%27 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
%29 = sub nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 %30
store i8 0, i8* %31
br label %32
32: ; preds = %26, %17
%33 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%34 = call i32 @unlink(i8* %33)
store i32 %34, i32* %3
br label %35
35: ; preds = %32, %16
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
define i32 @do_dele(i32 %0, i8* %1) {
%3 = alloca [2048 x i8]
%4 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %24, label %7
7: ; preds = %2
%8 = call i64 @checkpath(i32 %0, i8* %1, i8* %4)
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = call i32 @strlen(i8* %4)
%12 = add nsw i32 %11, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 47
br i1 %16, label %17, label %22
17: ; preds = %10
%18 = call i32 @strlen(i8* %4)
%19 = add nsw i32 %18, -1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [2048 x i8], [2048 x i8]* %3, i64 0, i64 %20
store i8 0, i8* %21
br label %22
22: ; preds = %17, %10
%23 = call i32 @unlink(i8* %4)
br label %24
24: ; preds = %2, %7, %22
%25 = phi i32 [ %23, %22 ], [ 1, %7 ], [ 1, %2 ]
ret i32 %25
}