#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 */

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *);
int sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stringafterstring(char *, char *, char *);
int stringpos(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int getintegervect(char *s1, char *arg, int n, int ivect[n]) {
  int i, nchar, slen;
  char temp[62];
  int pos;
  pos = stringpos(s1, arg);
  stringafterstring(s1, "=", temp);
  for (i = 0; i < n; i++) {
    slen = strlen(temp);
    if (sscanf(temp, "%d%n", &ivect[i], &nchar) != 1) {
      printf("ERROR: wrong values for -xmat option!\n");
      exit(-1);
    }
    strncpy(temp, temp + nchar + 1, slen);
  }
  return (0);
}


x86 assembly (clang, -O0):
<getintegervect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <stringpos@plt>
mov    %eax,-0x74(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x70(%rbp),%rdx
lea    0xe57(%rip),%rsi
call   1060 <stringafterstring@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1238 <getintegervect+0xc8>
lea    -0x70(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x20(%rbp),%rdx
movslq -0x24(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xe1b(%rip),%rsi
lea    -0x28(%rbp),%rcx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
je     120f <getintegervect+0x9f>
lea    0xe07(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
lea    -0x70(%rbp),%rdi
lea    -0x70(%rbp),%rsi
movslq -0x28(%rbp),%rax
add    %rax,%rsi
add    $0x1,%rsi
mov    -0x2c(%rbp),%edx
call   1030 <strncpy@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11b5 <getintegervect+0x45>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getintegervect>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rcx,%r13
mov    %edx,%r14d
mov    %rdi,%rbp
call   1070 <stringpos@plt>
lea    0xe6d(%rip),%rsi
lea    0x10(%rsp),%rdx
mov    %rbp,%rdi
call   1060 <stringafterstring@plt>
test   %r14d,%r14d
jle    1201 <getintegervect+0x91>
mov    %r14d,%ebx
lea    0x10(%rsp),%r14
lea    0xe4e(%rip),%r15
lea    0xc(%rsp),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r13,%rdx
mov    %r12,%rcx
call   1080 <sscanf@plt>
cmp    $0x1,%eax
jne    1212 <getintegervect+0xa2>
movslq 0xc(%rsp),%rax
lea    (%rsp,%rax,1),%rsi
add    $0x11,%rsi
mov    %r14,%rdi
mov    %ebp,%edx
call   1030 <strncpy@plt>
add    $0x4,%r13
add    $0xffffffffffffffff,%rbx
jne    11c0 <getintegervect+0x50>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdee(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"=\00"
@.str.1 = [5 x i8] c"%d%n\00"
@.str.2 = [39 x i8] c"ERROR: wrong values for -xmat option!\0A\00"
define i32 @getintegervect(i8* %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [62 x i8]
%13 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%14 = load i32, i32* %7
%15 = zext i32 %14 to i64
%16 = load i8*, i8** %5
%17 = load i8*, i8** %6
%18 = call i32 @stringpos(i8* %16, i8* %17)
store i32 %18, i32* %13
%19 = load i8*, i8** %5
%20 = getelementptr inbounds [62 x i8], [62 x i8]* %12, i64 0, i64 0
%21 = call i32 @stringafterstring(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %20)
store i32 0, i32* %9
br label %22
22: ; preds = %48, %4
%23 = load i32, i32* %9
%24 = load i32, i32* %7
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %51
26: ; preds = %22
%27 = getelementptr inbounds [62 x i8], [62 x i8]* %12, i64 0, i64 0
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %11
%29 = getelementptr inbounds [62 x i8], [62 x i8]* %12, i64 0, i64 0
%30 = load i32*, i32** %8
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %30, i64 %32
%34 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %33, i32* %10)
%35 = icmp ne i32 %34, 1
br i1 %35, label %36, label %39
36: ; preds = %26
%37 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%38 = call i32 @exit(i32 -1)
unreachable
39: ; preds = %26
%40 = getelementptr inbounds [62 x i8], [62 x i8]* %12, i64 0, i64 0
%41 = getelementptr inbounds [62 x i8], [62 x i8]* %12, i64 0, i64 0
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = getelementptr inbounds i8, i8* %44, i64 1
%46 = load i32, i32* %11
%47 = call i32 @strncpy(i8* %40, i8* %45, i32 %46)
br label %48
48: ; preds = %39
%49 = load i32, i32* %9
%50 = add nsw i32 %49, 1
store i32 %50, i32* %9
br label %22
51: ; preds = %22
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"=\00"
@.str.1 = [5 x i8] c"%d%n\00"
@str = [38 x i8] c"ERROR: wrong values for -xmat option!\00"
define i32 @getintegervect(i8* %0, i8* %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca [62 x i8]
%7 = bitcast i32* %5 to i8*
%8 = getelementptr inbounds [62 x i8], [62 x i8]* %6, i64 0, i64 0
%9 = tail call i32 @stringpos(i8* %0, i8* %1)
%10 = call i32 @stringafterstring(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8* %8)
%11 = icmp sgt i32 %2, 0
br i1 %11, label %12, label %31
12: ; preds = %4
%13 = zext i32 %2 to i64
br label %14
14: ; preds = %12, %23
%15 = phi i64 [ 0, %12 ], [ %29, %23 ]
%16 = call i32 @strlen(i8* %8)
%17 = getelementptr inbounds i32, i32* %3, i64 %15
%18 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %17, i32* %5)
%19 = icmp eq i32 %18, 1
br i1 %19, label %23, label %20
20: ; preds = %14
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%22 = call i32 @exit(i32 -1)
unreachable
23: ; preds = %14
%24 = load i32, i32* %5
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [62 x i8], [62 x i8]* %6, i64 0, i64 %25
%27 = getelementptr inbounds i8, i8* %26, i64 1
%28 = call i32 @strncpy(i8* %8, i8* %27, i32 %16)
%29 = add nuw nsw i64 %15, 1
%30 = icmp eq i64 %29, %13
br i1 %30, label %31, label %14
31: ; preds = %23, %4
ret i32 0
}