#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__ chdir(char *);
int /*<<< orphan*/ perror(char *);
scalar_t__ rmdir(char *);
void removeDirectory(char *dir_name) {
  if (chdir(dir_name)) {
    perror("error occurred while chdir()");
    return;
  }
  chdir("..");
  if (rmdir(dir_name)) {
    perror("error occurred while rmdir()");
    return;
  }
}


x86 assembly (clang, -O0):
<removeDirectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <chdir@plt>
cmp    $0x0,%rax
je     1160 <removeDirectory+0x30>
lea    0xeaa(%rip),%rdi
call   1050 <perror@plt>
jmp    118b <removeDirectory+0x5b>
lea    0xeb6(%rip),%rdi
call   1040 <chdir@plt>
mov    -0x8(%rbp),%rdi
call   1030 <rmdir@plt>
cmp    $0x0,%rax
je     118b <removeDirectory+0x5b>
lea    0xe9a(%rip),%rdi
call   1050 <perror@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeDirectory>:
push   %rbx
mov    %rdi,%rbx
call   1040 <chdir@plt>
test   %rax,%rax
jne    1159 <removeDirectory+0x29>
lea    0xed8(%rip),%rdi
call   1040 <chdir@plt>
mov    %rbx,%rdi
call   1030 <rmdir@plt>
test   %rax,%rax
jne    1166 <removeDirectory+0x36>
pop    %rbx
ret
lea    0xea0(%rip),%rdi
pop    %rbx
jmp    1050 <perror@plt>
lea    0xeb3(%rip),%rdi
pop    %rbx
jmp    1050 <perror@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"error occurred while chdir()\00"
@.str.1 = [3 x i8] c"..\00"
@.str.2 = [29 x i8] c"error occurred while rmdir()\00"
define void @removeDirectory(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i8*, i8** %2
%4 = call i64 @chdir(i8* %3)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %15
8: ; preds = %1
%9 = call i64 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = load i8*, i8** %2
%11 = call i64 @rmdir(i8* %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %8
%14 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %6, %13, %8
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"error occurred while chdir()\00"
@.str.1 = [3 x i8] c"..\00"
@.str.2 = [29 x i8] c"error occurred while rmdir()\00"
define void @removeDirectory(i8* %0) {
%2 = tail call i64 @chdir(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %1
%5 = tail call i64 @chdir(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i64 @rmdir(i8* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %4, %1
%9 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), %4 ]
%10 = tail call i32 @perror(i8* %9)
br label %11
11: ; preds = %8, %4
ret void
}