#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*/ exit(int);
scalar_t__ file_exists(char *);
int /*<<< orphan*/ file_mkdir_p(char *);
int /*<<< orphan*/ file_read(char *);
int /*<<< orphan*/ file_size(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ puts(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr, "<filename> required\n");
    exit(1);
  }
  char *name = argv[1];
  printf("exists: %s\n", file_exists(name) ? "yes" : "no");
  printf("size: %lld\n", file_size(name));
  if (file_exists(name))
    puts(file_read(name));
  char *path = "/tmp/long/dir/sequence";
  file_mkdir_p(path);
  printf("'%s' %s\n", path, file_exists(path) ? "created" : "not created");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11bf <main+0x3f>
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
lea    0xe50(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <file_exists@plt>
mov    %rax,%rcx
lea    0xe47(%rip),%rsi
lea    0xe3c(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rsi
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <file_size@plt>
movslq %eax,%rsi
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <file_exists@plt>
cmp    $0x0,%rax
je     1238 <main+0xb8>
mov    -0x18(%rbp),%rdi
call   1090 <file_read@plt>
mov    %eax,%edi
call   1040 <puts@plt>
lea    0xdf5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <file_mkdir_p@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <file_exists@plt>
mov    -0x28(%rbp),%rsi
mov    %rax,%rcx
lea    0xde9(%rip),%rdx
lea    0xde6(%rip),%rax
cmp    $0x0,%rcx
cmovne %rax,%rdx
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jle    122f <main+0xaf>
mov    0x8(%rsi),%rbx
mov    %rbx,%rdi
call   1030 <file_exists@plt>
test   %rax,%rax
lea    0xe85(%rip),%rax
lea    0xe7a(%rip),%rsi
cmove  %rax,%rsi
lea    0xe63(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1060 <file_size@plt>
movslq %eax,%rsi
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1030 <file_exists@plt>
test   %rax,%rax
je     11ee <main+0x6e>
mov    %rbx,%rdi
call   1090 <file_read@plt>
mov    %eax,%edi
call   1040 <puts@plt>
lea    0xe3f(%rip),%rbx
mov    %rbx,%rdi
call   1080 <file_mkdir_p@plt>
mov    %rbx,%rdi
call   1030 <file_exists@plt>
test   %rax,%rax
lea    0xe45(%rip),%rax
lea    0xe42(%rip),%rdx
cmove  %rax,%rdx
lea    0xe2a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2daa(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [21 x i8] c"<filename> required\0A\00"
@.str.1 = [12 x i8] c"exists: %s\0A\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [12 x i8] c"size: %lld\0A\00"
@.str.5 = [23 x i8] c"/tmp/long/dir/sequence\00"
@.str.6 = [9 x i8] c"'%s' %s\0A\00"
@.str.7 = [8 x i8] c"created\00"
@.str.8 = [12 x i8] c"not created\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = call i64 @file_exists(i8* %18)
%20 = icmp ne i64 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %6
%25 = call i32 @file_size(i8* %24)
%26 = sext i32 %25 to i64
%27 = inttoptr i64 %26 to i8*
%28 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %6
%30 = call i64 @file_exists(i8* %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %14
%33 = load i8*, i8** %6
%34 = call i32 @file_read(i8* %33)
%35 = call i32 @puts(i32 %34)
br label %36
36: ; preds = %32, %14
store i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8** %7
%37 = load i8*, i8** %7
%38 = call i32 @file_mkdir_p(i8* %37)
%39 = load i8*, i8** %7
%40 = load i8*, i8** %7
%41 = call i64 @file_exists(i8* %40)
%42 = icmp ne i64 %41, 0
%43 = zext i1 %42 to i64
%44 = select i1 %42, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0)
%45 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* %39, i8* %44)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [21 x i8] c"<filename> required\0A\00"
@.str.1 = [12 x i8] c"exists: %s\0A\00"
@.str.2 = [4 x i8] c"yes\00"
@.str.3 = [3 x i8] c"no\00"
@.str.4 = [12 x i8] c"size: %lld\0A\00"
@.str.5 = [23 x i8] c"/tmp/long/dir/sequence\00"
@.str.6 = [9 x i8] c"'%s' %s\0A\00"
@.str.7 = [8 x i8] c"created\00"
@.str.8 = [12 x i8] c"not created\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i64 @file_exists(i8* %10)
%12 = icmp eq i64 %11, 0
%13 = select i1 %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%14 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = tail call i32 @file_size(i8* %10)
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i8*
%18 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), i8* %17)
%19 = tail call i64 @file_exists(i8* %10)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %8
%22 = tail call i32 @file_read(i8* %10)
%23 = tail call i32 @puts(i32 %22)
br label %24
24: ; preds = %21, %8
%25 = tail call i32 @file_mkdir_p(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%26 = tail call i64 @file_exists(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0)
%29 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %28)
ret i32 0
}