#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*/ slog_csoup_format(char *, ...);
int /*<<< orphan*/ slog_csoup_puts(int /*<<< orphan*/, int, int /*<<< orphan*/);
int smm_fstat(char *);
scalar_t__ smm_mkpath(char *);
int do_smm_mkpath(char *path) {
  static char *plist[] = {NULL,
                          "Press/any/key to/continue/./../1234",
                          "/root/home/user/folder/file",
                          "./user/folder/file",
                          "",
                          NULL};
  int i;
  plist[0] = path;
  for (i = 0; plist[i]; i++) {
    slog_csoup_puts(0, (8 | 0), slog_csoup_format("MKDIR: %s\n", plist[i]));
    if (smm_mkpath(plist[i]) != 0) {
      slog_csoup_puts(0, (8 | 0), slog_csoup_format("Boo!\n"));
    } else if (smm_fstat(plist[i]) != 1) {
      slog_csoup_puts(0, (8 | 0), slog_csoup_format("FAILED!\n"));
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<do_smm_mkpath>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,0x2ef9(%rip)
movl   $0x0,-0xc(%rbp)
movslq -0xc(%rbp),%rcx
lea    0x2ee7(%rip),%rax
cmpq   $0x0,(%rax,%rcx,8)
je     122f <do_smm_mkpath+0xef>
movslq -0xc(%rbp),%rcx
lea    0x2ed1(%rip),%rax
mov    (%rax,%rcx,8),%rsi
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1060 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1050 <slog_csoup_puts@plt>
movslq -0xc(%rbp),%rcx
lea    0x2ea6(%rip),%rax
mov    (%rax,%rcx,8),%rdi
call   1040 <smm_mkpath@plt>
cmp    $0x0,%rax
je     11de <do_smm_mkpath+0x9e>
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1060 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1050 <slog_csoup_puts@plt>
jmp    121c <do_smm_mkpath+0xdc>
movslq -0xc(%rbp),%rcx
lea    0x2e67(%rip),%rax
mov    (%rax,%rcx,8),%rdi
call   1030 <smm_fstat@plt>
cmp    $0x1,%eax
je     1217 <do_smm_mkpath+0xd7>
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1060 <slog_csoup_format@plt>
mov    %eax,%edx
xor    %edi,%edi
mov    $0x8,%esi
call   1050 <slog_csoup_puts@plt>
jmp    121c <do_smm_mkpath+0xdc>
jmp    1221 <do_smm_mkpath+0xe1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115e <do_smm_mkpath+0x1e>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_smm_mkpath>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,0x2f01(%rip)
test   %rdi,%rdi
je     11dc <do_smm_mkpath+0x9c>
mov    %rdi,%rsi
lea    0x2eee(%rip),%rbx
lea    0xeea(%rip),%r14
lea    0xeee(%rip),%r15
lea    0xeed(%rip),%r12
jmp    11a2 <do_smm_mkpath+0x62>
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <slog_csoup_format@plt>
xor    %edi,%edi
mov    $0x8,%esi
mov    %eax,%edx
call   1050 <slog_csoup_puts@plt>
mov    0x8(%rbx),%rsi
add    $0x8,%rbx
test   %rsi,%rsi
je     11dc <do_smm_mkpath+0x9c>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <slog_csoup_format@plt>
xor    %edi,%edi
mov    $0x8,%esi
mov    %eax,%edx
call   1050 <slog_csoup_puts@plt>
mov    (%rbx),%rdi
call   1040 <smm_mkpath@plt>
mov    %r15,%rdi
test   %rax,%rax
jne    1180 <do_smm_mkpath+0x40>
mov    (%rbx),%rdi
call   1030 <smm_fstat@plt>
mov    %r12,%rdi
cmp    $0x1,%eax
jne    1180 <do_smm_mkpath+0x40>
jmp    1195 <do_smm_mkpath+0x55>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@do_smm_mkpath.plist = internal global [6 x i8*] [i8* null, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i32 0, i32 0), i8* null]
@.str = [36 x i8] c"Press/any/key to/continue/./../1234\00"
@.str.1 = [28 x i8] c"/root/home/user/folder/file\00"
@.str.2 = [19 x i8] c"./user/folder/file\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [11 x i8] c"MKDIR: %s\0A\00"
@.str.5 = [6 x i8] c"Boo!\0A\00"
@.str.6 = [9 x i8] c"FAILED!\0A\00"
define i32 @do_smm_mkpath(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
store i8* %4, i8** getelementptr inbounds ([6 x i8*], [6 x i8*]* @do_smm_mkpath.plist, i64 0, i64 0)
store i32 0, i32* %3
br label %5
5: ; preds = %39, %1
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds [6 x i8*], [6 x i8*]* @do_smm_mkpath.plist, i64 0, i64 %7
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %42
11: ; preds = %5
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [6 x i8*], [6 x i8*]* @do_smm_mkpath.plist, i64 0, i64 %13
%15 = load i8*, i8** %14
%16 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%17 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %16)
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [6 x i8*], [6 x i8*]* @do_smm_mkpath.plist, i64 0, i64 %19
%21 = load i8*, i8** %20
%22 = call i64 @smm_mkpath(i8* %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %11
%25 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %25)
br label %38
27: ; preds = %11
%28 = load i32, i32* %3
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [6 x i8*], [6 x i8*]* @do_smm_mkpath.plist, i64 0, i64 %29
%31 = load i8*, i8** %30
%32 = call i32 @smm_fstat(i8* %31)
%33 = icmp ne i32 %32, 1
br i1 %33, label %34, label %37
34: ; preds = %27
%35 = call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%36 = call i32 @slog_csoup_puts(i32 0, i32 8, i32 %35)
br label %37
37: ; preds = %34, %27
br label %38
38: ; preds = %37, %24
br label %39
39: ; preds = %38
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %5
42: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@do_smm_mkpath.plist = internal unnamed_addr global [6 x i8*] [i8* null, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i32 0, i32 0), i8* null]
@.str = [36 x i8] c"Press/any/key to/continue/./../1234\00"
@.str.1 = [28 x i8] c"/root/home/user/folder/file\00"
@.str.2 = [19 x i8] c"./user/folder/file\00"
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [11 x i8] c"MKDIR: %s\0A\00"
@.str.5 = [6 x i8] c"Boo!\0A\00"
@.str.6 = [9 x i8] c"FAILED!\0A\00"
define i32 @do_smm_mkpath(i8* %0) {
store i8* %0, i8** getelementptr inbounds ([6 x i8*], [6 x i8*]* @do_smm_mkpath.plist, i64 0, i64 0)
%2 = icmp eq i8* %0, null
br i1 %2, label %25, label %3
3: ; preds = %1, %20
%4 = phi i64 [ %21, %20 ], [ 0, %1 ]
%5 = phi i8* [ %23, %20 ], [ %0, %1 ]
%6 = phi i8** [ %22, %20 ], [ getelementptr inbounds ([6 x i8*], [6 x i8*]* @do_smm_mkpath.plist, i64 0, i64 0), %1 ]
%7 = tail call i32 (i8*, ...) @slog_csoup_format(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%8 = tail call i32 @slog_csoup_puts(i32 0, i32 8, i32 %7)
%9 = load i8*, i8** %6
%10 = tail call i64 @smm_mkpath(i8* %9)
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = tail call i32 @smm_fstat(i8* %13)
%15 = icmp eq i32 %14, 1
br i1 %15, label %20, label %16
16: ; preds = %12, %3
%17 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %3 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), %12 ]
%18 = tail call i32 (i8*, ...) @slog_csoup_format(i8* %17)
%19 = tail call i32 @slog_csoup_puts(i32 0, i32 8, i32 %18)
br label %20
20: ; preds = %16, %12
%21 = add nuw i64 %4, 1
%22 = getelementptr inbounds [6 x i8*], [6 x i8*]* @do_smm_mkpath.plist, i64 0, i64 %21
%23 = load i8*, i8** %22
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %3
25: ; preds = %20, %1
ret i32 0
}