#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int stop, j, num;
  printf("Ingrese un numero entre el 1 y el 9: ");
  scanf("%d", &stop);
  if (stop < 1 || stop > 9) {
    printf("El numero ingresado no entra dentro del rango\n");
    return 1;
  }
  for (int i = 1; i <= stop; i++) {
    if (i % 2 != 0)
      for (j = 1; j <= stop; j++)
        printf("%d", j);
    else
      for (j = stop; j >= 1; j--)
        printf("%d", j);
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jl     1161 <main+0x41>
cmpl   $0x9,-0x8(%rbp)
jle    117b <main+0x5b>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1230 <main+0x110>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1229 <main+0x109>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11d9 <main+0xb9>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11d4 <main+0xb4>
mov    -0xc(%rbp),%esi
lea    0xe67(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11a9 <main+0x89>
jmp    120d <main+0xed>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     1208 <main+0xe8>
mov    -0xc(%rbp),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    11df <main+0xbf>
jmp    120d <main+0xed>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1182 <main+0x62>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%ebx
lea    -0xa(%rbx),%eax
cmp    $0xfffffff7,%eax
jae    118a <main+0x4a>
lea    0xeae(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    1219 <main+0xd9>
mov    $0x1,%r15d
lea    0xe8f(%rip),%r14
jmp    11ba <main+0x7a>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r15),%eax
mov    0xc(%rsp),%ebx
cmp    %ebx,%r15d
mov    %eax,%r15d
jge    1217 <main+0xd7>
test   $0x1,%r15b
jne    11f0 <main+0xb0>
test   %ebx,%ebx
jle    11a0 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0x1(%rbx),%eax
cmp    $0x1,%ebx
mov    %eax,%ebx
ja     11d0 <main+0x90>
jmp    11a0 <main+0x60>
nopl   0x0(%rax,%rax,1)
test   %ebx,%ebx
jle    11a0 <main+0x60>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    0xc(%rsp),%ebx
jl     1200 <main+0xc0>
jmp    11a0 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Ingrese un numero entre el 1 y el 9: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [47 x i8] c"El numero ingresado no entra dentro del rango\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 1
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 9
br i1 %12, label %13, label %15
13: ; preds = %10, %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %54
15: ; preds = %10
store i32 1, i32* %5
br label %16
16: ; preds = %50, %15
%17 = load i32, i32* %5
%18 = load i32, i32* %2
%19 = icmp sle i32 %17, %18
br i1 %19, label %20, label %53
20: ; preds = %16
%21 = load i32, i32* %5
%22 = srem i32 %21, 2
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %36
24: ; preds = %20
store i32 1, i32* %3
br label %25
25: ; preds = %32, %24
%26 = load i32, i32* %3
%27 = load i32, i32* %2
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %35
29: ; preds = %25
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %29
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %25
35: ; preds = %25
br label %48
36: ; preds = %20
%37 = load i32, i32* %2
store i32 %37, i32* %3
br label %38
38: ; preds = %44, %36
%39 = load i32, i32* %3
%40 = icmp sge i32 %39, 1
br i1 %40, label %41, label %47
41: ; preds = %38
%42 = load i32, i32* %3
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %41
%45 = load i32, i32* %3
%46 = add nsw i32 %45, -1
store i32 %46, i32* %3
br label %38
47: ; preds = %38
br label %48
48: ; preds = %47, %35
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %50
50: ; preds = %48
%51 = load i32, i32* %5
%52 = add nsw i32 %51, 1
store i32 %52, i32* %5
br label %16
53: ; preds = %16
store i32 0, i32* %1
br label %54
54: ; preds = %53, %13
%55 = load i32, i32* %1
ret i32 %55
}

LLVM IR (-O2):
@.str = [38 x i8] c"Ingrese un numero entre el 1 y el 9: \00"
@.str.1 = [3 x i8] c"%d\00"
@str = [46 x i8] c"El numero ingresado no entra dentro del rango\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = add i32 %5, -10
%7 = icmp ult i32 %6, -9
br i1 %7, label %8, label %10
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
br label %35
10: ; preds = %0, %30
%11 = phi i32 [ %33, %30 ], [ %5, %0 ]
%12 = phi i32 [ %32, %30 ], [ 1, %0 ]
%13 = and i32 %12, 1
%14 = icmp eq i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %10
%16 = icmp slt i32 %11, 1
br i1 %16, label %30, label %19
17: ; preds = %10
%18 = icmp sgt i32 %11, 0
br i1 %18, label %25, label %30
19: ; preds = %15, %19
%20 = phi i32 [ %22, %19 ], [ 1, %15 ]
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = add nuw nsw i32 %20, 1
%23 = load i32, i32* %1
%24 = icmp slt i32 %20, %23
br i1 %24, label %19, label %30
25: ; preds = %17, %25
%26 = phi i32 [ %28, %25 ], [ %11, %17 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = add nsw i32 %26, -1
%29 = icmp ugt i32 %26, 1
br i1 %29, label %25, label %30
30: ; preds = %19, %25, %15, %17
%31 = call i32 @putchar(i32 10)
%32 = add nuw nsw i32 %12, 1
%33 = load i32, i32* %1
%34 = icmp slt i32 %12, %33
br i1 %34, label %10, label %35
35: ; preds = %30, %8
%36 = phi i32 [ 1, %8 ], [ 0, %30 ]
ret i32 %36
}