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

/* Variables and functions */
int atoi(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ strsep(char **, char *);
int readNextBlockDimension(int *dim, FILE *store) {
  char *line = NULL;
  char *ptr = NULL;
  size_t len = 0;
  ssize_t read;
  if ((read = getline(&line, &len, store)) != -1) {
    ptr = line;
    strsep(&line, "#");
    dim[0] = atoi(strsep(&line, ","));
    dim[1] = atoi(strsep(&line, ","));
    dim[2] = atoi(strsep(&line, ","));
    dim[3] = atoi(strsep(&line, ","));
    return 0;
  } else {
    return -1;
  }
  free(ptr);
}


x86 assembly (clang, -O0):
<readNextBlockDimension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1050 <getline@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1218 <readNextBlockDimension+0xe8>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xe78(%rip),%rsi
call   1030 <strsep@plt>
lea    -0x20(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1030 <strsep@plt>
mov    %eax,%edi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x20(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1030 <strsep@plt>
mov    %eax,%edi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
lea    -0x20(%rbp),%rdi
lea    0xe2b(%rip),%rsi
call   1030 <strsep@plt>
mov    %eax,%edi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
lea    -0x20(%rbp),%rdi
lea    0xe0b(%rip),%rsi
call   1030 <strsep@plt>
mov    %eax,%edi
call   1040 <atoi@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
movl   $0x0,-0x4(%rbp)
jmp    121f <readNextBlockDimension+0xef>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readNextBlockDimension>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rdx
mov    %rdi,%rbx
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rsp,%rdi
lea    0x8(%rsp),%rsi
call   1050 <getline@plt>
cmp    $0xffffffff,%eax
je     11d2 <readNextBlockDimension+0xa2>
lea    0xe97(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
call   1030 <strsep@plt>
lea    0xe87(%rip),%r15
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strsep@plt>
mov    %eax,%edi
call   1040 <atoi@plt>
mov    %eax,(%rbx)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strsep@plt>
mov    %eax,%edi
call   1040 <atoi@plt>
mov    %eax,0x4(%rbx)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strsep@plt>
mov    %eax,%edi
call   1040 <atoi@plt>
mov    %eax,0x8(%rbx)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <strsep@plt>
mov    %eax,%edi
call   1040 <atoi@plt>
mov    %eax,0xc(%rbx)
xor    %eax,%eax
jmp    11d7 <readNextBlockDimension+0xa7>
mov    $0xffffffff,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"#\00"
@.str.1 = [2 x i8] c",\00"
define i32 @readNextBlockDimension(i32* nocapture writeonly %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%6 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%7 = call i32 @getline(i8** %3, i64* %4, i32* %1)
%8 = icmp eq i32 %7, -1
br i1 %8, label %22, label %9
9: ; preds = %2
%10 = call i32 @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @atoi(i32 %11)
store i32 %12, i32* %0
%13 = call i32 @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @atoi(i32 %13)
%15 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %14, i32* %15
%16 = call i32 @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @atoi(i32 %16)
%18 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %17, i32* %18
%19 = call i32 @strsep(i8** %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = call i32 @atoi(i32 %19)
%21 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %20, i32* %21
br label %22
22: ; preds = %2, %9
%23 = phi i32 [ 0, %9 ], [ -1, %2 ]
ret i32 %23
}