#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 tm_hour;
  int tm_min;
};

/* Variables and functions */
int /*<<< orphan*/ get_local_time(struct tm *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int, int, long, char *);
int get_index_file_name(char *filename, long index, char *path, char *ext) {
  struct tm tm;
  int hour, minute;
  get_local_time(&tm);
  hour = tm.tm_hour;
  minute = tm.tm_min;
  sprintf(filename, "%s/%02d%02d%04ld.%s", path, hour, minute, index, ext);
  return 0;
}


x86 assembly (clang, -O0):
<get_index_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
lea    -0x28(%rbp),%rdi
call   1030 <get_local_time@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x2c(%rbp),%ecx
mov    -0x30(%rbp),%r8d
mov    -0x10(%rbp),%r9
mov    -0x20(%rbp),%rax
lea    0xe95(%rip),%rsi
mov    %rax,(%rsp)
call   1040 <sprintf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_index_file_name>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x10(%rsp),%rdi
call   1030 <get_local_time@plt>
mov    0x10(%rsp),%ecx
mov    0x14(%rsp),%r8d
mov    %r12,(%rsp)
lea    0xeab(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
mov    %r15,%r9
call   1040 <sprintf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32 }
@.str = [20 x i8] c"%s/%02d%02d%04ld.%s\00"
define i32 @get_index_file_name(i8* %0, i64 %1, i8* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.tm
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%12 = call i32 @get_local_time(%struct.tm* %9)
%13 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 0
%14 = load i32, i32* %13
store i32 %14, i32* %10
%15 = getelementptr inbounds %struct.tm, %struct.tm* %9, i32 0, i32 1
%16 = load i32, i32* %15
store i32 %16, i32* %11
%17 = load i8*, i8** %5
%18 = load i8*, i8** %7
%19 = load i32, i32* %10
%20 = load i32, i32* %11
%21 = load i64, i64* %6
%22 = load i8*, i8** %8
%23 = call i32 @sprintf(i8* %17, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %18, i32 %19, i32 %20, i64 %21, i8* %22)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32 }
@.str = [20 x i8] c"%s/%02d%02d%04ld.%s\00"
define i32 @get_index_file_name(i8* nocapture writeonly %0, i64 %1, i8* %2, i8* %3) {
%5 = alloca %struct.tm
%6 = bitcast %struct.tm* %5 to i8*
%7 = call i32 @get_local_time(%struct.tm* %5)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%11 = load i32, i32* %10
%12 = call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %2, i32 %9, i32 %11, i64 %1, i8* %3)
ret i32 0
}