#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 size_t uint32_t;

/* Variables and functions */
size_t *calloc(size_t, int);
size_t strtoint(char *);
char *strtok(char *, char *);
uint32_t *readVertices(char *line, uint32_t ls) {
  uint32_t *vert = calloc(ls, sizeof(uint32_t));
  char *s;
  for (uint32_t i = 0; (s = strtok(line, ",")); i++) {
    vert[i] = strtoint(s);
    if (vert[i] == 0) {
      vert[i] = -1;
    }
    line = NULL;
  }
  return vert;
}


x86 assembly (clang, -O0):
<readVertices>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1050 <strtok@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11cc <readVertices+0x9c>
mov    -0x20(%rbp),%rdi
call   1030 <strtoint@plt>
mov    %rax,%rdx
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    11b3 <readVertices+0x83>
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movq   $0xffffffffffffffff,(%rax,%rcx,8)
ff
movq   $0x0,-0x8(%rbp)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    115a <readVertices+0x2a>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readVertices>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    $0x8,%esi
call   1040 <calloc@plt>
mov    %rax,%r14
lea    0xeb1(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strtok@plt>
test   %rax,%rax
je     1198 <readVertices+0x68>
lea    0xe9d(%rip),%r15
mov    %r14,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rax,%rdi
call   1030 <strtoint@plt>
cmp    $0x1,%rax
sbb    %rcx,%rcx
or     %rax,%rcx
mov    %rcx,(%rbx)
xor    %edi,%edi
mov    %r15,%rsi
call   1050 <strtok@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    1170 <readVertices+0x40>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [2 x i8] c",\00"
define i64* @readVertices(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64*
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
%8 = load i64, i64* %4
%9 = call i64* @calloc(i64 %8, i32 8)
store i64* %9, i64** %5
store i64 0, i64* %7
br label %10
10: ; preds = %30, %2
%11 = load i8*, i8** %3
%12 = call i8* @strtok(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %12, i8** %6
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %33
14: ; preds = %10
%15 = load i8*, i8** %6
%16 = call i64 @strtoint(i8* %15)
%17 = load i64*, i64** %5
%18 = load i64, i64* %7
%19 = getelementptr inbounds i64, i64* %17, i64 %18
store i64 %16, i64* %19
%20 = load i64*, i64** %5
%21 = load i64, i64* %7
%22 = getelementptr inbounds i64, i64* %20, i64 %21
%23 = load i64, i64* %22
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %14
%26 = load i64*, i64** %5
%27 = load i64, i64* %7
%28 = getelementptr inbounds i64, i64* %26, i64 %27
store i64 -1, i64* %28
br label %29
29: ; preds = %25, %14
store i8* null, i8** %3
br label %30
30: ; preds = %29
%31 = load i64, i64* %7
%32 = add i64 %31, 1
store i64 %32, i64* %7
br label %10
33: ; preds = %10
%34 = load i64*, i64** %5
ret i64* %34
}

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define i64* @readVertices(i8* %0, i64 %1) {
%3 = tail call i64* @calloc(i64 %1, i32 8)
%4 = tail call i8* @strtok(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %7, %2
ret i64* %3
7: ; preds = %2, %7
%8 = phi i8* [ %15, %7 ], [ %4, %2 ]
%9 = phi i64 [ %14, %7 ], [ 0, %2 ]
%10 = tail call i64 @strtoint(i8* %8)
%11 = getelementptr inbounds i64, i64* %3, i64 %9
%12 = icmp eq i64 %10, 0
%13 = select i1 %12, i64 -1, i64 %10
store i64 %13, i64* %11
%14 = add i64 %9, 1
%15 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%16 = icmp eq i8* %15, null
br i1 %16, label %6, label %7
}