#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 */
int /*<<< orphan*/ sprintf(char *, char *, char *, int const, int const,
                           char const *, char const *);
char *strchr(char const *, char);
char *strchrnul(char const *, char);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void pnicorr_genoutfile(const char *filename, const int num_timeseries,
                        const char *ext, const char *comp, char *outfile) {
  char *loc = strchrnul(filename, '.');
  if (*loc != '\0')
    loc = strchr(filename, '.');
  strncpy(outfile, filename, loc - filename);
  sprintf(outfile, "%s_%dx%d_correlations.%s%s", outfile, num_timeseries,
          num_timeseries, ext, comp);
  (void)0;
}


x86 assembly (clang, -O0):
<pnicorr_genoutfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strchrnul@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118f <pnicorr_genoutfile+0x4f>
mov    -0x8(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x30(%rbp),%rax
mov    -0x8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    -0x28(%rbp),%rdi
mov    -0x28(%rbp),%rdx
mov    -0xc(%rbp),%ecx
mov    -0xc(%rbp),%r8d
mov    -0x18(%rbp),%r9
mov    -0x20(%rbp),%rax
lea    0xe39(%rip),%rsi
mov    %rax,(%rsp)
call   1060 <sprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pnicorr_genoutfile>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8,%rbx
mov    %rcx,%r15
mov    %rdx,%r14
mov    %esi,%r12d
mov    %rdi,%rbp
mov    $0x2e,%esi
call   1040 <strchrnul@plt>
cmpb   $0x0,(%rax)
je     1177 <pnicorr_genoutfile+0x37>
mov    %rbp,%rdi
mov    $0x2e,%esi
call   1050 <strchr@plt>
sub    %ebp,%eax
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1030 <strncpy@plt>
mov    %r15,(%rsp)
lea    0xe6f(%rip),%rsi
mov    %rbx,%rdi
mov    %rbx,%rdx
mov    %r12d,%ecx
mov    %r12d,%r8d
mov    %r14,%r9
call   1060 <sprintf@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"%s_%dx%d_correlations.%s%s\00"
define void @pnicorr_genoutfile(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = load i8*, i8** %6
%13 = call i8* @strchrnul(i8* %12, i8 signext 46)
store i8* %13, i8** %11
%14 = load i8*, i8** %11
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %5
%19 = load i8*, i8** %6
%20 = call i8* @strchr(i8* %19, i8 signext 46)
store i8* %20, i8** %11
br label %21
21: ; preds = %18, %5
%22 = load i8*, i8** %10
%23 = load i8*, i8** %6
%24 = load i8*, i8** %11
%25 = load i8*, i8** %6
%26 = ptrtoint i8* %24 to i64
%27 = ptrtoint i8* %25 to i64
%28 = sub i64 %26, %27
%29 = trunc i64 %28 to i32
%30 = call i32 @strncpy(i8* %22, i8* %23, i32 %29)
%31 = load i8*, i8** %10
%32 = load i8*, i8** %10
%33 = load i32, i32* %7
%34 = load i32, i32* %7
%35 = load i8*, i8** %8
%36 = load i8*, i8** %9
%37 = call i32 @sprintf(i8* %31, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %32, i32 %33, i32 %34, i8* %35, i8* %36)
ret void
}

LLVM IR (-O2):
@.str = [27 x i8] c"%s_%dx%d_correlations.%s%s\00"
define void @pnicorr_genoutfile(i8* %0, i32 %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i8* @strchrnul(i8* %0, i8 signext 46)
%7 = load i8, i8* %6
%8 = icmp eq i8 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %5
%10 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 46)
br label %11
11: ; preds = %9, %5
%12 = phi i8* [ %10, %9 ], [ %6, %5 ]
%13 = ptrtoint i8* %12 to i64
%14 = ptrtoint i8* %0 to i64
%15 = sub i64 %13, %14
%16 = trunc i64 %15 to i32
%17 = tail call i32 @strncpy(i8* %4, i8* %0, i32 %16)
%18 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %1, i32 %1, i8* %2, i8* %3)
ret void
}