#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 /*<<< orphan*/ e;

/* Variables and functions */
unsigned int atoi(char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
void read_numbers(unsigned int *res, int n, char *line) {
  char *s = &line[0];
  char e[30];
  memset(e, 0, sizeof(e));
  for (int i = 0; i < n; i++) {
    int count = 0;
    while (isdigit(*s)) {
      e[count] = *s;
      count++;
      s++;
    }
    e[count] = '\0';
    s++;
    res[i] = atoi(e);
  }
}


x86 assembly (clang, -O0):
<read_numbers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1040 <memset@plt>
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11ec <read_numbers+0xbc>
movl   $0x0,-0x48(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11b3 <read_numbers+0x83>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
movslq -0x48(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1175 <read_numbers+0x45>
movslq -0x48(%rbp),%rax
movb   $0x0,-0x40(%rbp,%rax,1)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <atoi@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1162 <read_numbers+0x32>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_numbers>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x1e,%edx
call   1040 <memset@plt>
test   %ebp,%ebp
jle    11bf <read_numbers+0x8f>
mov    %ebp,%r12d
xor    %r13d,%r13d
mov    %rsp,%r15
jmp    118f <read_numbers+0x5f>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebp,%eax
movb   $0x0,(%rsp,%rax,1)
add    $0x1,%rbx
mov    %r15,%rdi
call   1050 <atoi@plt>
mov    %eax,(%r14,%r13,4)
add    $0x1,%r13
cmp    %r12,%r13
je     11bf <read_numbers+0x8f>
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     1170 <read_numbers+0x40>
xchg   %ax,%ax
movzbl (%rbx,%rbp,1),%eax
mov    %al,(%rsp,%rbp,1)
movsbl 0x1(%rbx,%rbp,1),%edi
add    $0x1,%rbp
call   1030 <isdigit@plt>
test   %rax,%rax
jne    11a0 <read_numbers+0x70>
add    %rbp,%rbx
jmp    1170 <read_numbers+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @read_numbers(i32* %0, i32 %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [30 x i8]
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%11 = load i8*, i8** %6
%12 = getelementptr inbounds i8, i8* %11, i64 0
store i8* %12, i8** %7
%13 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%14 = call i32 @memset(i8* %13, i32 0, i32 30)
store i32 0, i32* %9
br label %15
15: ; preds = %47, %3
%16 = load i32, i32* %9
%17 = load i32, i32* %5
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %50
19: ; preds = %15
store i32 0, i32* %10
br label %20
20: ; preds = %25, %19
%21 = load i8*, i8** %7
%22 = load i8, i8* %21
%23 = call i64 @isdigit(i8 signext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %35
25: ; preds = %20
%26 = load i8*, i8** %7
%27 = load i8, i8* %26
%28 = load i32, i32* %10
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 %29
store i8 %27, i8* %30
%31 = load i32, i32* %10
%32 = add nsw i32 %31, 1
store i32 %32, i32* %10
%33 = load i8*, i8** %7
%34 = getelementptr inbounds i8, i8* %33, i32 1
store i8* %34, i8** %7
br label %20
35: ; preds = %20
%36 = load i32, i32* %10
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 %37
store i8 0, i8* %38
%39 = load i8*, i8** %7
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %7
%41 = getelementptr inbounds [30 x i8], [30 x i8]* %8, i64 0, i64 0
%42 = call i32 @atoi(i8* %41)
%43 = load i32*, i32** %4
%44 = load i32, i32* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i32, i32* %43, i64 %45
store i32 %42, i32* %46
br label %47
47: ; preds = %35
%48 = load i32, i32* %9
%49 = add nsw i32 %48, 1
store i32 %49, i32* %9
br label %15
50: ; preds = %15
ret void
}

LLVM IR (-O2):
define void @read_numbers(i32* nocapture writeonly %0, i32 %1, i8* nocapture %2) {
%4 = alloca [30 x i8]
%5 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 30)
%7 = icmp sgt i32 %1, 0
br i1 %7, label %8, label %16
8: ; preds = %3
%9 = zext i32 %1 to i64
br label %10
10: ; preds = %8, %27
%11 = phi i64 [ 0, %8 ], [ %35, %27 ]
%12 = phi i8* [ %2, %8 ], [ %32, %27 ]
%13 = load i8, i8* %12
%14 = call i64 @isdigit(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %27, label %17
16: ; preds = %27, %3
ret void
17: ; preds = %10, %17
%18 = phi i64 [ %22, %17 ], [ 0, %10 ]
%19 = phi i8* [ %23, %17 ], [ %12, %10 ]
%20 = load i8, i8* %19
%21 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 %18
store i8 %20, i8* %21
%22 = add nuw i64 %18, 1
%23 = getelementptr inbounds i8, i8* %19, i64 1
%24 = load i8, i8* %23
%25 = call i64 @isdigit(i8 signext %24)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %17
27: ; preds = %17, %10
%28 = phi i8* [ %12, %10 ], [ %23, %17 ]
%29 = phi i64 [ 0, %10 ], [ %22, %17 ]
%30 = and i64 %29, 4294967295
%31 = getelementptr inbounds [30 x i8], [30 x i8]* %4, i64 0, i64 %30
store i8 0, i8* %31
%32 = getelementptr inbounds i8, i8* %28, i64 1
%33 = call i32 @atoi(i8* %5)
%34 = getelementptr inbounds i32, i32* %0, i64 %11
store i32 %33, i32* %34
%35 = add nuw nsw i64 %11, 1
%36 = icmp eq i64 %35, %9
br i1 %36, label %16, label %10
}