#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 jumlahBaris, hitungBaris, akhirBaris, angka = 1;
  printf("Program ini akan menuliskan segitiga Floyd\n");
  printf("Masukkan jumlah baris yang diinginkan: ");
  scanf("%d", &jumlahBaris);
  for (hitungBaris = 1; hitungBaris <= jumlahBaris; hitungBaris++) {
    for (akhirBaris = 1; akhirBaris <= hitungBaris; ++akhirBaris) {
      printf("%d ", angka);
      ++angka;
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x14(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xefb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     11cc <main+0xac>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11b0 <main+0x90>
mov    -0x14(%rbp),%esi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117c <main+0x5c>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1169 <main+0x49>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xee0(%rip),%rdi
call   1040 <puts@plt>
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebf(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11d2 <main+0x92>
mov    $0x1,%r15d
lea    0xea4(%rip),%r14
mov    $0x1,%r12d
nopl   (%rax)
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    (%r15,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebx
cmp    %ebx,%r12d
jne    11a0 <main+0x60>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    %r12d,%r15d
lea    0x1(%r12),%eax
cmp    0x4(%rsp),%r12d
mov    %eax,%r12d
jl     1190 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Program ini akan menuliskan segitiga Floyd\0A\00"
@.str.1 = [40 x i8] c"Masukkan jumlah baris yang diinginkan: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
@.str.4 = [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
store i32 1, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
store i32 1, i32* %3
br label %9
9: ; preds = %28, %0
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = icmp sle i32 %10, %11
br i1 %12, label %13, label %31
13: ; preds = %9
store i32 1, i32* %4
br label %14
14: ; preds = %23, %13
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = load i32, i32* %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %23
23: ; preds = %18
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
store i32 %25, i32* %4
br label %14
26: ; preds = %14
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
store i32 %30, i32* %3
br label %9
31: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [40 x i8] c"Masukkan jumlah baris yang diinginkan: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d \00"
@str = [43 x i8] c"Program ini akan menuliskan segitiga Floyd\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %22, label %8
8: ; preds = %0, %17
%9 = phi i32 [ %11, %17 ], [ 1, %0 ]
%10 = phi i32 [ %19, %17 ], [ 1, %0 ]
%11 = add i32 %9, %10
br label %12
12: ; preds = %8, %12
%13 = phi i32 [ %9, %8 ], [ %15, %12 ]
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = add i32 %13, 1
%16 = icmp eq i32 %15, %11
br i1 %16, label %17, label %12
17: ; preds = %12
%18 = call i32 @putchar(i32 10)
%19 = add nuw nsw i32 %10, 1
%20 = load i32, i32* %1
%21 = icmp slt i32 %10, %20
br i1 %21, label %8, label %22
22: ; preds = %17, %0
ret i32 0
}