#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 */
long double filename_num(char *);
char *malloc(int);
int /*<<< orphan*/ memcpy(char **, ...);
int /*<<< orphan*/ memset(char *, int, int);
int snprintf(char *, int, char *, ...);
int strlen(char *);
char *directory_structure(char *filename) {
  long double number = 0;
  char hash[33];
  char str[22];
  int retval = 0;
  int temp = 0;
  char a[9];
  char b[9];
  char c[9];
  char d[9];
  char *dir = NULL;
  memset(hash, 0, 33 * sizeof(char));
  memset(str, 0, 22 * sizeof(char));
  temp = strlen(filename);
  if (temp < (22 - 1)) {
    memcpy(&str, filename, temp);
    memset(&str[temp], 48, 22 - temp);
    memset(&str[21], 0, 1);
    number = filename_num(str);
  } else
    number = filename_num(filename);
  retval = snprintf(hash, 33, "%.0Lf", number);
  if (retval < 0)
    return NULL;
  memcpy(&a, &hash, 8);
  memset(&a[8], 0, 1);
  memcpy(&b, &hash[8], 8);
  memset(&b[8], 0, 1);
  memcpy(&c, &hash[16], 8);
  memset(&c[8], 0, 1);
  memcpy(&d, &hash[24], 8);
  memset(&d[8], 0, 1);
  temp = 37 * sizeof(char);
  dir = malloc(temp);
  if (dir == NULL)
    return NULL;
  memset(dir, 0, temp);
  snprintf(dir, temp, "%s/%s/%s/%s/", a, b, c, d);
  return dir;
}


x86 assembly (clang, -O0):
<directory_structure>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    %rdi,-0x10(%rbp)
fldz
fstpt  -0x20(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
movq   $0x0,-0xa8(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1050 <memset@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x16,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0x15,-0x78(%rbp)
jge    1226 <directory_structure+0xc6>
mov    -0x10(%rbp),%rsi
mov    -0x78(%rbp),%edx
xor    %eax,%eax
mov    %eax,-0xb4(%rbp)
lea    -0x70(%rbp),%rdi
mov    %rdi,-0xb0(%rbp)
call   1060 <memcpy@plt>
movslq -0x78(%rbp),%rcx
mov    %ecx,%eax
lea    -0x70(%rbp,%rcx,1),%rdi
mov    $0x16,%edx
sub    %eax,%edx
mov    $0x30,%esi
call   1050 <memset@plt>
mov    -0xb4(%rbp),%esi
lea    -0x5b(%rbp),%rdi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    -0xb0(%rbp),%rdi
call   1080 <filename_num@plt>
fstpt  -0x20(%rbp)
jmp    1232 <directory_structure+0xd2>
mov    -0x10(%rbp),%rdi
call   1080 <filename_num@plt>
fstpt  -0x20(%rbp)
lea    -0x50(%rbp),%rdi
fldt   -0x20(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xdbb(%rip),%rdx
xor    %eax,%eax
mov    $0x21,%esi
call   1040 <snprintf@plt>
mov    %eax,-0x74(%rbp)
cmpl   $0x0,-0x74(%rbp)
jge    126b <directory_structure+0x10b>
movq   $0x0,-0x8(%rbp)
jmp    13b4 <directory_structure+0x254>
lea    -0x81(%rbp),%rdi
xor    %eax,%eax
lea    -0x50(%rbp),%rsi
mov    $0x8,%edx
call   1060 <memcpy@plt>
lea    -0x81(%rbp),%rdi
add    $0x8,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
lea    -0x8a(%rbp),%rdi
lea    -0x50(%rbp),%rsi
add    $0x8,%rsi
xor    %eax,%eax
mov    $0x8,%edx
call   1060 <memcpy@plt>
lea    -0x8a(%rbp),%rdi
add    $0x8,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
lea    -0x93(%rbp),%rdi
lea    -0x50(%rbp),%rsi
add    $0x10,%rsi
xor    %eax,%eax
mov    $0x8,%edx
call   1060 <memcpy@plt>
lea    -0x93(%rbp),%rdi
add    $0x8,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
lea    -0x9c(%rbp),%rdi
lea    -0x50(%rbp),%rsi
add    $0x18,%rsi
xor    %eax,%eax
mov    $0x8,%edx
call   1060 <memcpy@plt>
lea    -0x9c(%rbp),%rdi
add    $0x8,%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
movl   $0x25,-0x78(%rbp)
mov    -0x78(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
jne    1360 <directory_structure+0x200>
movq   $0x0,-0x8(%rbp)
jmp    13b4 <directory_structure+0x254>
mov    -0xa8(%rbp),%rdi
mov    -0x78(%rbp),%edx
xor    %esi,%esi
call   1050 <memset@plt>
mov    -0xa8(%rbp),%rdi
mov    -0x78(%rbp),%esi
lea    -0x81(%rbp),%rcx
lea    -0x8a(%rbp),%r8
lea    -0x93(%rbp),%r9
lea    -0x9c(%rbp),%rax
lea    0xc68(%rip),%rdx
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    -0xa8(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<directory_structure>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x88,%rsp
mov    %rdi,%rbx
lea    0x60(%rsp),%rdi
xor    %esi,%esi
mov    $0x21,%edx
call   1050 <memset@plt>
lea    0x40(%rsp),%rdi
mov    $0x16,%r14d
xor    %esi,%esi
mov    $0x16,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    $0x14,%eax
jg     11ec <directory_structure+0x8c>
mov    %eax,%ebp
lea    0x40(%rsp),%r15
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1060 <memcpy@plt>
movslq %ebp,%rax
lea    (%rsp,%rax,1),%rdi
add    $0x40,%rdi
sub    %ebp,%r14d
mov    $0x30,%esi
mov    %r14d,%edx
call   1050 <memset@plt>
lea    0x55(%rsp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    %r15,%rdi
jmp    11ef <directory_structure+0x8f>
mov    %rbx,%rdi
call   1080 <filename_num@plt>
fstpt  (%rsp)
lea    0xe02(%rip),%rdx
xor    %ebp,%ebp
lea    0x60(%rsp),%rdi
mov    $0x21,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
test   %eax,%eax
js     1307 <directory_structure+0x1a7>
xor    %ebp,%ebp
lea    0x2e(%rsp),%rdi
lea    0x60(%rsp),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1060 <memcpy@plt>
lea    0x36(%rsp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
lea    0x68(%rsp),%rsi
lea    0x25(%rsp),%rdi
mov    $0x8,%edx
xor    %eax,%eax
call   1060 <memcpy@plt>
lea    0x2d(%rsp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
lea    0x70(%rsp),%rsi
lea    0x1c(%rsp),%rdi
mov    $0x8,%edx
xor    %eax,%eax
call   1060 <memcpy@plt>
lea    0x24(%rsp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
lea    0x78(%rsp),%rsi
lea    0x37(%rsp),%r14
mov    %r14,%rdi
mov    $0x8,%edx
xor    %eax,%eax
call   1060 <memcpy@plt>
lea    0x3f(%rsp),%rdi
xor    %esi,%esi
mov    $0x1,%edx
call   1050 <memset@plt>
mov    $0x25,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     1307 <directory_structure+0x1a7>
mov    %rax,%rbx
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x25,%edx
call   1050 <memset@plt>
mov    %r14,(%rsp)
lea    0xd20(%rip),%rdx
lea    0x2e(%rsp),%rcx
lea    0x25(%rsp),%r8
lea    0x1c(%rsp),%r9
mov    %rbx,%rdi
mov    $0x25,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rbx,%rbp
mov    %rbp,%rax
add    $0x88,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%.0Lf\00"
@.str.1 = [13 x i8] c"%s/%s/%s/%s/\00"
define i8* @directory_structure(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca x86_fp80
%5 = alloca [33 x i8]
%6 = alloca [22 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca [9 x i8]
%10 = alloca [9 x i8]
%11 = alloca [9 x i8]
%12 = alloca [9 x i8]
%13 = alloca i8*
store i8* %0, i8** %3
store x86_fp80 0xK00000000000000000000, x86_fp80* %4
store i32 0, i32* %7
store i32 0, i32* %8
store i8* null, i8** %13
%14 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
%15 = call i32 @memset(i8* %14, i32 0, i32 33)
%16 = getelementptr inbounds [22 x i8], [22 x i8]* %6, i64 0, i64 0
%17 = call i32 @memset(i8* %16, i32 0, i32 22)
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
store i32 %19, i32* %8
%20 = load i32, i32* %8
%21 = icmp slt i32 %20, 21
br i1 %21, label %22, label %37
22: ; preds = %1
%23 = bitcast [22 x i8]* %6 to i8**
%24 = load i8*, i8** %3
%25 = load i32, i32* %8
%26 = call i32 (i8**, ...) @memcpy(i8** %23, i8* %24, i32 %25)
%27 = load i32, i32* %8
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [22 x i8], [22 x i8]* %6, i64 0, i64 %28
%30 = load i32, i32* %8
%31 = sub nsw i32 22, %30
%32 = call i32 @memset(i8* %29, i32 48, i32 %31)
%33 = getelementptr inbounds [22 x i8], [22 x i8]* %6, i64 0, i64 21
%34 = call i32 @memset(i8* %33, i32 0, i32 1)
%35 = getelementptr inbounds [22 x i8], [22 x i8]* %6, i64 0, i64 0
%36 = call x86_fp80 @filename_num(i8* %35)
store x86_fp80 %36, x86_fp80* %4
br label %40
37: ; preds = %1
%38 = load i8*, i8** %3
%39 = call x86_fp80 @filename_num(i8* %38)
store x86_fp80 %39, x86_fp80* %4
br label %40
40: ; preds = %37, %22
%41 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 0
%42 = load x86_fp80, x86_fp80* %4
%43 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %41, i32 33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), x86_fp80 %42)
store i32 %43, i32* %7
%44 = load i32, i32* %7
%45 = icmp slt i32 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %40
store i8* null, i8** %2
br label %84
47: ; preds = %40
%48 = bitcast [9 x i8]* %9 to i8**
%49 = call i32 (i8**, ...) @memcpy(i8** %48, [33 x i8]* %5, i32 8)
%50 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 8
%51 = call i32 @memset(i8* %50, i32 0, i32 1)
%52 = bitcast [9 x i8]* %10 to i8**
%53 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 8
%54 = call i32 (i8**, ...) @memcpy(i8** %52, i8* %53, i32 8)
%55 = getelementptr inbounds [9 x i8], [9 x i8]* %10, i64 0, i64 8
%56 = call i32 @memset(i8* %55, i32 0, i32 1)
%57 = bitcast [9 x i8]* %11 to i8**
%58 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 16
%59 = call i32 (i8**, ...) @memcpy(i8** %57, i8* %58, i32 8)
%60 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 8
%61 = call i32 @memset(i8* %60, i32 0, i32 1)
%62 = bitcast [9 x i8]* %12 to i8**
%63 = getelementptr inbounds [33 x i8], [33 x i8]* %5, i64 0, i64 24
%64 = call i32 (i8**, ...) @memcpy(i8** %62, i8* %63, i32 8)
%65 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 8
%66 = call i32 @memset(i8* %65, i32 0, i32 1)
store i32 37, i32* %8
%67 = load i32, i32* %8
%68 = call i8* @malloc(i32 %67)
store i8* %68, i8** %13
%69 = load i8*, i8** %13
%70 = icmp eq i8* %69, null
br i1 %70, label %71, label %72
71: ; preds = %47
store i8* null, i8** %2
br label %84
72: ; preds = %47
%73 = load i8*, i8** %13
%74 = load i32, i32* %8
%75 = call i32 @memset(i8* %73, i32 0, i32 %74)
%76 = load i8*, i8** %13
%77 = load i32, i32* %8
%78 = getelementptr inbounds [9 x i8], [9 x i8]* %9, i64 0, i64 0
%79 = getelementptr inbounds [9 x i8], [9 x i8]* %10, i64 0, i64 0
%80 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
%81 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 0
%82 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %76, i32 %77, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %78, i8* %79, i8* %80, i8* %81)
%83 = load i8*, i8** %13
store i8* %83, i8** %2
br label %84
84: ; preds = %72, %71, %46
%85 = load i8*, i8** %2
ret i8* %85
}

LLVM IR (-O2):
@.str = [6 x i8] c"%.0Lf\00"
@.str.1 = [13 x i8] c"%s/%s/%s/%s/\00"
define i8* @directory_structure(i8* %0) {
%2 = alloca [33 x i8]
%3 = alloca [22 x i8]
%4 = alloca [9 x i8]
%5 = alloca [9 x i8]
%6 = alloca [9 x i8]
%7 = alloca [9 x i8]
%8 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 0
%13 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 0
%14 = call i32 @memset(i8* %8, i32 0, i32 33)
%15 = call i32 @memset(i8* %9, i32 0, i32 22)
%16 = call i32 @strlen(i8* %0)
%17 = icmp slt i32 %16, 21
br i1 %17, label %18, label %28
18: ; preds = %1
%19 = bitcast [22 x i8]* %3 to i8**
%20 = call i32 (i8**, ...) @memcpy(i8** %19, i8* %0, i32 %16)
%21 = sext i32 %16 to i64
%22 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 %21
%23 = sub nsw i32 22, %16
%24 = call i32 @memset(i8* %22, i32 48, i32 %23)
%25 = getelementptr inbounds [22 x i8], [22 x i8]* %3, i64 0, i64 21
%26 = call i32 @memset(i8* %25, i32 0, i32 1)
%27 = call x86_fp80 @filename_num(i8* %9)
br label %30
28: ; preds = %1
%29 = call x86_fp80 @filename_num(i8* %0)
br label %30
30: ; preds = %28, %18
%31 = phi x86_fp80 [ %27, %18 ], [ %29, %28 ]
%32 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %8, i32 33, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), x86_fp80 %31)
%33 = icmp slt i32 %32, 0
br i1 %33, label %59, label %34
34: ; preds = %30
%35 = bitcast [9 x i8]* %4 to i8**
%36 = call i32 (i8**, ...) @memcpy(i8** %35, [33 x i8]* %2, i32 8)
%37 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 8
%38 = call i32 @memset(i8* %37, i32 0, i32 1)
%39 = bitcast [9 x i8]* %5 to i8**
%40 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 8
%41 = call i32 (i8**, ...) @memcpy(i8** %39, i8* %40, i32 8)
%42 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 8
%43 = call i32 @memset(i8* %42, i32 0, i32 1)
%44 = bitcast [9 x i8]* %6 to i8**
%45 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 16
%46 = call i32 (i8**, ...) @memcpy(i8** %44, i8* %45, i32 8)
%47 = getelementptr inbounds [9 x i8], [9 x i8]* %6, i64 0, i64 8
%48 = call i32 @memset(i8* %47, i32 0, i32 1)
%49 = bitcast [9 x i8]* %7 to i8**
%50 = getelementptr inbounds [33 x i8], [33 x i8]* %2, i64 0, i64 24
%51 = call i32 (i8**, ...) @memcpy(i8** %49, i8* %50, i32 8)
%52 = getelementptr inbounds [9 x i8], [9 x i8]* %7, i64 0, i64 8
%53 = call i32 @memset(i8* %52, i32 0, i32 1)
%54 = call dereferenceable_or_null(37) i8* @malloc(i32 37)
%55 = icmp eq i8* %54, null
br i1 %55, label %59, label %56
56: ; preds = %34
%57 = call i32 @memset(i8* %54, i32 0, i32 37)
%58 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %54, i32 37, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %10, i8* %11, i8* %12, i8* %13)
br label %59
59: ; preds = %34, %30, %56
%60 = phi i8* [ %54, %56 ], [ null, %30 ], [ null, %34 ]
ret i8* %60
}