#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 */
struct dbg_line {
  int dummy;
};

/* Variables and functions */
struct dbg_line **malloc(int);
struct dbg_line **realloc(struct dbg_line **, int);
int add_rec(struct dbg_line *line, struct dbg_line ***linevp, int *lenp,
            int used) {
  struct dbg_line **linev = *linevp;
  if (used == *lenp) {
    int nlen = *lenp + 512;
    int nsize = nlen * sizeof(struct dbg_line *);
    linev = *linevp ? realloc(*linevp, nsize) : malloc(nsize);
    if (!linev)
      return 0;
    *linevp = linev;
    *lenp = nlen;
  }
  linev[used] = line;
  return 1;
}


x86 assembly (clang, -O0):
<add_rec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jne    11cf <add_rec+0xaf>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
add    $0x200,%eax
mov    %eax,-0x34(%rbp)
movslq -0x34(%rbp),%rax
shl    $0x3,%rax
mov    %eax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
cmpq   $0x0,(%rax)
je     1190 <add_rec+0x70>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x38(%rbp),%esi
call   1040 <realloc@plt>
mov    %rax,-0x40(%rbp)
jmp    119c <add_rec+0x7c>
mov    -0x38(%rbp),%edi
call   1030 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11bb <add_rec+0x9b>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <add_rec+0xc6>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x34(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdx
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_rec>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %rdi,%r14
mov    (%rsi),%rax
cmp    %ecx,(%rdx)
jne    1160 <add_rec+0x40>
mov    %rdx,%r15
mov    %rsi,%r12
lea    0x1000(,%rbx,8),%esi
test   %rax,%rax
je     116e <add_rec+0x4e>
mov    %rax,%rdi
call   1040 <realloc@plt>
test   %rax,%rax
je     117a <add_rec+0x5a>
lea    0x200(%rbx),%ecx
mov    %rax,(%r12)
mov    %ecx,(%r15)
movslq %ebx,%rcx
mov    %r14,(%rax,%rcx,8)
mov    $0x1,%eax
jmp    117c <add_rec+0x5c>
mov    %esi,%edi
call   1030 <malloc@plt>
test   %rax,%rax
jne    1153 <add_rec+0x33>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.dbg_line = type { i32 }
define i32 @add_rec(%struct.dbg_line* %0, %struct.dbg_line*** %1, i32* %2, i32 %3) {
%5 = alloca i32
%6 = alloca %struct.dbg_line*
%7 = alloca %struct.dbg_line***
%8 = alloca i32*
%9 = alloca i32
%10 = alloca %struct.dbg_line**
%11 = alloca i32
%12 = alloca i32
store %struct.dbg_line* %0, %struct.dbg_line** %6
store %struct.dbg_line*** %1, %struct.dbg_line**** %7
store i32* %2, i32** %8
store i32 %3, i32* %9
%13 = load %struct.dbg_line***, %struct.dbg_line**** %7
%14 = load %struct.dbg_line**, %struct.dbg_line*** %13
store %struct.dbg_line** %14, %struct.dbg_line*** %10
%15 = load i32, i32* %9
%16 = load i32*, i32** %8
%17 = load i32, i32* %16
%18 = icmp eq i32 %15, %17
br i1 %18, label %19, label %48
19: ; preds = %4
%20 = load i32*, i32** %8
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 512
store i32 %22, i32* %11
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = mul i64 %24, 8
%26 = trunc i64 %25 to i32
store i32 %26, i32* %12
%27 = load %struct.dbg_line***, %struct.dbg_line**** %7
%28 = load %struct.dbg_line**, %struct.dbg_line*** %27
%29 = icmp ne %struct.dbg_line** %28, null
br i1 %29, label %30, label %35
30: ; preds = %19
%31 = load %struct.dbg_line***, %struct.dbg_line**** %7
%32 = load %struct.dbg_line**, %struct.dbg_line*** %31
%33 = load i32, i32* %12
%34 = call %struct.dbg_line** @realloc(%struct.dbg_line** %32, i32 %33)
br label %38
35: ; preds = %19
%36 = load i32, i32* %12
%37 = call %struct.dbg_line** @malloc(i32 %36)
br label %38
38: ; preds = %35, %30
%39 = phi %struct.dbg_line** [ %34, %30 ], [ %37, %35 ]
store %struct.dbg_line** %39, %struct.dbg_line*** %10
%40 = load %struct.dbg_line**, %struct.dbg_line*** %10
%41 = icmp ne %struct.dbg_line** %40, null
br i1 %41, label %43, label %42
42: ; preds = %38
store i32 0, i32* %5
br label %54
43: ; preds = %38
%44 = load %struct.dbg_line**, %struct.dbg_line*** %10
%45 = load %struct.dbg_line***, %struct.dbg_line**** %7
store %struct.dbg_line** %44, %struct.dbg_line*** %45
%46 = load i32, i32* %11
%47 = load i32*, i32** %8
store i32 %46, i32* %47
br label %48
48: ; preds = %43, %4
%49 = load %struct.dbg_line*, %struct.dbg_line** %6
%50 = load %struct.dbg_line**, %struct.dbg_line*** %10
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds %struct.dbg_line*, %struct.dbg_line** %50, i64 %52
store %struct.dbg_line* %49, %struct.dbg_line** %53
store i32 1, i32* %5
br label %54
54: ; preds = %48, %42
%55 = load i32, i32* %5
ret i32 %55
}

LLVM IR (-O2):
%struct.dbg_line = type { i32 }
define i32 @add_rec(%struct.dbg_line* %0, %struct.dbg_line*** nocapture %1, i32* nocapture %2, i32 %3) {
%5 = load %struct.dbg_line**, %struct.dbg_line*** %1
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, %3
br i1 %7, label %8, label %20
8: ; preds = %4
%9 = add nsw i32 %3, 512
%10 = shl i32 %9, 3
%11 = icmp eq %struct.dbg_line** %5, null
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = tail call %struct.dbg_line** @realloc(%struct.dbg_line** %5, i32 %10)
br label %16
14: ; preds = %8
%15 = tail call %struct.dbg_line** @malloc(i32 %10)
br label %16
16: ; preds = %14, %12
%17 = phi %struct.dbg_line** [ %13, %12 ], [ %15, %14 ]
%18 = icmp eq %struct.dbg_line** %17, null
br i1 %18, label %24, label %19
19: ; preds = %16
store %struct.dbg_line** %17, %struct.dbg_line*** %1
store i32 %9, i32* %2
br label %20
20: ; preds = %19, %4
%21 = phi %struct.dbg_line** [ %17, %19 ], [ %5, %4 ]
%22 = sext i32 %3 to i64
%23 = getelementptr inbounds %struct.dbg_line*, %struct.dbg_line** %21, i64 %22
store %struct.dbg_line* %0, %struct.dbg_line** %23
br label %24
24: ; preds = %16, %20
%25 = phi i32 [ 1, %20 ], [ 0, %16 ]
ret i32 %25
}