#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 *, ...);
void serie_repetition(int n) {
  int i, j;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= i; j++) {
      printf("%d", j);
    }
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<serie_repetition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     117c <serie_repetition+0x6c>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1160 <serie_repetition+0x50>
mov    -0xc(%rbp),%esi
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1135 <serie_repetition+0x25>
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1122 <serie_repetition+0x12>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serie_repetition>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edi,%edi
jle    1197 <serie_repetition+0x77>
mov    %edi,%r14d
add    $0x1,%r14d
mov    $0x2,%r15d
lea    0xec0(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x2,%eax
jne    1160 <serie_repetition+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0x1(%r15),%eax
add    $0xffffffff,%ebx
cmp    %r14d,%r15d
mov    %eax,%r15d
jne    1150 <serie_repetition+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @serie_repetition(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %2
store i32 1, i32* %3
br label %5
5: ; preds = %22, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp sle i32 %6, %7
br i1 %8, label %9, label %25
9: ; preds = %5
store i32 1, i32* %4
br label %10
10: ; preds = %17, %9
%11 = load i32, i32* %4
%12 = load i32, i32* %3
%13 = icmp sle i32 %11, %12
br i1 %13, label %14, label %20
14: ; preds = %10
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14
%18 = load i32, i32* %4
%19 = add nsw i32 %18, 1
store i32 %19, i32* %4
br label %10
20: ; preds = %10
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %5
25: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
define void @serie_repetition(i32 %0) {
%2 = icmp slt i32 %0, 1
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = add i32 %0, 1
br label %5
5: ; preds = %3, %12
%6 = phi i32 [ 2, %3 ], [ %14, %12 ]
br label %7
7: ; preds = %5, %7
%8 = phi i32 [ 1, %5 ], [ %10, %7 ]
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = add nuw i32 %8, 1
%11 = icmp eq i32 %10, %6
br i1 %11, label %12, label %7
12: ; preds = %7
%13 = tail call i32 @putchar(i32 10)
%14 = add nuw i32 %6, 1
%15 = icmp eq i32 %6, %4
br i1 %15, label %16, label %5
16: ; preds = %12, %1
ret void
}