#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 */
scalar_t__ isspace(char const);
int /*<<< orphan*/ memset(unsigned int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strlen(char const *);
char *strstr(char const *, char const *);
unsigned int strtoul(char const *, char **, int /*<<< orphan*/);
void read_values(const char *buffer, const char *prefix, unsigned int *values,
                 int count) {
  int i;
  buffer = strstr(buffer, prefix);
  if (buffer != NULL) {
    buffer += strlen(prefix);
    for (i = 0; i < count; i++) {
      while (isspace(*buffer)) {
        buffer++;
      }
      if (*buffer != '\0') {
        values[i] = strtoul(buffer, (char **)&buffer, 0);
      } else {
        values[i] = 0;
      }
    }
  } else {
    memset(values, 0, count * sizeof(unsigned int));
  }
}


x86 assembly (clang, -O0):
<read_values>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <strstr@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1233 <read_values+0xe3>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    122e <read_values+0xde>
jmp    11b4 <read_values+0x64>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     11db <read_values+0x8b>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b4 <read_values+0x64>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     120c <read_values+0xbc>
mov    -0x8(%rbp),%rdi
lea    -0x8(%rbp),%rsi
xor    %edx,%edx
call   1060 <strtoul@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    121b <read_values+0xcb>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    1220 <read_values+0xd0>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11a3 <read_values+0x53>
jmp    1248 <read_values+0xf8>
mov    -0x18(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_values>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbp
call   1070 <strstr@plt>
test   %rax,%rax
je     1203 <read_values+0xb3>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1030 <strlen@plt>
test   %r14d,%r14d
jle    11f6 <read_values+0xa6>
cltq
add    %rax,%rbx
mov    %r14d,%r12d
xor    %ebp,%ebp
lea    0x8(%rsp),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffffffffffff,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1050 <isspace@plt>
test   %rax,%rax
jne    11b0 <read_values+0x60>
mov    %rbx,0x8(%rsp)
cmpb   $0x0,(%rbx)
je     11e0 <read_values+0x90>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1060 <strtoul@plt>
jmp    11e2 <read_values+0x92>
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
mov    %eax,(%r15,%rbp,4)
add    $0x1,%rbp
cmp    %r12,%rbp
je     11f6 <read_values+0xa6>
mov    0x8(%rsp),%rbx
jmp    11a0 <read_values+0x50>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
shl    $0x2,%r14d
mov    %r15,%rdi
xor    %esi,%esi
mov    %r14d,%edx
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <memset@plt>

LLVM IR (-O0):
define void @read_values(i8* %0, i8* %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%10 = load i8*, i8** %5
%11 = load i8*, i8** %6
%12 = call i8* @strstr(i8* %10, i8* %11)
store i8* %12, i8** %5
%13 = load i8*, i8** %5
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %56
15: ; preds = %4
%16 = load i8*, i8** %6
%17 = call i32 @strlen(i8* %16)
%18 = load i8*, i8** %5
%19 = sext i32 %17 to i64
%20 = getelementptr inbounds i8, i8* %18, i64 %19
store i8* %20, i8** %5
store i32 0, i32* %9
br label %21
21: ; preds = %52, %15
%22 = load i32, i32* %9
%23 = load i32, i32* %8
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %55
25: ; preds = %21
br label %26
26: ; preds = %31, %25
%27 = load i8*, i8** %5
%28 = load i8, i8* %27
%29 = call i64 @isspace(i8 signext %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
br label %26
34: ; preds = %26
%35 = load i8*, i8** %5
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %46
39: ; preds = %34
%40 = load i8*, i8** %5
%41 = call i32 @strtoul(i8* %40, i8** %5, i32 0)
%42 = load i32*, i32** %7
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %42, i64 %44
store i32 %41, i32* %45
br label %51
46: ; preds = %34
%47 = load i32*, i32** %7
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i32, i32* %47, i64 %49
store i32 0, i32* %50
br label %51
51: ; preds = %46, %39
br label %52
52: ; preds = %51
%53 = load i32, i32* %9
%54 = add nsw i32 %53, 1
store i32 %54, i32* %9
br label %21
55: ; preds = %21
br label %63
56: ; preds = %4
%57 = load i32*, i32** %7
%58 = load i32, i32* %8
%59 = sext i32 %58 to i64
%60 = mul i64 %59, 4
%61 = trunc i64 %60 to i32
%62 = call i32 @memset(i32* %57, i32 0, i32 %61)
br label %63
63: ; preds = %56, %55
ret void
}

LLVM IR (-O2):
define void @read_values(i8* %0, i8* %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = tail call i8* @strstr(i8* dereferenceable(1) %0, i8* dereferenceable(1) %1)
%7 = icmp eq i8* %6, null
br i1 %7, label %36, label %8
8: ; preds = %4
%9 = tail call i32 @strlen(i8* %1)
%10 = icmp sgt i32 %3, 0
br i1 %10, label %11, label %39
11: ; preds = %8
%12 = sext i32 %9 to i64
%13 = getelementptr inbounds i8, i8* %6, i64 %12
%14 = zext i32 %3 to i64
br label %15
15: ; preds = %34, %11
%16 = phi i8* [ %13, %11 ], [ %35, %34 ]
%17 = phi i64 [ 0, %11 ], [ %32, %34 ]
br label %18
18: ; preds = %18, %15
%19 = phi i8* [ %16, %15 ], [ %23, %18 ]
%20 = load i8, i8* %19
%21 = tail call i64 @isspace(i8 signext %20)
%22 = icmp eq i64 %21, 0
%23 = getelementptr inbounds i8, i8* %19, i64 1
br i1 %22, label %24, label %18
24: ; preds = %18
store i8* %19, i8** %5
%25 = load i8, i8* %19
%26 = icmp eq i8 %25, 0
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = call i32 @strtoul(i8* %19, i8** %5, i32 0)
br label %29
29: ; preds = %24, %27
%30 = phi i32 [ %28, %27 ], [ 0, %24 ]
%31 = getelementptr inbounds i32, i32* %2, i64 %17
store i32 %30, i32* %31
%32 = add nuw nsw i64 %17, 1
%33 = icmp eq i64 %32, %14
br i1 %33, label %39, label %34
34: ; preds = %29
%35 = load i8*, i8** %5
br label %15
36: ; preds = %4
%37 = shl i32 %3, 2
%38 = tail call i32 @memset(i32* %2, i32 0, i32 %37)
br label %39
39: ; preds = %29, %8, %36
ret void
}