#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 */
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ int64_t;
typedef int /*<<< orphan*/ date_string;

/* Variables and functions */
char *add_path_parts(char *, char *);
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
char *get_index_subdirectory(char *indexdir, int64_t timestamp) {
  struct tm *gmt = gmtime(&timestamp);
  char date_string[8];
  strftime(date_string, sizeof(date_string), "%Y_%m", gmt);
  char *index_subdir = add_path_parts(indexdir, date_string);
  mkdir(index_subdir, 0777);
  return index_subdir;
}


x86 assembly (clang, -O0):
<get_index_subdirectory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x8,%esi
lea    0xe90(%rip),%rdx
call   1040 <strftime@plt>
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <add_path_parts@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_index_subdirectory>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
mov    %esi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <gmtime@plt>
lea    0xea1(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x8,%esi
mov    %rax,%rcx
call   1040 <strftime@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <add_path_parts@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [6 x i8] c"%Y_%m\00"
define i8* @get_index_subdirectory(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.tm*
%6 = alloca [8 x i8]
%7 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%8 = call %struct.tm* @gmtime(i32* %4)
store %struct.tm* %8, %struct.tm** %5
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%10 = load %struct.tm*, %struct.tm** %5
%11 = call i32 @strftime(i8* %9, i32 8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %10)
%12 = load i8*, i8** %3
%13 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%14 = call i8* @add_path_parts(i8* %12, i8* %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = call i32 @mkdir(i8* %15, i32 511)
%17 = load i8*, i8** %7
ret i8* %17
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [6 x i8] c"%Y_%m\00"
define i8* @get_index_subdirectory(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca [8 x i8]
store i32 %1, i32* %3
%5 = call %struct.tm* @gmtime(i32* %3)
%6 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 0
%7 = call i32 @strftime(i8* %6, i32 8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), %struct.tm* %5)
%8 = call i8* @add_path_parts(i8* %0, i8* %6)
%9 = call i32 @mkdir(i8* %8, i32 511)
ret i8* %8
}