#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 main(int argc, char *argv[]) {
  int i, n, zenbat;
  int bektore[50];
  char str[128];
  zenbat = 0;
  printf("Hasi zenbakiak sartzen, bat hilarako\n");
  do {
    fgets(str, 128, stdin);
    sscanf(str, "%d", &n);
    if (n != 0) {
      bektore[zenbat] = n;
      zenbat++;
    }
  } while (n != 0);
  printf("Zuk emandako emandako honako hau da:\n");
  for (i = 0; i < zenbat; i++)
    printf("%d ", bektore[i]);
  printf("\n\nTori orain zerrenda berbera baina alderantziz:\n");
  for (i = zenbat - 1; i >= 0; i--)
    printf("%d ", bektore[i]);
  printf("\n");
  printf("Sakatu \"return\" amaitzeko .....");
  fgets(str, 128, stdin);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x170(%rbp),%rdi
mov    0x2e7c(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1040 <fgets@plt>
lea    -0x170(%rbp),%rdi
lea    0xea0(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1050 <sscanf@plt>
cmpl   $0x0,-0x18(%rbp)
je     11b0 <main+0x80>
mov    -0x18(%rbp),%ecx
movslq -0x1c(%rbp),%rax
mov    %ecx,-0xf0(%rbp,%rax,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11b5 <main+0x85>
cmpl   $0x0,-0x18(%rbp)
jne    115e <main+0x2e>
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1207 <main+0xd7>
movslq -0x14(%rbp),%rax
mov    -0xf0(%rbp,%rax,4),%esi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11d4 <main+0xa4>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     124f <main+0x11f>
movslq -0x14(%rbp),%rax
mov    -0xf0(%rbp,%rax,4),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    121e <main+0xee>
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x170(%rbp),%rdi
mov    0x2d6f(%rip),%rax
mov    (%rax),%edx
mov    $0x80,%esi
call   1040 <fgets@plt>
xor    %eax,%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x158,%rsp
lea    0xebf(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e74(%rip),%r12
mov    (%r12),%edx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x80,%esi
call   1060 <fgets@plt>
lea    0xe6f(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
call   1070 <sscanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1270 <main+0x120>
xor    %ebp,%ebp
lea    0x10(%rsp),%r13
lea    0xe48(%rip),%r14
lea    0xc(%rsp),%r15
nopl   (%rax)
mov    %eax,0x90(%rsp,%rbp,4)
add    $0x1,%rbp
mov    (%r12),%edx
mov    %r13,%rdi
mov    $0x80,%esi
call   1060 <fgets@plt>
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
call   1070 <sscanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    11c0 <main+0x70>
lea    0xe53(%rip),%rdi
call   1040 <puts@plt>
test   %ebp,%ebp
je     127c <main+0x12c>
mov    %ebp,%r15d
lea    0xdf7(%rip),%r14
xor    %ebx,%ebx
xchg   %ax,%ax
mov    0x90(%rsp,%rbx,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1210 <main+0xc0>
lea    0xe40(%rip),%rdi
call   1040 <puts@plt>
test   %ebp,%ebp
jle    1288 <main+0x138>
mov    %ebp,%ebx
add    $0x1,%rbx
lea    0xdbc(%rip),%r14
nopw   0x0(%rax,%rax,1)
lea    -0x2(%rbx),%eax
mov    0x90(%rsp,%rax,4),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffffffffffff,%rbx
cmp    $0x1,%rbx
ja     1250 <main+0x100>
jmp    1288 <main+0x138>
lea    0xdd5(%rip),%rdi
call   1040 <puts@plt>
lea    0xdee(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xd6e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r12),%edx
lea    0x10(%rsp),%rdi
mov    $0x80,%esi
call   1060 <fgets@plt>
xor    %eax,%eax
add    $0x158,%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"
@.str.2 = [38 x i8] c"Zuk emandako emandako honako hau da:\0A\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [50 x i8] c"\0A\0ATori orain zerrenda berbera baina alderantziz:\0A\00"
@.str.5 = [2 x i8] c"\0A\00"
@.str.6 = [32 x i8] c"Sakatu \22return\22 amaitzeko .....\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [50 x i32]
%10 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %28, %2
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%14 = load i32, i32* @stdin
%15 = call i32 @fgets(i8* %13, i32 128, i32 %14)
%16 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%17 = call i32 @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%18 = load i32, i32* %7
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %27
20: ; preds = %12
%21 = load i32, i32* %7
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [50 x i32], [50 x i32]* %9, i64 0, i64 %23
store i32 %21, i32* %24
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %27
27: ; preds = %20, %12
br label %28
28: ; preds = %27
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
br i1 %30, label %12, label %31
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %6
br label %33
33: ; preds = %43, %31
%34 = load i32, i32* %6
%35 = load i32, i32* %8
%36 = icmp slt i32 %34, %35
br i1 %36, label %37, label %46
37: ; preds = %33
%38 = load i32, i32* %6
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [50 x i32], [50 x i32]* %9, i64 0, i64 %39
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %37
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
store i32 %45, i32* %6
br label %33
46: ; preds = %33
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.4, i64 0, i64 0))
%48 = load i32, i32* %8
%49 = sub nsw i32 %48, 1
store i32 %49, i32* %6
br label %50
50: ; preds = %59, %46
%51 = load i32, i32* %6
%52 = icmp sge i32 %51, 0
br i1 %52, label %53, label %62
53: ; preds = %50
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [50 x i32], [50 x i32]* %9, i64 0, i64 %55
%57 = load i32, i32* %56
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %57)
br label %59
59: ; preds = %53
%60 = load i32, i32* %6
%61 = add nsw i32 %60, -1
store i32 %61, i32* %6
br label %50
62: ; preds = %50
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%65 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%66 = load i32, i32* @stdin
%67 = call i32 @fgets(i8* %65, i32 128, i32 %66)
ret i32 0
}

LLVM IR (-O2):
@stdin = global i32 0
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.6 = [32 x i8] c"Sakatu \22return\22 amaitzeko .....\00"
@str = [37 x i8] c"Hasi zenbakiak sartzen, bat hilarako\00"
@str.7 = [37 x i8] c"Zuk emandako emandako honako hau da:\00"
@str.8 = [49 x i8] c"\0A\0ATori orain zerrenda berbera baina alderantziz:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [50 x i32]
%5 = alloca [128 x i8]
%6 = bitcast i32* %3 to i8*
%7 = bitcast [50 x i32]* %4 to i8*
%8 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%10 = load i32, i32* @stdin
%11 = call i32 @fgets(i8* %8, i32 128, i32 %10)
%12 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
br label %40
17: ; preds = %2, %17
%18 = phi i64 [ %21, %17 ], [ 0, %2 ]
%19 = phi i32 [ %25, %17 ], [ %13, %2 ]
%20 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 %18
store i32 %19, i32* %20
%21 = add nuw i64 %18, 1
%22 = load i32, i32* @stdin
%23 = call i32 @fgets(i8* %8, i32 128, i32 %22)
%24 = call i32 @sscanf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %17
27: ; preds = %17
%28 = trunc i64 %21 to i32
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.7, i64 0, i64 0))
%30 = icmp eq i32 %28, 0
br i1 %30, label %40, label %31
31: ; preds = %27
%32 = and i64 %21, 4294967295
br label %33
33: ; preds = %31, %33
%34 = phi i64 [ 0, %31 ], [ %38, %33 ]
%35 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = add nuw nsw i64 %34, 1
%39 = icmp eq i64 %38, %32
br i1 %39, label %42, label %33
40: ; preds = %15, %27
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.8, i64 0, i64 0))
br label %55
42: ; preds = %33
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.8, i64 0, i64 0))
%44 = icmp sgt i32 %28, 0
br i1 %44, label %45, label %55
45: ; preds = %42
%46 = and i64 %21, 4294967295
br label %47
47: ; preds = %45, %47
%48 = phi i64 [ %46, %45 ], [ %49, %47 ]
%49 = add nsw i64 %48, -1
%50 = and i64 %49, 4294967295
%51 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 %50
%52 = load i32, i32* %51
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %52)
%54 = icmp ugt i64 %48, 1
br i1 %54, label %47, label %55
55: ; preds = %47, %40, %42
%56 = call i32 @putchar(i32 10)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%58 = load i32, i32* @stdin
%59 = call i32 @fgets(i8* %8, i32 128, i32 %58)
ret i32 0
}