#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 */
struct stat {
  int /*<<< orphan*/ st_mode;
  int /*<<< orphan*/ member_0;
};

/* Variables and functions */
int /*<<< orphan*/ mkdir(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *);
int stat(char const *, struct stat *);
void RecoverDir(const char *name, struct stat *inode) {
  struct stat st = {0};
  if (stat(name, &st) == -1) {
    mkdir(name, inode->st_mode);
    printf("recovered folder %s\n", name);
  }
}


x86 assembly (clang, -O0):
<RecoverDir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <stat@plt>
cmp    $0xffffffff,%eax
jne    1195 <RecoverDir+0x55>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
call   1030 <mkdir@plt>
mov    -0x8(%rbp),%rsi
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RecoverDir>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,(%rsp)
mov    %rsp,%rsi
call   1050 <stat@plt>
cmp    $0xffffffff,%eax
je     1157 <RecoverDir+0x27>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    (%r14),%esi
mov    %rbx,%rdi
call   1030 <mkdir@plt>
lea    0xe97(%rip),%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
@.str = [21 x i8] c"recovered folder %s\0A\00"
define void @RecoverDir(i8* %0, %struct.stat* %1) {
%3 = alloca i8*
%4 = alloca %struct.stat*
%5 = alloca %struct.stat
store i8* %0, i8** %3
store %struct.stat* %1, %struct.stat** %4
%6 = bitcast %struct.stat* %5 to i8*
%7 = load i8*, i8** %3
%8 = call i32 @stat(i8* %7, %struct.stat* %5)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i8*, i8** %3
%12 = load %struct.stat*, %struct.stat** %4
%13 = getelementptr inbounds %struct.stat, %struct.stat* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = call i32 @mkdir(i8* %11, i32 %14)
%16 = load i8*, i8** %3
%17 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %18
18: ; preds = %10, %2
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
@.str = [21 x i8] c"recovered folder %s\0A\00"
define void @RecoverDir(i8* %0, %struct.stat* nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to %struct.stat*
%5 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%6 = call i32 @stat(i8* %0, %struct.stat* %4)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%10 = load i32, i32* %9
%11 = tail call i32 @mkdir(i8* %0, i32 %10)
%12 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %13
13: ; preds = %8, %2
ret void
}