#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*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int rmdir(char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, scalar_t__);
int executeRmdirCommand(char *arg) {
  int ret = 0;
  char name[20];
  strncpy(name, arg, strlen(arg) - 1);
  ret = rmdir(name);
  if (!ret) {
    printf("Directory %s deleted\n", name);
  } else {
    perror("Delete Error");
  }
  return ret;
}


x86 assembly (clang, -O0):
<executeRmdirCommand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
sub    $0x1,%rdx
call   1030 <strncpy@plt>
lea    -0x20(%rbp),%rdi
call   1040 <rmdir@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    11bb <executeRmdirCommand+0x6b>
lea    -0x20(%rbp),%rsi
lea    0xe4f(%rip),%rdi
call   1060 <printf@plt>
jmp    11c7 <executeRmdirCommand+0x77>
lea    0xe54(%rip),%rdi
call   1070 <perror@plt>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executeRmdirCommand>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
call   1050 <strlen@plt>
lea    -0x1(%rax),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strncpy@plt>
mov    %r14,%rdi
call   1040 <rmdir@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    1198 <executeRmdirCommand+0x48>
lea    0xe7a(%rip),%rdi
mov    %rsp,%rsi
call   1060 <printf@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe77(%rip),%rdi
call   1070 <perror@plt>
jmp    118e <executeRmdirCommand+0x3e>

LLVM IR (-O0):
@.str = [22 x i8] c"Directory %s deleted\0A\00"
@.str.1 = [13 x i8] c"Delete Error\00"
define i32 @executeRmdirCommand(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca [20 x i8]
store i8* %0, i8** %2
store i32 0, i32* %3
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%6 = load i8*, i8** %2
%7 = load i8*, i8** %2
%8 = call i64 @strlen(i8* %7)
%9 = sub nsw i64 %8, 1
%10 = call i32 @strncpy(i8* %5, i8* %6, i64 %9)
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%12 = call i32 @rmdir(i8* %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %1
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%17 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %20
18: ; preds = %1
%19 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
@.str = [22 x i8] c"Directory %s deleted\0A\00"
@.str.1 = [13 x i8] c"Delete Error\00"
define i32 @executeRmdirCommand(i8* %0) {
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = add nsw i64 %4, -1
%6 = call i32 @strncpy(i8* %3, i8* %0, i64 %5)
%7 = call i32 @rmdir(i8* %3)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %3)
br label %13
11: ; preds = %1
%12 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
ret i32 %7
}