#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*/ printf(char *, char const *);
int smp_dir_create(char const *, int);
int smp_dir_remove(char const *);
int /*<<< orphan*/ smp_print_error();
int smp_test_mkdir(const char *dir_path) {
  if ((smp_dir_create(dir_path, (0666))) == (-1)) {
    smp_print_error();
    return (-1);
  }
  printf("create a dir %s\n", dir_path);
  if (smp_dir_remove(dir_path) == (-1)) {
    smp_print_error();
    return (-1);
  }
  printf("remove dir %s success\n", dir_path);
  return (0);
}


x86 assembly (clang, -O0):
<smp_test_mkdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x1b6,%esi
call   1040 <smp_dir_create@plt>
cmp    $0xffffffff,%eax
jne    1176 <smp_test_mkdir+0x36>
mov    $0x0,%al
call   1030 <smp_print_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c2 <smp_test_mkdir+0x82>
mov    -0x10(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1060 <smp_dir_remove@plt>
cmp    $0xffffffff,%eax
jne    11ab <smp_test_mkdir+0x6b>
mov    $0x0,%al
call   1030 <smp_print_error@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c2 <smp_test_mkdir+0x82>
mov    -0x10(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1050 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smp_test_mkdir>:
push   %rbx
mov    %rdi,%rbx
mov    $0x1b6,%esi
call   1040 <smp_dir_create@plt>
cmp    $0xffffffff,%eax
je     1182 <smp_test_mkdir+0x42>
lea    0xea6(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1060 <smp_dir_remove@plt>
cmp    $0xffffffff,%eax
je     1182 <smp_test_mkdir+0x42>
lea    0xe9b(%rip),%rdi
mov    %rbx,%rsi
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
call   1030 <smp_print_error@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [17 x i8] c"create a dir %s\0A\00"
@.str.1 = [23 x i8] c"remove dir %s success\0A\00"
define i32 @smp_test_mkdir(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @smp_dir_create(i8* %4, i32 438)
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %9
7: ; preds = %1
%8 = call i32 (...) @smp_print_error()
store i32 -1, i32* %2
br label %20
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i8*, i8** %3
%13 = call i32 @smp_dir_remove(i8* %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %9
%16 = call i32 (...) @smp_print_error()
store i32 -1, i32* %2
br label %20
17: ; preds = %9
%18 = load i8*, i8** %3
%19 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %18)
store i32 0, i32* %2
br label %20
20: ; preds = %17, %15, %7
%21 = load i32, i32* %2
ret i32 %21
}

LLVM IR (-O2):
@.str = [17 x i8] c"create a dir %s\0A\00"
@.str.1 = [23 x i8] c"remove dir %s success\0A\00"
define i32 @smp_test_mkdir(i8* %0) {
%2 = tail call i32 @smp_dir_create(i8* %0, i32 438)
%3 = icmp eq i32 %2, -1
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 (...) @smp_print_error()
br label %14
6: ; preds = %1
%7 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0)
%8 = tail call i32 @smp_dir_remove(i8* %0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = tail call i32 (...) @smp_print_error()
br label %14
12: ; preds = %6
%13 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %14
14: ; preds = %12, %10, %4
%15 = phi i32 [ -1, %4 ], [ -1, %10 ], [ 0, %12 ]
ret i32 %15
}