#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ mkdir(char const *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
scalar_t__ stat(char const *, struct stat *);
void MakeDir(const char *mydir) {
  struct stat st;
  if (stat(mydir, &st) != 0) {
    mkdir(mydir, 0777);
  } else {
    printf("the output directory %s exists, force overwriting? y/n ", mydir);
    char input;
    scanf("%c", &input);
    if (input == 'n') {
      printf("program terminated\n");
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<MakeDir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
je     1186 <MakeDir+0x36>
mov    -0x8(%rbp),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
jmp    11d2 <MakeDir+0x82>
mov    -0x8(%rbp),%rsi
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe99(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1060 <scanf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x6e,%eax
jne    11cd <MakeDir+0x7d>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
jmp    11d2 <MakeDir+0x82>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MakeDir>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0x8(%rsp),%rsi
call   1060 <stat@plt>
test   %rax,%rax
je     1186 <MakeDir+0x26>
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
jmp    11af <MakeDir+0x4f>
lea    0xe73(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe9a(%rip),%rdi
lea    0x7(%rsp),%rsi
call   1070 <scanf@plt>
cmpb   $0x6e,0x7(%rsp)
je     11b5 <MakeDir+0x55>
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe7f(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i32 }
@.str = [56 x i8] c"the output directory %s exists, force overwriting? y/n \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [20 x i8] c"program terminated\0A\00"
define void @MakeDir(i8* %0) {
%2 = alloca i8*
%3 = alloca %struct.stat
%4 = alloca i8
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i64 @stat(i8* %5, %struct.stat* %3)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i8*, i8** %2
%10 = call i32 @mkdir(i8* %9, i32 511)
br label %22
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 110
br i1 %17, label %18, label %21
18: ; preds = %11
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %11
br label %22
22: ; preds = %21, %8
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@.str = [56 x i8] c"the output directory %s exists, force overwriting? y/n \00"
@.str.1 = [3 x i8] c"%c\00"
@str = [19 x i8] c"program terminated\00"
define void @MakeDir(i8* %0) {
%2 = alloca %struct.stat
%3 = alloca i8
%4 = bitcast %struct.stat* %2 to i8*
%5 = call i64 @stat(i8* %0, %struct.stat* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @mkdir(i8* %0, i32 511)
br label %18
9: ; preds = %1
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %0)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%12 = load i8, i8* %3
%13 = icmp eq i8 %12, 110
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %9
br label %18
18: ; preds = %17, %7
ret void
}