#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*/ printf(char *, int);
scalar_t__ sscanf(char *, char *, int *, int *);
int sreadint2(char *lerroa, int *zenbakiak) {
  char *s = lerroa;
  int i, zbk, kont = 0;
  while (sscanf(s, " %d%n", &zbk, &i) > 0) {
    s += i;
    while ((*s != ' ') && (*s != '\0'))
      s++;
    zenbakiak[kont++] = zbk;
  }
  printf("%d numbers in the line\n", kont);
  return (kont);
}


x86 assembly (clang, -O0):
<sreadint2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xeb6(%rip),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x1c(%rbp),%rcx
call   1040 <sscanf@plt>
cmp    $0x0,%rax
jle    11d5 <sreadint2+0xb5>
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x25(%rbp)
je     1197 <sreadint2+0x77>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11a7 <sreadint2+0x87>
jmp    11b8 <sreadint2+0x98>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1172 <sreadint2+0x52>
mov    -0x20(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x24(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    113f <sreadint2+0x1f>
mov    -0x24(%rbp),%esi
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sreadint2>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xec8(%rip),%rsi
mov    %rsp,%rdx
lea    0x4(%rsp),%rcx
call   1040 <sscanf@plt>
xor    %r15d,%r15d
test   %rax,%rax
jle    119b <sreadint2+0x7b>
lea    0xeac(%rip),%r12
mov    %rsp,%r13
lea    0x4(%rsp),%rbp
jmp    1181 <sreadint2+0x61>
xchg   %ax,%ax
mov    (%rsp),%eax
mov    %eax,(%r14,%r15,4)
add    $0x1,%r15
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1040 <sscanf@plt>
test   %rax,%rax
jle    119b <sreadint2+0x7b>
movslq 0x4(%rsp),%rax
add    %rax,%rbx
testb  $0xdf,(%rbx)
je     1160 <sreadint2+0x40>
xchg   %ax,%ax
add    $0x1,%rbx
testb  $0xdf,(%rbx)
jne    1190 <sreadint2+0x70>
jmp    1160 <sreadint2+0x40>
lea    0xe64(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c" %d%n\00"
@.str.1 = [24 x i8] c"%d numbers in the line\0A\00"
define i32 @sreadint2(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %3
store i32* %1, i32** %4
%9 = load i8*, i8** %3
store i8* %9, i8** %5
store i32 0, i32* %8
br label %10
10: ; preds = %34, %2
%11 = load i8*, i8** %5
%12 = call i64 @sscanf(i8* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %7, i32* %6)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %41
14: ; preds = %10
%15 = load i32, i32* %6
%16 = load i8*, i8** %5
%17 = sext i32 %15 to i64
%18 = getelementptr inbounds i8, i8* %16, i64 %17
store i8* %18, i8** %5
br label %19
19: ; preds = %31, %14
%20 = load i8*, i8** %5
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 32
br i1 %23, label %24, label %29
24: ; preds = %19
%25 = load i8*, i8** %5
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br label %29
29: ; preds = %24, %19
%30 = phi i1 [ false, %19 ], [ %28, %24 ]
br i1 %30, label %31, label %34
31: ; preds = %29
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
br label %19
34: ; preds = %29
%35 = load i32, i32* %7
%36 = load i32*, i32** %4
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
%39 = sext i32 %37 to i64
%40 = getelementptr inbounds i32, i32* %36, i64 %39
store i32 %35, i32* %40
br label %10
41: ; preds = %10
%42 = load i32, i32* %8
%43 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %8
ret i32 %44
}

LLVM IR (-O2):
@.str = [6 x i8] c" %d%n\00"
@.str.1 = [24 x i8] c"%d numbers in the line\0A\00"
define i32 @sreadint2(i8* %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = call i64 @sscanf(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %3)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %28
9: ; preds = %2, %20
%10 = phi i64 [ %22, %20 ], [ 0, %2 ]
%11 = phi i8* [ %16, %20 ], [ %0, %2 ]
%12 = load i32, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
br label %15
15: ; preds = %18, %9
%16 = phi i8* [ %14, %9 ], [ %19, %18 ]
%17 = load i8, i8* %16
switch i8 %17, label %18 [
i8 32, label %20
i8 0, label %20
]
18: ; preds = %15
%19 = getelementptr inbounds i8, i8* %16, i64 1
br label %15
20: ; preds = %15, %15
%21 = load i32, i32* %4
%22 = add nuw i64 %10, 1
%23 = getelementptr inbounds i32, i32* %1, i64 %10
store i32 %21, i32* %23
%24 = call i64 @sscanf(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %4, i32* %3)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %9, label %26
26: ; preds = %20
%27 = trunc i64 %22 to i32
br label %28
28: ; preds = %26, %2
%29 = phi i32 [ 0, %2 ], [ %27, %26 ]
%30 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 %29)
ret i32 %29
}