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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ mkdir(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, ...);
int main(void) {
  int i, j, k, l;
  char name[] = "dir_%d/dir_%d/%d%d.txt";
  for (i = 0; i < 10; ++i) {
    snprintf(name, sizeof(name), "dir_%d", i);
    mkdir(name);
    for (j = 0; j < 40; ++j) {
      snprintf(name, sizeof(name), "dir_%d/dir_%d", i, j);
      mkdir(name);
      for (k = 0; k < 10; ++k) {
        for (l = 0; l < 10; ++l) {
          FILE *fp;
          snprintf(name, sizeof(name), "dir_%d/dir_%d/%d%d.txt", i, j, k, l);
          fp = fopen(name, "w");
          if (fp) {
            fprintf(fp, "dummy file.\n");
            fclose(fp);
          }
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe9a(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe97(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xe95(%rip),%eax
mov    %eax,-0x20(%rbp)
mov    0xe8f(%rip),%ax
mov    %ax,-0x1c(%rbp)
mov    0xe87(%rip),%al
mov    %al,-0x1a(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    12cc <main+0x17c>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    $0x17,%esi
lea    0xe68(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <mkdir@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x28,-0xc(%rbp)
jge    12b9 <main+0x169>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    $0x17,%esi
lea    0xe29(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <mkdir@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0xa,-0x10(%rbp)
jge    12a6 <main+0x156>
movl   $0x0,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jge    1293 <main+0x143>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    -0x10(%rbp),%r9d
mov    -0x14(%rbp),%eax
mov    $0x17,%esi
lea    0xde7(%rip),%rdx
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <snprintf@plt>
lea    -0x30(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
je     1280 <main+0x130>
mov    -0x38(%rbp),%rdi
lea    0xdcc(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1040 <fclose@plt>
jmp    1285 <main+0x135>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1216 <main+0xc6>
jmp    1298 <main+0x148>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1205 <main+0xb5>
jmp    12ab <main+0x15b>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cd <main+0x7d>
jmp    12be <main+0x16e>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1199 <main+0x49>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movaps 0xebb(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x7478742e642564,%rax
mov    %rax,0x1f(%rsp)
lea    0x10(%rsp),%rbx
xor    %r14d,%r14d
jmp    119e <main+0x4e>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14d
cmp    $0xa,%r14d
je     1287 <main+0x137>
mov    %rbx,%rdi
mov    $0x17,%esi
lea    0xe5a(%rip),%rdx
mov    %r14d,%ecx
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <mkdir@plt>
xor    %r15d,%r15d
jmp    11da <main+0x8a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%r15d
cmp    $0x28,%r15d
je     1190 <main+0x40>
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    $0x17,%esi
lea    0xe15(%rip),%rdx
mov    %r14d,%ecx
mov    %r15d,%r8d
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <mkdir@plt>
jmp    1218 <main+0xc8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%ebp
cmp    $0xa,%ebp
je     11d0 <main+0x80>
xor    %r13d,%r13d
jmp    122a <main+0xda>
nopl   (%rax)
add    $0x1,%r13d
cmp    $0xa,%r13d
je     1210 <main+0xc0>
mov    %r13d,(%rsp)
mov    %rbx,%rdi
mov    $0x17,%esi
lea    0xde3(%rip),%rdx
mov    %r14d,%ecx
mov    %r15d,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rbx,%rdi
lea    0xdb7(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1220 <main+0xd0>
mov    %rax,%r12
mov    $0xc,%esi
mov    $0x1,%edx
lea    0xd9b(%rip),%rdi
mov    %rax,%rcx
call   1070 <fwrite@plt>
mov    %r12,%rdi
call   1040 <fclose@plt>
jmp    1220 <main+0xd0>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.name = [23 x i8] c"dir_%d/dir_%d/%d%d.txt\00"
@.str = [7 x i8] c"dir_%d\00"
@.str.1 = [14 x i8] c"dir_%d/dir_%d\00"
@.str.2 = [23 x i8] c"dir_%d/dir_%d/%d%d.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [13 x i8] c"dummy file.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [23 x i8]
%7 = alloca i32*
store i32 0, i32* %1
%8 = bitcast [23 x i8]* %6 to i8*
store i32 0, i32* %2
br label %9
9: ; preds = %64, %0
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %67
12: ; preds = %9
%13 = getelementptr inbounds [23 x i8], [23 x i8]* %6, i64 0, i64 0
%14 = load i32, i32* %2
%15 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %13, i32 23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [23 x i8], [23 x i8]* %6, i64 0, i64 0
%17 = call i32 @mkdir(i8* %16)
store i32 0, i32* %3
br label %18
18: ; preds = %60, %12
%19 = load i32, i32* %3
%20 = icmp slt i32 %19, 40
br i1 %20, label %21, label %63
21: ; preds = %18
%22 = getelementptr inbounds [23 x i8], [23 x i8]* %6, i64 0, i64 0
%23 = load i32, i32* %2
%24 = load i32, i32* %3
%25 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %22, i32 23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %23, i32 %24)
%26 = getelementptr inbounds [23 x i8], [23 x i8]* %6, i64 0, i64 0
%27 = call i32 @mkdir(i8* %26)
store i32 0, i32* %4
br label %28
28: ; preds = %56, %21
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 10
br i1 %30, label %31, label %59
31: ; preds = %28
store i32 0, i32* %5
br label %32
32: ; preds = %52, %31
%33 = load i32, i32* %5
%34 = icmp slt i32 %33, 10
br i1 %34, label %35, label %55
35: ; preds = %32
%36 = getelementptr inbounds [23 x i8], [23 x i8]* %6, i64 0, i64 0
%37 = load i32, i32* %2
%38 = load i32, i32* %3
%39 = load i32, i32* %4
%40 = load i32, i32* %5
%41 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %36, i32 23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 %38, i32 %39, i32 %40)
%42 = getelementptr inbounds [23 x i8], [23 x i8]* %6, i64 0, i64 0
%43 = call i32* @fopen(i8* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %43, i32** %7
%44 = load i32*, i32** %7
%45 = icmp ne i32* %44, null
br i1 %45, label %46, label %51
46: ; preds = %35
%47 = load i32*, i32** %7
%48 = call i32 @fprintf(i32* %47, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%49 = load i32*, i32** %7
%50 = call i32 @fclose(i32* %49)
br label %51
51: ; preds = %46, %35
br label %52
52: ; preds = %51
%53 = load i32, i32* %5
%54 = add nsw i32 %53, 1
store i32 %54, i32* %5
br label %32
55: ; preds = %32
br label %56
56: ; preds = %55
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
br label %28
59: ; preds = %28
br label %60
60: ; preds = %59
%61 = load i32, i32* %3
%62 = add nsw i32 %61, 1
store i32 %62, i32* %3
br label %18
63: ; preds = %18
br label %64
64: ; preds = %63
%65 = load i32, i32* %2
%66 = add nsw i32 %65, 1
store i32 %66, i32* %2
br label %9
67: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"dir_%d\00"
@.str.1 = [14 x i8] c"dir_%d/dir_%d\00"
@.str.2 = [23 x i8] c"dir_%d/dir_%d/%d%d.txt\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [13 x i8] c"dummy file.\0A\00"
define i32 @main() {
%1 = alloca [23 x i8]
%2 = getelementptr inbounds [23 x i8], [23 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %30
%4 = phi i32 [ 0, %0 ], [ %31, %30 ]
%5 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %2, i32 23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = call i32 @mkdir(i8* %2)
br label %7
7: ; preds = %3, %27
%8 = phi i32 [ 0, %3 ], [ %28, %27 ]
%9 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %2, i32 23, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %8)
%10 = call i32 @mkdir(i8* %2)
br label %11
11: ; preds = %7, %24
%12 = phi i32 [ 0, %7 ], [ %25, %24 ]
br label %13
13: ; preds = %11, %21
%14 = phi i32 [ 0, %11 ], [ %22, %21 ]
%15 = call i32 (i8*, i32, i8*, i32, ...) @snprintf(i8* %2, i32 23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %8, i32 %12, i32 %14)
%16 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = call i64 @fwrite(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i64 12, i64 1, i32* %16)
%20 = call i32 @fclose(i32* %16)
br label %21
21: ; preds = %18, %13
%22 = add nuw nsw i32 %14, 1
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %13
24: ; preds = %21
%25 = add nuw nsw i32 %12, 1
%26 = icmp eq i32 %25, 10
br i1 %26, label %27, label %11
27: ; preds = %24
%28 = add nuw nsw i32 %8, 1
%29 = icmp eq i32 %28, 40
br i1 %29, label %30, label %7
30: ; preds = %27
%31 = add nuw nsw i32 %4, 1
%32 = icmp eq i32 %31, 10
br i1 %32, label %33, label %3
33: ; preds = %30
ret i32 0
}