#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 scalar_t__ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
struct tm *localtime(scalar_t__ *);
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int strlen(char const *);
void iter_to_folder(int iter, const char *dst, time_t start_time, int dt,
                    char **name) {
  time_t ti = start_time + iter * dt;
  struct tm *timestruct = localtime(&ti);
  char buff[80];
  strftime(buff, 80, "%Y_%m_%d_%H_%M_%S", timestruct);
  int size = strlen(buff) + strlen(dst) + 1;
  *name = malloc((size + 1) * sizeof(char));
  sprintf(*name, "%s/%s", dst, buff);
  (*name)[size] = '\0';
}


x86 assembly (clang, -O0):
<iter_to_folder>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x38(%rbp)
lea    -0x90(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x50,%esi
lea    0xe5a(%rip),%rdx
call   1060 <strftime@plt>
lea    -0x90(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x98(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%eax
add    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rdx
lea    -0x90(%rbp),%rcx
lea    0xe00(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
movslq -0x94(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iter_to_folder>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    %r8,%r14
mov    %rsi,%r12
imul   %ecx,%edi
movslq %edi,%rax
add    %rdx,%rax
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <localtime@plt>
lea    0xe7e(%rip),%rdx
lea    0x10(%rsp),%r15
mov    %r15,%rdi
mov    $0x50,%esi
mov    %rax,%rcx
call   1060 <strftime@plt>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    (%rax,%rbx,1),%ecx
movslq %ecx,%r13
lea    (%rax,%rbx,1),%edi
add    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,(%r14)
lea    0xe4e(%rip),%rsi
mov    %rax,%rdi
mov    %r12,%rdx
mov    %r15,%rcx
call   1070 <sprintf@plt>
mov    (%r14),%rax
movb   $0x0,0x1(%r13,%rax,1)
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y_%m_%d_%H_%M_%S\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define void @iter_to_folder(i32 %0, i8* %1, i64 %2, i32 %3, i8** %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i8**
%11 = alloca i64
%12 = alloca %struct.tm*
%13 = alloca [80 x i8]
%14 = alloca i32
store i32 %0, i32* %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i32 %3, i32* %9
store i8** %4, i8*** %10
%15 = load i64, i64* %8
%16 = load i32, i32* %6
%17 = load i32, i32* %9
%18 = mul nsw i32 %16, %17
%19 = sext i32 %18 to i64
%20 = add nsw i64 %15, %19
store i64 %20, i64* %11
%21 = call %struct.tm* @localtime(i64* %11)
store %struct.tm* %21, %struct.tm** %12
%22 = getelementptr inbounds [80 x i8], [80 x i8]* %13, i64 0, i64 0
%23 = load %struct.tm*, %struct.tm** %12
%24 = call i32 @strftime(i8* %22, i32 80, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %23)
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %13, i64 0, i64 0
%26 = call i32 @strlen(i8* %25)
%27 = load i8*, i8** %7
%28 = call i32 @strlen(i8* %27)
%29 = add nsw i32 %26, %28
%30 = add nsw i32 %29, 1
store i32 %30, i32* %14
%31 = load i32, i32* %14
%32 = add nsw i32 %31, 1
%33 = sext i32 %32 to i64
%34 = mul i64 %33, 1
%35 = trunc i64 %34 to i32
%36 = call i8* @malloc(i32 %35)
%37 = load i8**, i8*** %10
store i8* %36, i8** %37
%38 = load i8**, i8*** %10
%39 = load i8*, i8** %38
%40 = load i8*, i8** %7
%41 = getelementptr inbounds [80 x i8], [80 x i8]* %13, i64 0, i64 0
%42 = call i32 @sprintf(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %40, i8* %41)
%43 = load i8**, i8*** %10
%44 = load i8*, i8** %43
%45 = load i32, i32* %14
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
store i8 0, i8* %47
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y_%m_%d_%H_%M_%S\00"
@.str.1 = [6 x i8] c"%s/%s\00"
define void @iter_to_folder(i32 %0, i8* %1, i64 %2, i32 %3, i8** nocapture %4) {
%6 = alloca i64
%7 = alloca [80 x i8]
%8 = bitcast i64* %6 to i8*
%9 = mul nsw i32 %3, %0
%10 = sext i32 %9 to i64
%11 = add nsw i64 %10, %2
store i64 %11, i64* %6
%12 = call %struct.tm* @localtime(i64* %6)
%13 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%14 = call i32 @strftime(i8* %13, i32 80, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %12)
%15 = call i32 @strlen(i8* %13)
%16 = call i32 @strlen(i8* %1)
%17 = add nsw i32 %16, %15
%18 = add nsw i32 %17, 1
%19 = add nsw i32 %17, 2
%20 = call i8* @malloc(i32 %19)
store i8* %20, i8** %4
%21 = call i32 @sprintf(i8* dereferenceable(1) %20, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %13)
%22 = load i8*, i8** %4
%23 = sext i32 %18 to i64
%24 = getelementptr inbounds i8, i8* %22, i64 %23
store i8 0, i8* %24
ret void
}