#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ getit(char *, char **, char **);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ system(char *);
int dump(char *bfile) {
  FILE *fin, *fout;
  char buf[1025], xx[80], *filename, *dir;
  int locked = 0, size;
  fin = fopen(bfile, "r");
  if (fin == NULL)
    return 1;
  locked = 1;
  while (fgets(buf, 1024, fin) != NULL) {
    if (buf[0] == '>' && buf[strlen(buf) - 3] == '<' &&
        buf[strlen(buf) - 2] == '\37') {
      if (locked == 1) {
        locked = 2;
        getit(buf, &dir, &filename);
        sprintf(xx, "mkdir -p %s", dir);
        system(xx);
        sprintf(xx, "%s/%s", dir, filename);
        size = 0;
        fout = fopen(xx, "w");
      } else {
        fclose(fout);
        locked = 2;
        getit(buf, &dir, &filename);
        sprintf(xx, "mkdir -p %s", dir);
        system(xx);
        sprintf(xx, "%s/%s", dir, filename);
        size = 0;
        fout = fopen(xx, "w");
      }
      continue;
    }
    fputs(buf, fout);
    size += (int)strlen(buf);
  }
  fclose(fin);
  if (fout != NULL) {
    fclose(fout);
  }
  printf("all file dumped.\n");
}


x86 assembly (clang, -O0):
<dump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4a0,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x494(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe4c(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11d4 <dump+0x44>
movl   $0x1,-0x4(%rbp)
jmp    13e7 <dump+0x257>
movl   $0x1,-0x494(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x400,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     13be <dump+0x22e>
movsbl -0x430(%rbp),%eax
cmp    $0x3e,%eax
jne    1391 <dump+0x201>
lea    -0x430(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x3,%eax
cltq
movsbl -0x430(%rbp,%rax,1),%eax
ff
cmp    $0x3c,%eax
jne    1391 <dump+0x201>
lea    -0x430(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x2,%eax
cltq
movsbl -0x430(%rbp,%rax,1),%eax
ff
cmp    $0x1f,%eax
jne    1391 <dump+0x201>
cmpl   $0x1,-0x494(%rbp)
jne    12f3 <dump+0x163>
movl   $0x2,-0x494(%rbp)
lea    -0x430(%rbp),%rdi
lea    -0x490(%rbp),%rsi
lea    -0x488(%rbp),%rdx
call   1070 <getit@plt>
lea    -0x480(%rbp),%rdi
mov    -0x490(%rbp),%rdx
lea    0xd6b(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x480(%rbp),%rdi
call   1050 <system@plt>
lea    -0x480(%rbp),%rdi
mov    -0x490(%rbp),%rdx
mov    -0x488(%rbp),%rcx
lea    0xd48(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
movl   $0x0,-0x498(%rbp)
lea    -0x480(%rbp),%rdi
lea    0xd2f(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    138c <dump+0x1fc>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x2,-0x494(%rbp)
lea    -0x430(%rbp),%rdi
lea    -0x490(%rbp),%rsi
lea    -0x488(%rbp),%rdx
call   1070 <getit@plt>
lea    -0x480(%rbp),%rdi
mov    -0x490(%rbp),%rdx
lea    0xccd(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
lea    -0x480(%rbp),%rdi
call   1050 <system@plt>
lea    -0x480(%rbp),%rdi
mov    -0x490(%rbp),%rdx
mov    -0x488(%rbp),%rcx
lea    0xcaa(%rip),%rsi
mov    $0x0,%al
call   10b0 <sprintf@plt>
movl   $0x0,-0x498(%rbp)
lea    -0x480(%rbp),%rdi
lea    0xc91(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x20(%rbp)
jmp    11de <dump+0x4e>
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <fputs@plt>
lea    -0x430(%rbp),%rdi
call   1040 <strlen@plt>
add    -0x498(%rbp),%eax
mov    %eax,-0x498(%rbp)
jmp    11de <dump+0x4e>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
cmpq   $0x0,-0x20(%rbp)
je     13db <dump+0x24b>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xc34(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x4a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x468,%rsp
lea    0xe58(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     12e3 <dump+0x153>
mov    %rax,%r14
lea    0x60(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     12fa <dump+0x16a>
mov    $0x1,%r15b
lea    0x10(%rsp),%rbp
lea    0xe2e(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
cmpb   $0x3e,0x60(%rsp)
jne    1219 <dump+0x89>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x3c,-0x3(%rax,%rbx,1)
jne    1219 <dump+0x89>
mov    %rbx,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0x1f,-0x2(%rax,%rbx,1)
je     1243 <dump+0xb3>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1080 <fputs@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
jne    11f0 <dump+0x60>
jmp    12c2 <dump+0x132>
test   $0x1,%r15b
jne    1251 <dump+0xc1>
mov    %r13,%rdi
call   1040 <fclose@plt>
mov    %rbx,%rdi
mov    %rsp,%rsi
lea    0x8(%rsp),%rdx
call   1070 <getit@plt>
mov    (%rsp),%rdx
mov    %rbp,%rdi
lea    0xd93(%rip),%rsi
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    %rbp,%rdi
call   1060 <system@plt>
mov    (%rsp),%rdx
mov    0x8(%rsp),%rcx
mov    %rbp,%rdi
lea    0xd7d(%rip),%rsi
xor    %eax,%eax
call   10b0 <sprintf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
call   10a0 <fopen@plt>
mov    %rax,%r13
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1090 <fgets@plt>
xor    %r15d,%r15d
test   %rax,%rax
jne    11f0 <dump+0x60>
mov    %r14,%rdi
call   1040 <fclose@plt>
test   %r13,%r13
je     12d7 <dump+0x147>
mov    %r13,%rdi
call   1040 <fclose@plt>
lea    0xd38(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x468,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
call   1040 <fclose@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [12 x i8] c"mkdir -p %s\00"
@.str.2 = [6 x i8] c"%s/%s\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [18 x i8] c"all file dumped.\0A\00"
define i32 @dump(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca [1025 x i8]
%7 = alloca [80 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %10
%12 = load i8*, i8** %3
%13 = call i32* @fopen(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %13, i32** %4
%14 = load i32*, i32** %4
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %17
16: ; preds = %1
store i32 1, i32* %2
br label %98
17: ; preds = %1
store i32 1, i32* %10
br label %18
18: ; preds = %80, %79, %17
%19 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%20 = load i32*, i32** %4
%21 = call i32* @fgets(i8* %19, i32 1024, i32* %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %88
23: ; preds = %18
%24 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 62
br i1 %27, label %28, label %80
28: ; preds = %23
%29 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = sub nsw i32 %30, 3
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 60
br i1 %36, label %37, label %80
37: ; preds = %28
%38 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%39 = call i32 @strlen(i8* %38)
%40 = sub nsw i32 %39, 2
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %44, 31
br i1 %45, label %46, label %80
46: ; preds = %37
%47 = load i32, i32* %10
%48 = icmp eq i32 %47, 1
br i1 %48, label %49, label %63
49: ; preds = %46
store i32 2, i32* %10
%50 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%51 = call i32 @getit(i8* %50, i8** %9, i8** %8)
%52 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%53 = load i8*, i8** %9
%54 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %53)
%55 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%56 = call i32 @system(i8* %55)
%57 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%58 = load i8*, i8** %9
%59 = load i8*, i8** %8
%60 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %57, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %58, i8* %59)
store i32 0, i32* %11
%61 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%62 = call i32* @fopen(i8* %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %62, i32** %5
br label %79
63: ; preds = %46
%64 = load i32*, i32** %5
%65 = call i32 @fclose(i32* %64)
store i32 2, i32* %10
%66 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%67 = call i32 @getit(i8* %66, i8** %9, i8** %8)
%68 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%69 = load i8*, i8** %9
%70 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %68, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %69)
%71 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%72 = call i32 @system(i8* %71)
%73 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%74 = load i8*, i8** %9
%75 = load i8*, i8** %8
%76 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %73, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %74, i8* %75)
store i32 0, i32* %11
%77 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%78 = call i32* @fopen(i8* %77, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %78, i32** %5
br label %79
79: ; preds = %63, %49
br label %18
80: ; preds = %37, %28, %23
%81 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%82 = load i32*, i32** %5
%83 = call i32 @fputs(i8* %81, i32* %82)
%84 = getelementptr inbounds [1025 x i8], [1025 x i8]* %6, i64 0, i64 0
%85 = call i32 @strlen(i8* %84)
%86 = load i32, i32* %11
%87 = add nsw i32 %86, %85
store i32 %87, i32* %11
br label %18
88: ; preds = %18
%89 = load i32*, i32** %4
%90 = call i32 @fclose(i32* %89)
%91 = load i32*, i32** %5
%92 = icmp ne i32* %91, null
br i1 %92, label %93, label %96
93: ; preds = %88
%94 = load i32*, i32** %5
%95 = call i32 @fclose(i32* %94)
br label %96
96: ; preds = %93, %88
%97 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
br label %98
98: ; preds = %96, %16
%99 = load i32, i32* %2
ret i32 %99
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [12 x i8] c"mkdir -p %s\00"
@.str.2 = [6 x i8] c"%s/%s\00"
@.str.3 = [2 x i8] c"w\00"
@str = [17 x i8] c"all file dumped.\00"
define i32 @dump(i8* nocapture %0) {
%2 = alloca [1025 x i8]
%3 = alloca [80 x i8]
%4 = alloca i8*
%5 = alloca i8*
%6 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%8 = bitcast i8** %4 to i8*
%9 = bitcast i8** %5 to i8*
%10 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %72, label %12
12: ; preds = %1
%13 = call i32* @fgets(i8* %6, i32 1024, i32* %10)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @fclose(i32* %10)
unreachable
17: ; preds = %12, %55
%18 = phi i1 [ false, %55 ], [ true, %12 ]
%19 = phi i32* [ %56, %55 ], [ undef, %12 ]
br label %20
20: ; preds = %17, %59
%21 = load i8, i8* %6
%22 = icmp eq i8 %21, 62
br i1 %22, label %23, label %59
23: ; preds = %20
%24 = call i32 @strlen(i8* %6)
%25 = add nsw i32 %24, -3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 60
br i1 %29, label %30, label %59
30: ; preds = %23
%31 = call i32 @strlen(i8* %6)
%32 = add nsw i32 %31, -2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds [1025 x i8], [1025 x i8]* %2, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = icmp eq i8 %35, 31
br i1 %36, label %37, label %59
37: ; preds = %30
br i1 %18, label %38, label %46
38: ; preds = %37
%39 = call i32 @getit(i8* %6, i8** %5, i8** %4)
%40 = load i8*, i8** %5
%41 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %40)
%42 = call i32 @system(i8* %7)
%43 = load i8*, i8** %5
%44 = load i8*, i8** %4
%45 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %43, i8* %44)
br label %55
46: ; preds = %37
%47 = call i32 @fclose(i32* %19)
%48 = call i32 @getit(i8* %6, i8** %5, i8** %4)
%49 = load i8*, i8** %5
%50 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %49)
%51 = call i32 @system(i8* %7)
%52 = load i8*, i8** %5
%53 = load i8*, i8** %4
%54 = call i32 (i8*, i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %52, i8* %53)
br label %55
55: ; preds = %46, %38
%56 = call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%57 = call i32* @fgets(i8* %6, i32 1024, i32* %10)
%58 = icmp eq i32* %57, null
br i1 %58, label %64, label %17
59: ; preds = %30, %23, %20
%60 = call i32 @fputs(i8* %6, i32* %19)
%61 = call i32 @strlen(i8* %6)
%62 = call i32* @fgets(i8* %6, i32 1024, i32* %10)
%63 = icmp eq i32* %62, null
br i1 %63, label %64, label %20
64: ; preds = %55, %59
%65 = phi i32* [ %19, %59 ], [ %56, %55 ]
%66 = call i32 @fclose(i32* %10)
%67 = icmp eq i32* %65, null
br i1 %67, label %70, label %68
68: ; preds = %64
%69 = call i32 @fclose(i32* %65)
br label %70
70: ; preds = %68, %64
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %72
72: ; preds = %1, %70
ret i32 1
}