#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 */
int atoi(char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
unsigned int *realloc(unsigned int *, int);
char *strtok(char *, char *);
int read_deg_seq(FILE *filein, unsigned int **nodes) {
  int size, N, k;
  char buff[256];
  char *ptr;
  N = 0;
  size = 10;
  *nodes = (unsigned int *)malloc(size * sizeof(unsigned int));
  while (fgets(buff, 256, filein)) {
    ptr = strtok(buff, " ");
    if (ptr[0] == '#')
      continue;
    k = atoi(ptr);
    if (N == size) {
      size += 10;
      *nodes = realloc(*nodes, size * sizeof(unsigned int));
    }
    (*nodes)[N] = k;
    N += 1;
  }
  *nodes = realloc(*nodes, N * sizeof(unsigned int));
  return N;
}


x86 assembly (clang, -O0):
<read_deg_seq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0xa,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x100,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
je     123e <read_deg_seq+0xee>
lea    -0x120(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x23,%eax
jne    11db <read_deg_seq+0x8b>
jmp    118a <read_deg_seq+0x3a>
mov    -0x128(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    121f <read_deg_seq+0xcf>
mov    -0x14(%rbp),%eax
add    $0xa,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x1c(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x18(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    118a <read_deg_seq+0x3a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_deg_seq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x118,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
mov    $0x28,%edi
call   1040 <malloc@plt>
mov    %rax,(%r14)
mov    $0xa,%ebp
xor    %r15d,%r15d
lea    0x10(%rsp),%rbx
lea    0xe78(%rip),%r13
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x100,%esi
mov    %r12,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     11f5 <read_deg_seq+0xa5>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <strtok@plt>
cmpb   $0x23,(%rax)
je     1190 <read_deg_seq+0x40>
mov    %rax,%rdi
call   1070 <atoi@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cmp    %rax,%r15
jne    11e8 <read_deg_seq+0x98>
mov    (%r14),%rdi
mov    %rbp,%rax
add    $0xa,%ebp
lea    0x28(,%rax,4),%esi
mov    %ecx,0xc(%rsp)
call   1050 <realloc@plt>
mov    0xc(%rsp),%ecx
mov    %rax,(%r14)
jmp    11eb <read_deg_seq+0x9b>
mov    (%r14),%rax
mov    %ecx,(%rax,%r15,4)
add    $0x1,%r15
jmp    1190 <read_deg_seq+0x40>
mov    (%r14),%rdi
lea    0x0(,%r15,4),%esi
call   1050 <realloc@plt>
mov    %rax,(%r14)
mov    %r15d,%eax
add    $0x118,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
define i32 @read_deg_seq(i32* %0, i32** %1) {
%3 = alloca i32*
%4 = alloca i32**
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [256 x i8]
%9 = alloca i8*
store i32* %0, i32** %3
store i32** %1, i32*** %4
store i32 0, i32* %6
store i32 10, i32* %5
%10 = load i32, i32* %5
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 4
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i32*
%16 = load i32**, i32*** %4
store i32* %15, i32** %16
br label %17
17: ; preds = %48, %30, %2
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%19 = load i32*, i32** %3
%20 = call i64 @fgets(i8* %18, i32 256, i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %57
22: ; preds = %17
%23 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%24 = call i8* @strtok(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %24, i8** %9
%25 = load i8*, i8** %9
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 35
br i1 %29, label %30, label %31
30: ; preds = %22
br label %17
31: ; preds = %22
%32 = load i8*, i8** %9
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %7
%34 = load i32, i32* %6
%35 = load i32, i32* %5
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %48
37: ; preds = %31
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 10
store i32 %39, i32* %5
%40 = load i32**, i32*** %4
%41 = load i32*, i32** %40
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = mul i64 %43, 4
%45 = trunc i64 %44 to i32
%46 = call i32* @realloc(i32* %41, i32 %45)
%47 = load i32**, i32*** %4
store i32* %46, i32** %47
br label %48
48: ; preds = %37, %31
%49 = load i32, i32* %7
%50 = load i32**, i32*** %4
%51 = load i32*, i32** %50
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
store i32 %49, i32* %54
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %17
57: ; preds = %17
%58 = load i32**, i32*** %4
%59 = load i32*, i32** %58
%60 = load i32, i32* %6
%61 = sext i32 %60 to i64
%62 = mul i64 %61, 4
%63 = trunc i64 %62 to i32
%64 = call i32* @realloc(i32* %59, i32 %63)
%65 = load i32**, i32*** %4
store i32* %64, i32** %65
%66 = load i32, i32* %6
ret i32 %66
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
define i32 @read_deg_seq(i32* nocapture %0, i32** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @malloc(i32 40)
%6 = inttoptr i64 %5 to i32*
store i32* %6, i32** %1
br label %7
7: ; preds = %28, %2
%8 = phi i64 [ %32, %28 ], [ 0, %2 ]
%9 = phi i32 [ %30, %28 ], [ 10, %2 ]
br label %10
10: ; preds = %7, %13
%11 = call i64 @fgets(i8* %4, i32 256, i32* %0)
%12 = icmp eq i64 %11, 0
br i1 %12, label %33, label %13
13: ; preds = %10
%14 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 35
br i1 %16, label %10, label %17
17: ; preds = %13
%18 = call i32 @atoi(i8* %14)
%19 = zext i32 %9 to i64
%20 = icmp eq i64 %8, %19
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = load i32*, i32** %1
br label %28
23: ; preds = %17
%24 = add nsw i32 %9, 10
%25 = load i32*, i32** %1
%26 = shl i32 %24, 2
%27 = call i32* @realloc(i32* %25, i32 %26)
store i32* %27, i32** %1
br label %28
28: ; preds = %21, %23
%29 = phi i32* [ %27, %23 ], [ %22, %21 ]
%30 = phi i32 [ %24, %23 ], [ %9, %21 ]
%31 = getelementptr inbounds i32, i32* %29, i64 %8
store i32 %18, i32* %31
%32 = add nuw i64 %8, 1
br label %7
33: ; preds = %10
%34 = trunc i64 %8 to i32
%35 = load i32*, i32** %1
%36 = shl i32 %34, 2
%37 = call i32* @realloc(i32* %35, i32 %36)
store i32* %37, i32** %1
ret i32 %34
}