#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ calloc(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
void encode_json_lines(FILE *fp, const char *label, const char *annot_s,
                       int first) {
  char *obp, *bp;
  char *tmp_annot_s;
  int n_tmp_annot_s;
  n_tmp_annot_s = strlen(annot_s) + 1;
  if ((tmp_annot_s = (char *)calloc(n_tmp_annot_s, sizeof(char))) == NULL) {
    fprintf(stderr, "*** ERROR [%s:%d] *** cannot allocate tmp_annot_s[%d]\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/url_subs.c",
            64, n_tmp_annot_s);
    return;
  }
  strncpy(tmp_annot_s, annot_s, n_tmp_annot_s);
  tmp_annot_s[n_tmp_annot_s - 1] = '\0';
  if (!first) {
    fprintf(fp, ",\n");
  }
  fprintf(fp, " \"%s\": [\n", label);
  obp = bp = tmp_annot_s;
  while ((bp = strchr(obp, '\n'))) {
    *bp = '\0';
    if (obp != tmp_annot_s)
      fprintf(fp, ",\n");
    fprintf(fp, " \"%s\"", obp);
    obp = bp + 1;
  }
  fprintf(fp, "\n ]");
  free(tmp_annot_s);
}


x86 assembly (clang, -O0):
<encode_json_lines>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    11ce <encode_json_lines+0x6e>
mov    0x2e38(%rip),%rax
movslq (%rax),%rdi
mov    -0x3c(%rbp),%r8d
lea    0xe4a(%rip),%rsi
lea    0xe7a(%rip),%rdx
mov    $0x40,%ecx
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    12b2 <encode_json_lines+0x152>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x3c(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x38(%rbp),%rax
mov    -0x3c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
cmpl   $0x0,-0x1c(%rbp)
jne    120b <encode_json_lines+0xab>
mov    -0x8(%rbp),%rdi
lea    0xee5(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xed2(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     1297 <encode_json_lines+0x137>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x28(%rbp),%rax
cmp    -0x38(%rbp),%rax
je     1270 <encode_json_lines+0x110>
mov    -0x8(%rbp),%rdi
lea    0xe80(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    122d <encode_json_lines+0xcd>
mov    -0x8(%rbp),%rdi
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encode_json_lines>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r13d
mov    %rdx,%rbx
mov    %rsi,(%rsp)
mov    %rdi,%r12
mov    %rdx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r15d
lea    0x1(%r15),%ebp
mov    %ebp,%edi
mov    $0x1,%esi
call   1070 <calloc@plt>
test   %rax,%rax
je     129a <encode_json_lines+0x12a>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
movslq %r15d,%rax
movb   $0x0,(%r14,%rax,1)
test   %r13d,%r13d
jne    11e2 <encode_json_lines+0x72>
lea    0xf19(%rip),%rdi
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1090 <fwrite@plt>
lea    0xf03(%rip),%rsi
mov    %r12,%rdi
mov    (%rsp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     126b <encode_json_lines+0xfb>
mov    %rax,%rbx
lea    0xee3(%rip),%r15
lea    0xecf(%rip),%r13
mov    %r14,%rbp
jmp    124c <encode_json_lines+0xdc>
nop
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %rbx,%rbp
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
mov    %rax,%rbx
test   %rax,%rax
je     126b <encode_json_lines+0xfb>
movb   $0x0,(%rbx)
cmp    %r14,%rbp
je     1220 <encode_json_lines+0xb0>
mov    $0x2,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %r12,%rcx
call   1090 <fwrite@plt>
jmp    1220 <encode_json_lines+0xb0>
lea    0xe8a(%rip),%rdi
mov    $0x3,%esi
mov    $0x1,%edx
mov    %r12,%rcx
call   1090 <fwrite@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>
mov    0x2d3f(%rip),%rax
movslq (%rax),%rdi
lea    0xd55(%rip),%rsi
lea    0xd85(%rip),%rdx
mov    $0x40,%ecx
mov    %ebp,%r8d
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <fprintf@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [55 x i8] c"*** ERROR [%s:%d] *** cannot allocate tmp_annot_s[%d]\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/url_subs.c\00"
@.str.2 = [3 x i8] c",\0A\00"
@.str.3 = [10 x i8] c" \22%s\22: [\0A\00"
@.str.4 = [6 x i8] c" \22%s\22\00"
@.str.5 = [4 x i8] c"\0A ]\00"
define void @encode_json_lines(i32* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%13 = load i8*, i8** %7
%14 = call i32 @strlen(i8* %13)
%15 = add nsw i32 %14, 1
store i32 %15, i32* %12
%16 = load i32, i32* %12
%17 = call i64 @calloc(i32 %16, i32 1)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %11
%19 = icmp eq i8* %18, null
br i1 %19, label %20, label %26
20: ; preds = %4
%21 = load i32, i32* @stderr
%22 = sext i32 %21 to i64
%23 = inttoptr i64 %22 to i32*
%24 = load i32, i32* %12
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %23, 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 64, i32 %24)
br label %69
26: ; preds = %4
%27 = load i8*, i8** %11
%28 = load i8*, i8** %7
%29 = load i32, i32* %12
%30 = call i32 @strncpy(i8* %27, i8* %28, i32 %29)
%31 = load i8*, i8** %11
%32 = load i32, i32* %12
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
store i8 0, i8* %35
%36 = load i32, i32* %8
%37 = icmp ne i32 %36, 0
br i1 %37, label %41, label %38
38: ; preds = %26
%39 = load i32*, i32** %5
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %41
41: ; preds = %38, %26
%42 = load i32*, i32** %5
%43 = load i8*, i8** %6
%44 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %43)
%45 = load i8*, i8** %11
store i8* %45, i8** %10
store i8* %45, i8** %9
br label %46
46: ; preds = %58, %41
%47 = load i8*, i8** %9
%48 = call i8* @strchr(i8* %47, i8 signext 10)
store i8* %48, i8** %10
%49 = icmp ne i8* %48, null
br i1 %49, label %50, label %64
50: ; preds = %46
%51 = load i8*, i8** %10
store i8 0, i8* %51
%52 = load i8*, i8** %9
%53 = load i8*, i8** %11
%54 = icmp ne i8* %52, %53
br i1 %54, label %55, label %58
55: ; preds = %50
%56 = load i32*, i32** %5
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %58
58: ; preds = %55, %50
%59 = load i32*, i32** %5
%60 = load i8*, i8** %9
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %60)
%62 = load i8*, i8** %10
%63 = getelementptr inbounds i8, i8* %62, i64 1
store i8* %63, i8** %9
br label %46
64: ; preds = %46
%65 = load i32*, i32** %5
%66 = call i32 (i32*, i8*, ...) @fprintf(i32* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%67 = load i8*, i8** %11
%68 = call i32 @free(i8* %67)
br label %69
69: ; preds = %64, %20
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [55 x i8] c"*** ERROR [%s:%d] *** cannot allocate tmp_annot_s[%d]\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/url_subs.c\00"
@.str.2 = [3 x i8] c",\0A\00"
@.str.3 = [10 x i8] c" \22%s\22: [\0A\00"
@.str.4 = [6 x i8] c" \22%s\22\00"
@.str.5 = [4 x i8] c"\0A ]\00"
define void @encode_json_lines(i32* nocapture %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %2)
%6 = add nsw i32 %5, 1
%7 = tail call i64 @calloc(i32 %6, i32 1)
%8 = inttoptr i64 %7 to i8*
%9 = icmp eq i64 %7, 0
br i1 %9, label %10, label %15
10: ; preds = %4
%11 = load i32, i32* @stderr
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i32*
%14 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %13, 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 64, i32 %6)
br label %40
15: ; preds = %4
%16 = tail call i32 @strncpy(i8* %8, i8* %2, i32 %6)
%17 = sext i32 %5 to i64
%18 = getelementptr inbounds i8, i8* %8, i64 %17
store i8 0, i8* %18
%19 = icmp eq i32 %3, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %22
22: ; preds = %20, %15
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%24 = tail call i8* @strchr(i8* dereferenceable(1) %8, i8 signext 10)
%25 = icmp eq i8* %24, null
br i1 %25, label %37, label %26
26: ; preds = %22, %32
%27 = phi i8* [ %35, %32 ], [ %24, %22 ]
%28 = phi i8* [ %34, %32 ], [ %8, %22 ]
store i8 0, i8* %27
%29 = icmp eq i8* %28, %8
br i1 %29, label %32, label %30
30: ; preds = %26
%31 = tail call i64 @fwrite(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i64 2, i64 1, i32* %0)
br label %32
32: ; preds = %30, %26
%33 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* %28)
%34 = getelementptr inbounds i8, i8* %27, i64 1
%35 = tail call i8* @strchr(i8* dereferenceable(1) %34, i8 signext 10)
%36 = icmp eq i8* %35, null
br i1 %36, label %37, label %26
37: ; preds = %32, %22
%38 = tail call i64 @fwrite(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i64 3, i64 1, i32* %0)
%39 = tail call i32 @free(i8* %8)
br label %40
40: ; preds = %37, %10
ret void
}