#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 int32_t;

/* Variables and functions */
int atoi(char const *const);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(void *);
int *malloc(int);
int sscanf(char const *, char *, int *);
int /*<<< orphan*/ stderr;
char *strchr(char const *, char);
int parse_slice_specification(const char *const arg, int32_t *const nslices,
                              int32_t **const array) {
  const char *current_arg = NULL;
  int32_t current_value;
  int32_t values[16];
  int i;
  if (*array) {
    {
      free((void *)*array);
      *array = NULL;
    };
  }
  if (arg[0] == 'u') {
    *nslices = atoi(arg + 1);
    if (16 <= *nslices || 0 >= *nslices) {
      fprintf(stderr,
              "Invalid number of tiles (0 < %d <= %d = KVZ_MAX_SLICES)!\n",
              *nslices + 1, 16);
      return 0;
    }
    return 1;
  }
  current_arg = arg;
  values[0] = 0;
  *nslices = 1;
  do {
    int ret = sscanf(current_arg, "%d", &current_value);
    if (ret != 1) {
      fprintf(stderr, "Could not parse integer \"%s\"!\n", current_arg);
      return 0;
    }
    current_arg = strchr(current_arg, ',');
    if (current_arg)
      ++current_arg;
    values[*nslices] = current_value;
    ++(*nslices);
    if (16 <= *nslices)
      break;
  } while (current_arg);
  if (16 <= *nslices || 0 >= *nslices) {
    fprintf(stderr,
            "Invalid number of slices (0 < %d <= %d = KVZ_MAX_SLICES)!\n",
            *nslices, 16);
    return 0;
  }
  *array = malloc(sizeof(int32_t) * (*nslices));
  if (!*array) {
    fprintf(stderr, "Could not allocate array for slices\n");
    return 0;
  }
  for (i = 0; i < *nslices; ++i) {
    (*array)[i] = values[i];
  }
  return 1;
}


x86 assembly (clang, -O0):
<parse_slice_specification>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     11a4 <parse_slice_specification+0x44>
mov    -0x20(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x75,%eax
jne    1225 <parse_slice_specification+0xc5>
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
call   1080 <atoi@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rcx
mov    $0x10,%eax
cmp    (%rcx),%eax
jle    11e8 <parse_slice_specification+0x88>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%eax
jl     1219 <parse_slice_specification+0xb9>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
add    $0x1,%edx
lea    0xdff(%rip),%rsi
mov    $0x10,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13c9 <parse_slice_specification+0x269>
movl   $0x1,-0x4(%rbp)
jmp    13c9 <parse_slice_specification+0x269>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x70(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x28(%rbp),%rdi
lea    0xdf1(%rip),%rsi
lea    -0x2c(%rbp),%rdx
call   1070 <sscanf@plt>
mov    %eax,-0x78(%rbp)
cmpl   $0x1,-0x78(%rbp)
je     1286 <parse_slice_specification+0x126>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
lea    0xdca(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13c9 <parse_slice_specification+0x269>
mov    -0x28(%rbp),%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12af <parse_slice_specification+0x14f>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x2c(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq (%rax),%rax
mov    %ecx,-0x70(%rbp,%rax,4)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rcx
mov    $0x10,%eax
cmp    (%rcx),%eax
jg     12de <parse_slice_specification+0x17e>
jmp    12ee <parse_slice_specification+0x18e>
jmp    12e3 <parse_slice_specification+0x183>
cmpq   $0x0,-0x28(%rbp)
jne    123e <parse_slice_specification+0xde>
mov    -0x18(%rbp),%rcx
mov    $0x10,%eax
cmp    (%rcx),%eax
jle    130d <parse_slice_specification+0x1ad>
mov    -0x18(%rbp),%rcx
xor    %eax,%eax
cmp    (%rcx),%eax
jl     133b <parse_slice_specification+0x1db>
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xd39(%rip),%rsi
mov    $0x10,%ecx
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13c9 <parse_slice_specification+0x269>
mov    -0x18(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1388 <parse_slice_specification+0x228>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
lea    0xd22(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    13c9 <parse_slice_specification+0x269>
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    -0x18(%rbp),%rcx
cmp    (%rcx),%eax
jge    13c2 <parse_slice_specification+0x262>
movslq -0x74(%rbp),%rax
mov    -0x70(%rbp,%rax,4),%edx
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movslq -0x74(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    138f <parse_slice_specification+0x22f>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_slice_specification>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    (%rdx),%rdi
test   %rdi,%rdi
je     119b <parse_slice_specification+0x2b>
call   1030 <free@plt>
movq   $0x0,(%r14)
cmpb   $0x75,(%rbx)
jne    11de <parse_slice_specification+0x6e>
add    $0x1,%rbx
mov    %rbx,%rdi
call   1090 <atoi@plt>
mov    %eax,(%r15)
lea    -0x10(%rax),%ecx
mov    $0x1,%r14d
cmp    $0xfffffff0,%ecx
ja     12d7 <parse_slice_specification+0x167>
mov    0x2e18(%rip),%rcx
mov    (%rcx),%edi
add    $0x1,%eax
lea    0xe2c(%rip),%rsi
xor    %r14d,%r14d
mov    %eax,%edx
jmp    1261 <parse_slice_specification+0xf1>
movl   $0x0,0x10(%rsp)
movl   $0x1,(%r15)
lea    0xe46(%rip),%r12
lea    0xc(%rsp),%r13
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    126f <parse_slice_specification+0xff>
mov    %rbx,%rdi
mov    $0x2c,%esi
call   1040 <strchr@plt>
lea    0x1(%rax),%rbx
test   %rax,%rax
cmove  %rax,%rbx
mov    0xc(%rsp),%edx
movslq (%r15),%rcx
lea    0x1(%rcx),%ebp
mov    %edx,0x10(%rsp,%rcx,4)
mov    %ebp,(%r15)
cmp    $0xe,%rcx
jg     1247 <parse_slice_specification+0xd7>
test   %rax,%rax
jne    1200 <parse_slice_specification+0x90>
cmp    $0xf,%ecx
jb     128e <parse_slice_specification+0x11e>
mov    0x2d8d(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
xor    %r14d,%r14d
mov    %ebp,%edx
mov    $0x10,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    12d7 <parse_slice_specification+0x167>
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
lea    0xdbe(%rip),%rsi
xor    %r14d,%r14d
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    12d7 <parse_slice_specification+0x167>
lea    0x0(,%rbp,4),%edi
call   1070 <malloc@plt>
mov    %rax,(%r14)
test   %rax,%rax
je     12bd <parse_slice_specification+0x14d>
mov    %ebp,%edx
shl    $0x2,%rdx
lea    0x10(%rsp),%rsi
mov    %rax,%rdi
call   1060 <memcpy@plt>
mov    $0x1,%r14d
jmp    12d7 <parse_slice_specification+0x167>
mov    0x2d1c(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    %r14d,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [58 x i8] c"Invalid number of tiles (0 < %d <= %d = KVZ_MAX_SLICES)!\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Could not parse integer \22%s\22!\0A\00"
@.str.3 = [59 x i8] c"Invalid number of slices (0 < %d <= %d = KVZ_MAX_SLICES)!\0A\00"
@.str.4 = [37 x i8] c"Could not allocate array for slices\0A\00"
define i32 @parse_slice_specification(i8* %0, i32* %1, i32** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32**
%8 = alloca i8*
%9 = alloca i32
%10 = alloca [16 x i32]
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i32* %1, i32** %6
store i32** %2, i32*** %7
store i8* null, i8** %8
%13 = load i32**, i32*** %7
%14 = load i32*, i32** %13
%15 = icmp ne i32* %14, null
br i1 %15, label %16, label %22
16: ; preds = %3
%17 = load i32**, i32*** %7
%18 = load i32*, i32** %17
%19 = bitcast i32* %18 to i8*
%20 = call i32 @free(i8* %19)
%21 = load i32**, i32*** %7
store i32* null, i32** %21
br label %22
22: ; preds = %16, %3
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 117
br i1 %27, label %28, label %47
28: ; preds = %22
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i64 1
%31 = call i32 @atoi(i8* %30)
%32 = load i32*, i32** %6
store i32 %31, i32* %32
%33 = load i32*, i32** %6
%34 = load i32, i32* %33
%35 = icmp sle i32 16, %34
br i1 %35, label %40, label %36
36: ; preds = %28
%37 = load i32*, i32** %6
%38 = load i32, i32* %37
%39 = icmp sge i32 0, %38
br i1 %39, label %40, label %46
40: ; preds = %36, %28
%41 = load i32, i32* @stderr
%42 = load i32*, i32** %6
%43 = load i32, i32* %42
%44 = add nsw i32 %43, 1
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %44, i32 16)
store i32 0, i32* %4
br label %132
46: ; preds = %36
store i32 1, i32* %4
br label %132
47: ; preds = %22
%48 = load i8*, i8** %5
store i8* %48, i8** %8
%49 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 0
store i32 0, i32* %49
%50 = load i32*, i32** %6
store i32 1, i32* %50
br label %51
51: ; preds = %82, %47
%52 = load i8*, i8** %8
%53 = call i32 @sscanf(i8* %52, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %9)
store i32 %53, i32* %12
%54 = load i32, i32* %12
%55 = icmp ne i32 %54, 1
br i1 %55, label %56, label %60
56: ; preds = %51
%57 = load i32, i32* @stderr
%58 = load i8*, i8** %8
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %58)
store i32 0, i32* %4
br label %132
60: ; preds = %51
%61 = load i8*, i8** %8
%62 = call i8* @strchr(i8* %61, i8 signext 44)
store i8* %62, i8** %8
%63 = load i8*, i8** %8
%64 = icmp ne i8* %63, null
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = load i8*, i8** %8
%67 = getelementptr inbounds i8, i8* %66, i32 1
store i8* %67, i8** %8
br label %68
68: ; preds = %65, %60
%69 = load i32, i32* %9
%70 = load i32*, i32** %6
%71 = load i32, i32* %70
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 %72
store i32 %69, i32* %73
%74 = load i32*, i32** %6
%75 = load i32, i32* %74
%76 = add nsw i32 %75, 1
store i32 %76, i32* %74
%77 = load i32*, i32** %6
%78 = load i32, i32* %77
%79 = icmp sle i32 16, %78
br i1 %79, label %80, label %81
80: ; preds = %68
br label %85
81: ; preds = %68
br label %82
82: ; preds = %81
%83 = load i8*, i8** %8
%84 = icmp ne i8* %83, null
br i1 %84, label %51, label %85
85: ; preds = %82, %80
%86 = load i32*, i32** %6
%87 = load i32, i32* %86
%88 = icmp sle i32 16, %87
br i1 %88, label %93, label %89
89: ; preds = %85
%90 = load i32*, i32** %6
%91 = load i32, i32* %90
%92 = icmp sge i32 0, %91
br i1 %92, label %93, label %98
93: ; preds = %89, %85
%94 = load i32, i32* @stderr
%95 = load i32*, i32** %6
%96 = load i32, i32* %95
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i32 %96, i32 16)
store i32 0, i32* %4
br label %132
98: ; preds = %89
%99 = load i32*, i32** %6
%100 = load i32, i32* %99
%101 = sext i32 %100 to i64
%102 = mul i64 4, %101
%103 = trunc i64 %102 to i32
%104 = call i32* @malloc(i32 %103)
%105 = load i32**, i32*** %7
store i32* %104, i32** %105
%106 = load i32**, i32*** %7
%107 = load i32*, i32** %106
%108 = icmp ne i32* %107, null
br i1 %108, label %112, label %109
109: ; preds = %98
%110 = load i32, i32* @stderr
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %110, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %4
br label %132
112: ; preds = %98
store i32 0, i32* %11
br label %113
113: ; preds = %128, %112
%114 = load i32, i32* %11
%115 = load i32*, i32** %6
%116 = load i32, i32* %115
%117 = icmp slt i32 %114, %116
br i1 %117, label %118, label %131
118: ; preds = %113
%119 = load i32, i32* %11
%120 = sext i32 %119 to i64
%121 = getelementptr inbounds [16 x i32], [16 x i32]* %10, i64 0, i64 %120
%122 = load i32, i32* %121
%123 = load i32**, i32*** %7
%124 = load i32*, i32** %123
%125 = load i32, i32* %11
%126 = sext i32 %125 to i64
%127 = getelementptr inbounds i32, i32* %124, i64 %126
store i32 %122, i32* %127
br label %128
128: ; preds = %118
%129 = load i32, i32* %11
%130 = add nsw i32 %129, 1
store i32 %130, i32* %11
br label %113
131: ; preds = %113
store i32 1, i32* %4
br label %132
132: ; preds = %131, %109, %93, %56, %46, %40
%133 = load i32, i32* %4
ret i32 %133
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [58 x i8] c"Invalid number of tiles (0 < %d <= %d = KVZ_MAX_SLICES)!\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [31 x i8] c"Could not parse integer \22%s\22!\0A\00"
@.str.3 = [59 x i8] c"Invalid number of slices (0 < %d <= %d = KVZ_MAX_SLICES)!\0A\00"
@.str.4 = [37 x i8] c"Could not allocate array for slices\0A\00"
define i32 @parse_slice_specification(i8* %0, i32* nocapture %1, i32** nocapture %2) {
%4 = alloca i32
%5 = alloca [16 x i32]
%6 = bitcast [16 x i32]* %5 to i8*
%7 = bitcast i32* %4 to i8*
%8 = load i32*, i32** %2
%9 = icmp eq i32* %8, null
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = bitcast i32* %8 to i8*
%12 = tail call i32 @free(i8* %11)
store i32* null, i32** %2
br label %13
13: ; preds = %10, %3
%14 = load i8, i8* %0
%15 = icmp eq i8 %14, 117
br i1 %15, label %16, label %25
16: ; preds = %13
%17 = getelementptr inbounds i8, i8* %0, i64 1
%18 = tail call i32 @atoi(i8* %17)
store i32 %18, i32* %1
%19 = add i32 %18, -16
%20 = icmp ult i32 %19, -15
br i1 %20, label %21, label %62
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = add nsw i32 %18, 1
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %23, i32 16)
br label %62
25: ; preds = %13
%26 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
store i32 0, i32* %26
store i32 1, i32* %1
br label %27
27: ; preds = %34, %25
%28 = phi i8* [ %0, %25 ], [ %38, %34 ]
%29 = call i32 @sscanf(i8* %28, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%30 = icmp eq i32 %29, 1
br i1 %30, label %34, label %31
31: ; preds = %27
%32 = load i32, i32* @stderr
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %32, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %28)
br label %62
34: ; preds = %27
%35 = call i8* @strchr(i8* dereferenceable(1) %28, i8 signext 44)
%36 = icmp eq i8* %35, null
%37 = getelementptr inbounds i8, i8* %35, i64 1
%38 = select i1 %36, i8* null, i8* %37
%39 = load i32, i32* %4
%40 = load i32, i32* %1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 %41
store i32 %39, i32* %42
%43 = add nsw i32 %40, 1
store i32 %43, i32* %1
%44 = icmp sgt i32 %40, 14
%45 = select i1 %44, i1 true, i1 %36
br i1 %45, label %46, label %27
46: ; preds = %34
%47 = icmp ugt i32 %40, 14
br i1 %47, label %48, label %51
48: ; preds = %46
%49 = load i32, i32* @stderr
%50 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.3, i64 0, i64 0), i32 %43, i32 16)
br label %62
51: ; preds = %46
%52 = shl nuw nsw i32 %43, 2
%53 = call i32* @malloc(i32 %52)
store i32* %53, i32** %2
%54 = icmp eq i32* %53, null
br i1 %54, label %59, label %55
55: ; preds = %51
%56 = bitcast i32* %53 to i8*
%57 = zext i32 %43 to i64
%58 = shl nuw nsw i64 %57, 2
br label %62
59: ; preds = %51
%60 = load i32, i32* @stderr
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %60, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %55, %31, %16, %59, %48, %21
%63 = phi i32 [ 0, %21 ], [ 0, %48 ], [ 0, %59 ], [ 1, %16 ], [ 0, %31 ], [ 1, %55 ]
ret i32 %63
}