#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 */
char *calloc(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, int,
                           char *);
int /*<<< orphan*/ stderr;
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *alloc_file_name(char *f_name) {
  int fn_len;
  char *alloc_f_name;
  fn_len = strlen(f_name);
  if ((alloc_f_name = calloc(fn_len + 1, sizeof(char))) == NULL) {
    fprintf(stderr, "*** Warning [%s:%d] - Cannot allocate %d space for %s\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/uwbmrb/BMRB-API/refs/heads/master/"
            "server/wsgi/bmrbapi/submodules/fasta36/src/nmgetlib.c",
            2247, fn_len + 1, f_name);
    exit(1);
  } else {
    strncpy(alloc_f_name, f_name, fn_len);
    alloc_f_name[fn_len - 1] = '\0';
    return alloc_f_name;
  }
}


x86 assembly (clang, -O0):
<alloc_file_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11bd <alloc_file_name+0x6d>
mov    0x2e53(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%r8d
add    $0x1,%r8d
mov    -0x8(%rbp),%r9
lea    0xe5e(%rip),%rsi
lea    0xe8e(%rip),%rdx
mov    $0x8c7,%ecx
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alloc_file_name>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%ebp
lea    0x1(%rbp),%r14d
mov    %r14d,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     119d <alloc_file_name+0x4d>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <strncpy@plt>
movslq %ebp,%rax
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
lea    0xe53(%rip),%rsi
lea    0xe83(%rip),%rdx
mov    $0x8c7,%ecx
mov    %r14d,%r8d
mov    %r15,%r9
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [55 x i8] c"*** Warning [%s:%d] - Cannot allocate %d space for %s\0A\00"
@.str.1 = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/uwbmrb/BMRB-API/refs/heads/master/server/wsgi/bmrbapi/submodules/fasta36/src/nmgetlib.c\00"
define i8* @alloc_file_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i32 @strlen(i8* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = add nsw i32 %7, 1
%9 = call i8* @calloc(i32 %8, i32 1)
store i8* %9, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %18
11: ; preds = %1
%12 = load i32, i32* @stderr
%13 = load i32, i32* %3
%14 = add nsw i32 %13, 1
%15 = load i8*, i8** %2
%16 = call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.1, i64 0, i64 0), i32 2247, i32 %14, i8* %15)
%17 = call i32 @exit(i32 1)
unreachable
18: ; preds = %1
%19 = load i8*, i8** %4
%20 = load i8*, i8** %2
%21 = load i32, i32* %3
%22 = call i32 @strncpy(i8* %19, i8* %20, i32 %21)
%23 = load i8*, i8** %4
%24 = load i32, i32* %3
%25 = sub nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8 0, i8* %27
%28 = load i8*, i8** %4
ret i8* %28
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [55 x i8] c"*** Warning [%s:%d] - Cannot allocate %d space for %s\0A\00"
@.str.1 = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/uwbmrb/BMRB-API/refs/heads/master/server/wsgi/bmrbapi/submodules/fasta36/src/nmgetlib.c\00"
define i8* @alloc_file_name(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 1
%4 = tail call i8* @calloc(i32 %3, i32 1)
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str.1, i64 0, i64 0), i32 2247, i32 %3, i8* %0)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %1
%11 = tail call i32 @strncpy(i8* %4, i8* %0, i32 %2)
%12 = add nsw i32 %2, -1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %4, i64 %13
store i8 0, i8* %14
ret i8* %4
}