#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 */
scalar_t__ asprintf(char **, char *, char const *, long);
int /*<<< orphan*/ assert(int);
int strlen(char const *);
char *full_fn_from_number(const char **filename, const char *path, long num) {
  char *str;
  assert(asprintf(&str, "%s/%li.h2w", path, num + 1) > 0);
  *filename = str + strlen(path) + 1;
  return str;
}


x86 assembly (clang, -O0):
<full_fn_from_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rcx
add    $0x1,%rcx
lea    -0x20(%rbp),%rdi
lea    0xea5(%rip),%rsi
call   1050 <asprintf@plt>
cmp    $0x0,%rax
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rcx
cltq
add    %rax,%rcx
add    $0x1,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<full_fn_from_number>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r15
mov    %rdi,%r14
lea    0x1(%rdx),%rcx
lea    0xeb6(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    %r15,%rdx
call   1050 <asprintf@plt>
xor    %edi,%edi
test   %rax,%rax
setg   %dil
call   1040 <assert@plt>
mov    0x8(%rsp),%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
add    %rbx,%rax
add    $0x1,%rax
mov    %rax,(%r14)
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [11 x i8] c"%s/%li.h2w\00"
define i8* @full_fn_from_number(i8** %0, i8* %1, i64 %2) {
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
store i8** %0, i8*** %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%8 = load i8*, i8** %5
%9 = load i64, i64* %6
%10 = add nsw i64 %9, 1
%11 = call i64 @asprintf(i8** %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %8, i64 %10)
%12 = icmp sgt i64 %11, 0
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
%15 = load i8*, i8** %7
%16 = load i8*, i8** %5
%17 = call i32 @strlen(i8* %16)
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8**, i8*** %4
store i8* %20, i8** %21
%22 = load i8*, i8** %7
ret i8* %22
}

LLVM IR (-O2):
@.str = [11 x i8] c"%s/%li.h2w\00"
define i8* @full_fn_from_number(i8** nocapture writeonly %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
%6 = add nsw i64 %2, 1
%7 = call i64 @asprintf(i8** %4, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %1, i64 %6)
%8 = icmp sgt i64 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = load i8*, i8** %4
%12 = call i32 @strlen(i8* %1)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8* %15, i8** %0
%16 = load i8*, i8** %4
ret i8* %16
}