#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*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stdin;
int zerrendaEskatu(int b[]) {
  int n, zenbat = 0;
  char str[128];
  printf("Hasi zenbakiak sartzen, bat hilarako\n");
  do {
    fgets(str, 128, stdin);
    sscanf(str, "%d", &n);
    if (n != 0) {
      b[zenbat] = n;
      zenbat++;
    }
  } while (n != 0);
  return zenbat;
}


x86 assembly (clang, -O0):
<zerrendaEskatu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2e88(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1040 <fgets@plt>
lea    -0x90(%rbp),%rdi
lea    0xeac(%rip),%rsi
lea    -0xc(%rbp),%rdx
call   1050 <sscanf@plt>
cmpl   $0x0,-0xc(%rbp)
je     11a4 <zerrendaEskatu+0x74>
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a9 <zerrendaEskatu+0x79>
cmpl   $0x0,-0xc(%rbp)
jne    1152 <zerrendaEskatu+0x22>
mov    -0x10(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zerrendaEskatu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
mov    %rdi,%r14
lea    0xeb8(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e91(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1040 <fgets@plt>
lea    0xe8d(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1050 <sscanf@plt>
mov    0xc(%rsp),%eax
xor    %ebx,%ebx
test   %eax,%eax
je     11ce <zerrendaEskatu+0x9e>
lea    0x10(%rsp),%r15
lea    0xe6a(%rip),%r12
lea    0xc(%rsp),%r13
nopl   0x0(%rax,%rax,1)
mov    %eax,(%r14,%rbx,4)
add    $0x1,%rbx
mov    0x0(%rbp),%edx
mov    %r15,%rdi
mov    $0x80,%esi
call   1040 <fgets@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r13,%rdx
call   1050 <sscanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    11a0 <zerrendaEskatu+0x70>
mov    %ebx,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Hasi zenbakiak sartzen, bat hilarako\0A\00"
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
define i32 @zerrendaEskatu(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca [128 x i8]
store i32* %0, i32** %2
store i32 0, i32* %4
%6 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %24, %1
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%9 = load i32, i32* @stdin
%10 = call i32 @fgets(i8* %8, i32 128, i32 %9)
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %23
15: ; preds = %7
%16 = load i32, i32* %3
%17 = load i32*, i32** %2
%18 = load i32, i32* %4
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
store i32 %16, i32* %20
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %23
23: ; preds = %15, %7
br label %24
24: ; preds = %23
%25 = load i32, i32* %3
%26 = icmp ne i32 %25, 0
br i1 %26, label %7, label %27
27: ; preds = %24
%28 = load i32, i32* %4
ret i32 %28
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@str = [37 x i8] c"Hasi zenbakiak sartzen, bat hilarako\00"
define i32 @zerrendaEskatu(i32* nocapture writeonly %0) {
%2 = alloca i32
%3 = alloca [128 x i8]
%4 = bitcast i32* %2 to i8*
%5 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%7 = load i32, i32* @stdin
%8 = call i32 @fgets(i8* %5, i32 128, i32 %7)
%9 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 0
br i1 %11, label %24, label %12
12: ; preds = %1, %12
%13 = phi i64 [ %16, %12 ], [ 0, %1 ]
%14 = phi i32 [ %20, %12 ], [ %10, %1 ]
%15 = getelementptr inbounds i32, i32* %0, i64 %13
store i32 %14, i32* %15
%16 = add nuw i64 %13, 1
%17 = load i32, i32* @stdin
%18 = call i32 @fgets(i8* %5, i32 128, i32 %17)
%19 = call i32 @sscanf(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %12
22: ; preds = %12
%23 = trunc i64 %16 to i32
br label %24
24: ; preds = %22, %1
%25 = phi i32 [ 0, %1 ], [ %23, %22 ]
ret i32 %25
}