#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 *malloc(int);
int /*<<< orphan*/ mostra(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int *bp = NULL, k = 0, tam = 1;
  bp = malloc(sizeof(int) * 20);
  for (int i = 0; i < 20; i++)
    bp[i] = 0;
  bp[0] = 1;
  printf("1\n");
  do {
    if (0) {
      printf("Loop>> k: %d, t: %d\n", k, tam);
    }
    bp[tam++] = 1;
    mostra(bp, tam);
    for (int i = (tam - 1); i > 0; i--) {
      bp[i] = bp[i - 1] + bp[i];
    }
    k++;
  } while (k < 20);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jge    1191 <main+0x61>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    116a <main+0x3a>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,4)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <mostra@plt>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jle    1215 <main+0xe5>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
add    (%rax,%rcx,4),%edx
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    11d7 <main+0xa7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x14,-0x14(%rbp)
jl     11a9 <main+0x79>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x50,%edi
call   1050 <malloc@plt>
mov    %rax,%r12
xorps  %xmm0,%xmm0
movups %xmm0,0x4(%rax)
movups %xmm0,0x14(%rax)
movups %xmm0,0x24(%rax)
movups %xmm0,0x34(%rax)
movups %xmm0,0x40(%rax)
movl   $0x1,(%rax)
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
xor    %r15d,%r15d
jmp    118d <main+0x5d>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
mov    %r14,%rbx
cmp    $0x15,%r14
je     11f4 <main+0xc4>
lea    0x1(%rbx),%r14
movl   $0x1,(%r12,%rbx,4)
mov    %r12,%rdi
mov    %r14d,%esi
call   1040 <mostra@plt>
test   $0x1,%bl
je     11ba <main+0x8a>
lea    -0x1(%rbx),%rax
mov    %eax,%ecx
mov    (%r12,%rcx,4),%ecx
add    %ecx,(%r12,%rbx,4)
mov    %rax,%rbx
test   %r15,%r15
je     1180 <main+0x50>
add    $0x2,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x3(%rbx),%eax
mov    (%r12,%rax,4),%eax
add    %eax,-0x8(%r12,%rbx,4)
lea    -0x4(%rbx),%eax
mov    (%r12,%rax,4),%eax
add    %eax,-0xc(%r12,%rbx,4)
add    $0xfffffffffffffffe,%rbx
cmp    $0x2,%rbx
jg     11d0 <main+0xa0>
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"1\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
store i32* null, i32** %2
store i32 0, i32* %3
store i32 1, i32* %4
%7 = call i32* @malloc(i32 80)
store i32* %7, i32** %2
store i32 0, i32* %5
br label %8
8: ; preds = %16, %0
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 20
br i1 %10, label %11, label %19
11: ; preds = %8
%12 = load i32*, i32** %2
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
store i32 0, i32* %15
br label %16
16: ; preds = %11
%17 = load i32, i32* %5
%18 = add nsw i32 %17, 1
store i32 %18, i32* %5
br label %8
19: ; preds = %8
%20 = load i32*, i32** %2
%21 = getelementptr inbounds i32, i32* %20, i64 0
store i32 1, i32* %21
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %60, %19
%24 = load i32*, i32** %2
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
%27 = sext i32 %25 to i64
%28 = getelementptr inbounds i32, i32* %24, i64 %27
store i32 1, i32* %28
%29 = load i32*, i32** %2
%30 = load i32, i32* %4
%31 = call i32 @mostra(i32* %29, i32 %30)
%32 = load i32, i32* %4
%33 = sub nsw i32 %32, 1
store i32 %33, i32* %6
br label %34
34: ; preds = %54, %23
%35 = load i32, i32* %6
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %57
37: ; preds = %34
%38 = load i32*, i32** %2
%39 = load i32, i32* %6
%40 = sub nsw i32 %39, 1
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i32, i32* %38, i64 %41
%43 = load i32, i32* %42
%44 = load i32*, i32** %2
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i32, i32* %44, i64 %46
%48 = load i32, i32* %47
%49 = add nsw i32 %43, %48
%50 = load i32*, i32** %2
%51 = load i32, i32* %6
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %50, i64 %52
store i32 %49, i32* %53
br label %54
54: ; preds = %37
%55 = load i32, i32* %6
%56 = add nsw i32 %55, -1
store i32 %56, i32* %6
br label %34
57: ; preds = %34
%58 = load i32, i32* %3
%59 = add nsw i32 %58, 1
store i32 %59, i32* %3
br label %60
60: ; preds = %57
%61 = load i32, i32* %3
%62 = icmp slt i32 %61, 20
br i1 %62, label %23, label %63
63: ; preds = %60
ret i32 0
}

LLVM IR (-O2):
@str = [2 x i8] c"1\00"
define i32 @main() {
%1 = tail call i32* @malloc(i32 80)
%2 = getelementptr inbounds i32, i32* %1, i64 1
%3 = bitcast i32* %2 to i8*
store i32 1, i32* %1
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %5
5: ; preds = %25, %0
%6 = phi i64 [ %27, %25 ], [ 0, %0 ]
%7 = phi i64 [ %8, %25 ], [ 1, %0 ]
%8 = add nuw nsw i64 %7, 1
%9 = getelementptr inbounds i32, i32* %1, i64 %7
store i32 1, i32* %9
%10 = trunc i64 %8 to i32
%11 = tail call i32 @mostra(i32* %1, i32 %10)
%12 = and i64 %7, 1
%13 = icmp eq i64 %12, 0
br i1 %13, label %22, label %14
14: ; preds = %5
%15 = add nsw i64 %7, -1
%16 = and i64 %15, 4294967295
%17 = getelementptr inbounds i32, i32* %1, i64 %16
%18 = load i32, i32* %17
%19 = getelementptr inbounds i32, i32* %1, i64 %7
%20 = load i32, i32* %19
%21 = add nsw i32 %20, %18
store i32 %21, i32* %19
br label %22
22: ; preds = %14, %5
%23 = phi i64 [ %7, %5 ], [ %15, %14 ]
%24 = icmp eq i64 %6, 0
br i1 %24, label %25, label %28
25: ; preds = %28, %22
%26 = icmp eq i64 %8, 21
%27 = add i64 %6, 1
br i1 %26, label %45, label %5
28: ; preds = %22, %28
%29 = phi i64 [ %37, %28 ], [ %23, %22 ]
%30 = add nsw i64 %29, -1
%31 = and i64 %30, 4294967295
%32 = getelementptr inbounds i32, i32* %1, i64 %31
%33 = load i32, i32* %32
%34 = getelementptr inbounds i32, i32* %1, i64 %29
%35 = load i32, i32* %34
%36 = add nsw i32 %35, %33
store i32 %36, i32* %34
%37 = add nsw i64 %29, -2
%38 = and i64 %37, 4294967295
%39 = getelementptr inbounds i32, i32* %1, i64 %38
%40 = load i32, i32* %39
%41 = getelementptr inbounds i32, i32* %1, i64 %30
%42 = load i32, i32* %41
%43 = add nsw i32 %42, %40
store i32 %43, i32* %41
%44 = icmp sgt i64 %29, 2
br i1 %44, label %28, label %25
45: ; preds = %25
ret i32 0
}