#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*/ snprintf(char *, size_t, char *, char const *, ...);
void gen_classiclog_fname(char *fname, size_t fname_sz, const char *archive_dir,
                          const char *namepart, int numlogs_c) {
  if (archive_dir[0] != '\0')
    (void)snprintf(fname, fname_sz, "%s/%s.%d", archive_dir, namepart,
                   numlogs_c);
  else
    (void)snprintf(fname, fname_sz, "%s.%d", namepart, numlogs_c);
}


x86 assembly (clang, -O0):
<gen_classiclog_fname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1163 <gen_classiclog_fname+0x53>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x24(%rbp),%r9d
lea    0xea9(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
jmp    1181 <gen_classiclog_fname+0x71>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
lea    0xe89(%rip),%rdx
mov    $0x0,%al
call   1030 <snprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_classiclog_fname>:
mov    %r8d,%r9d
mov    %rcx,%r8
cmpb   $0x0,(%rdx)
je     112c <gen_classiclog_fname+0x1c>
mov    %rdx,%rcx
lea    0xedb(%rip),%rdx
xor    %eax,%eax
jmp    1030 <snprintf@plt>
lea    0xed0(%rip),%rdx
mov    %r8,%rcx
mov    %r9d,%r8d
xor    %eax,%eax
jmp    1030 <snprintf@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%s/%s.%d\00"
@.str.1 = [6 x i8] c"%s.%d\00"
define void @gen_classiclog_fname(i8* %0, i64 %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %6
store i64 %1, i64* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%11 = load i8*, i8** %8
%12 = getelementptr inbounds i8, i8* %11, i64 0
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %5
%17 = load i8*, i8** %6
%18 = load i64, i64* %7
%19 = load i8*, i8** %8
%20 = load i8*, i8** %9
%21 = load i32, i32* %10
%22 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %17, i64 %18, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %19, i8* %20, i32 %21)
br label %29
23: ; preds = %5
%24 = load i8*, i8** %6
%25 = load i64, i64* %7
%26 = load i8*, i8** %9
%27 = load i32, i32* %10
%28 = call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %24, i64 %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %26, i32 %27)
br label %29
29: ; preds = %23, %16
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s/%s.%d\00"
@.str.1 = [6 x i8] c"%s.%d\00"
define void @gen_classiclog_fname(i8* %0, i64 %1, i8* %2, i8* %3, i32 %4) {
%6 = load i8, i8* %2
%7 = icmp eq i8 %6, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = tail call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %3, i32 %4)
br label %12
10: ; preds = %5
%11 = tail call i32 (i8*, i64, i8*, i8*, ...) @snprintf(i8* %0, i64 %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %3, i32 %4)
br label %12
12: ; preds = %10, %8
ret void
}