#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__ create_trash_dir(char const *);
scalar_t__ is_path_absolute(char const *);
int /*<<< orphan*/ is_rooted_trash_dir(char const *);
int /*<<< orphan*/ show_error_msgf(char *, char *, char const *);
int validate_spec(const char spec[]) {
  if (is_path_absolute(spec)) {
    if (create_trash_dir(spec) != 0) {
      return 0;
    }
  } else if (!is_rooted_trash_dir(spec)) {
    show_error_msgf("Error Setting Trash Directory",
                    "The path specification is of incorrect format: %s", spec);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<validate_spec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <is_path_absolute@plt>
cmp    $0x0,%rax
je     1183 <validate_spec+0x43>
mov    -0x10(%rbp),%rdi
call   1030 <create_trash_dir@plt>
cmp    $0x0,%rax
je     117e <validate_spec+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    11c4 <validate_spec+0x84>
jmp    11bd <validate_spec+0x7d>
mov    -0x10(%rbp),%rdi
call   1050 <is_rooted_trash_dir@plt>
cmp    $0x0,%eax
jne    11b8 <validate_spec+0x78>
mov    -0x10(%rbp),%rdx
lea    0xe60(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1040 <show_error_msgf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c4 <validate_spec+0x84>
jmp    11bd <validate_spec+0x7d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_spec>:
push   %rbx
mov    %rdi,%rbx
call   1060 <is_path_absolute@plt>
test   %rax,%rax
je     1162 <validate_spec+0x22>
mov    %rbx,%rdi
call   1030 <create_trash_dir@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     116e <validate_spec+0x2e>
pop    %rbx
ret
mov    %rbx,%rdi
call   1050 <is_rooted_trash_dir@plt>
test   %eax,%eax
je     1175 <validate_spec+0x35>
mov    $0x1,%eax
pop    %rbx
ret
lea    0xe84(%rip),%rdi
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdx
call   1040 <show_error_msgf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Error Setting Trash Directory\00"
@.str.1 = [50 x i8] c"The path specification is of incorrect format: %s\00"
define i32 @validate_spec(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @is_path_absolute(i8* %4)
%6 = icmp ne i64 %5, 0
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @create_trash_dir(i8* %8)
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 0, i32* %2
br label %22
12: ; preds = %7
br label %21
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @is_rooted_trash_dir(i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = call i32 @show_error_msgf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %18)
store i32 0, i32* %2
br label %22
20: ; preds = %13
br label %21
21: ; preds = %20, %12
store i32 1, i32* %2
br label %22
22: ; preds = %21, %17, %11
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [30 x i8] c"Error Setting Trash Directory\00"
@.str.1 = [50 x i8] c"The path specification is of incorrect format: %s\00"
define i32 @validate_spec(i8* %0) {
%2 = tail call i64 @is_path_absolute(i8* %0)
%3 = icmp eq i64 %2, 0
br i1 %3, label %7, label %4
4: ; preds = %1
%5 = tail call i64 @create_trash_dir(i8* %0)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %13
7: ; preds = %1
%8 = tail call i32 @is_rooted_trash_dir(i8* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @show_error_msgf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %13
12: ; preds = %7, %4
br label %13
13: ; preds = %4, %12, %10
%14 = phi i32 [ 1, %12 ], [ 0, %10 ], [ 0, %4 ]
ret i32 %14
}