#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(void) {
  int i;
  int x;
  printf("How many lines need to display: ");
  scanf("%d", &x);
  for (i = 1; i <= x; i++)
    printf("%*d\n", i, i % 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xedd(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     118a <main+0x6a>
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x34>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11a3 <main+0x83>
mov    $0x1,%ebx
mov    $0xcccccccd,%r15d
lea    0xec5(%rip),%r14
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %ebx,%ecx
imul   %r15,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %eax,%ebp
add    $0x1,%ebp
neg    %ecx
lea    (%rax,%rcx,1),%edx
add    $0x1,%edx
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%ebx
mov    %ebp,%eax
cmp    0x4(%rsp),%ebp
jl     1170 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"How many lines need to display: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%*d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
store i32 1, i32* %2
br label %6
6: ; preds = %15, %0
%7 = load i32, i32* %2
%8 = load i32, i32* %3
%9 = icmp sle i32 %7, %8
br i1 %9, label %10, label %18
10: ; preds = %6
%11 = load i32, i32* %2
%12 = load i32, i32* %2
%13 = srem i32 %12, 10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %11, i32 %13)
br label %15
15: ; preds = %10
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
store i32 %17, i32* %2
br label %6
18: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"How many lines need to display: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"%*d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 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 = icmp slt i32 %5, 1
br i1 %6, label %14, label %7
7: ; preds = %0, %7
%8 = phi i32 [ %11, %7 ], [ 1, %0 ]
%9 = urem i32 %8, 10
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %8, i32 %9)
%11 = add nuw nsw i32 %8, 1
%12 = load i32, i32* %1
%13 = icmp slt i32 %8, %12
br i1 %13, label %7, label %14
14: ; preds = %7, %0
ret i32 0
}