#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 factorial(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int main(int argc, char const *argv[]) {
  unsigned int start;
  printf("Conjetura Collatz: ");
  scanf("%u", &start);
  printf("%u\n", start);
  while (start != 1 && start) {
    if (!(start % 2)) {
      start /= 2;
      printf("%u\n", start);
    } else {
      start = start * 3 + 1;
      printf("%u\n", start);
    }
  }
  printf("Pascal Triangle: ");
  scanf("%u", &start);
  for (int i = 0; i < start; i++) {
    for (int j = 0; j < start - i; j++) {
      printf(" ");
    }
    for (int j = 1; j <= i + 1; j++) {
      printf("%d ", factorial(i) / (factorial(i - j + 1) * factorial(j - 1)));
    }
    printf("\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x14(%rbp),%esi
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
cmpl   $0x1,-0x14(%rbp)
mov    %al,-0x21(%rbp)
je     118e <main+0x5e>
cmpl   $0x0,-0x14(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    119e <main+0x6e>
jmp    11ec <main+0xbc>
mov    -0x14(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11cc <main+0x9c>
mov    -0x14(%rbp),%eax
shr    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e7 <main+0xb7>
imul   $0x3,-0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1175 <main+0x45>
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe13(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    12d8 <main+0x1a8>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
cmp    %ecx,%eax
jae    1251 <main+0x121>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1224 <main+0xf4>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     12bc <main+0x18c>
mov    -0x18(%rbp),%edi
call   1030 <factorial@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%edi
sub    -0x20(%rbp),%edi
add    $0x1,%edi
call   1030 <factorial@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%edi
sub    $0x1,%edi
call   1030 <factorial@plt>
mov    -0x2c(%rbp),%ecx
mov    %eax,%edx
mov    -0x28(%rbp),%eax
imul   %edx,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1258 <main+0x128>
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1211 <main+0xe1>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb4(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%esi
lea    0xea5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%eax
cmp    $0x2,%eax
jb     11b2 <main+0x72>
lea    0xe8f(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %eax,%ecx
shr    %ecx
test   $0x1,%al
lea    0x1(%rax,%rax,2),%esi
cmove  %ecx,%esi
mov    %esi,(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%eax
cmp    $0x1,%eax
ja     1190 <main+0x50>
lea    0xe62(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe4d(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%eax
test   %eax,%eax
je     1288 <main+0x148>
lea    0xe4c(%rip),%r14
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    %r15d,%eax
je     1217 <main+0xd7>
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x20,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
mov    (%rsp),%eax
sub    %r15d,%eax
cmp    %eax,%ebx
jb     1200 <main+0xc0>
lea    0x1(%r15),%eax
mov    %eax,0x4(%rsp)
xor    %ebp,%ebp
mov    %r15d,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15d,%edi
call   1040 <factorial@plt>
mov    %eax,%r12d
mov    %ebx,%edi
call   1040 <factorial@plt>
mov    %eax,%r13d
mov    %ebp,%edi
call   1040 <factorial@plt>
mov    %eax,%ecx
imul   %r13d,%ecx
mov    %r12d,%eax
cltd
idiv   %ecx
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%ebp
add    $0xffffffff,%ebx
jb     1230 <main+0xf0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    (%rsp),%eax
mov    0x4(%rsp),%ecx
mov    %ecx,%r15d
cmp    %eax,%ecx
jb     11f0 <main+0xb0>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Conjetura Collatz: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [4 x i8] c"%u\0A\00"
@.str.3 = [18 x i8] c"Pascal Triangle: \00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [4 x i8] c"%d \00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%12 = load i32, i32* %6
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %37, %2
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 1
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 0
br label %20
20: ; preds = %17, %14
%21 = phi i1 [ false, %14 ], [ %19, %17 ]
br i1 %21, label %22, label %38
22: ; preds = %20
%23 = load i32, i32* %6
%24 = urem i32 %23, 2
%25 = icmp ne i32 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %22
%27 = load i32, i32* %6
%28 = udiv i32 %27, 2
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %37
31: ; preds = %22
%32 = load i32, i32* %6
%33 = mul i32 %32, 3
%34 = add i32 %33, 1
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %31, %26
br label %14
38: ; preds = %20
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%40 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
store i32 0, i32* %7
br label %41
41: ; preds = %82, %38
%42 = load i32, i32* %7
%43 = load i32, i32* %6
%44 = icmp ult i32 %42, %43
br i1 %44, label %45, label %85
45: ; preds = %41
store i32 0, i32* %8
br label %46
46: ; preds = %54, %45
%47 = load i32, i32* %8
%48 = load i32, i32* %6
%49 = load i32, i32* %7
%50 = sub i32 %48, %49
%51 = icmp ult i32 %47, %50
br i1 %51, label %52, label %57
52: ; preds = %46
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %54
54: ; preds = %52
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
store i32 %56, i32* %8
br label %46
57: ; preds = %46
store i32 1, i32* %9
br label %58
58: ; preds = %77, %57
%59 = load i32, i32* %9
%60 = load i32, i32* %7
%61 = add nsw i32 %60, 1
%62 = icmp sle i32 %59, %61
br i1 %62, label %63, label %80
63: ; preds = %58
%64 = load i32, i32* %7
%65 = call i32 @factorial(i32 %64)
%66 = load i32, i32* %7
%67 = load i32, i32* %9
%68 = sub nsw i32 %66, %67
%69 = add nsw i32 %68, 1
%70 = call i32 @factorial(i32 %69)
%71 = load i32, i32* %9
%72 = sub nsw i32 %71, 1
%73 = call i32 @factorial(i32 %72)
%74 = mul nsw i32 %70, %73
%75 = sdiv i32 %65, %74
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %63
%78 = load i32, i32* %9
%79 = add nsw i32 %78, 1
store i32 %79, i32* %9
br label %58
80: ; preds = %58
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
br label %82
82: ; preds = %80
%83 = load i32, i32* %7
%84 = add nsw i32 %83, 1
store i32 %84, i32* %7
br label %41
85: ; preds = %41
ret i32 0
}

LLVM IR (-O2):
@.str = [20 x i8] c"Conjetura Collatz: \00"
@.str.1 = [3 x i8] c"%u\00"
@.str.2 = [4 x i8] c"%u\0A\00"
@.str.3 = [18 x i8] c"Pascal Triangle: \00"
@.str.5 = [4 x i8] c"%d \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %3
%10 = icmp ult i32 %9, 2
br i1 %10, label %22, label %11
11: ; preds = %2, %11
%12 = phi i32 [ %20, %11 ], [ %9, %2 ]
%13 = and i32 %12, 1
%14 = icmp eq i32 %13, 0
%15 = mul i32 %12, 3
%16 = add i32 %15, 1
%17 = lshr i32 %12, 1
%18 = select i1 %14, i32 %17, i32 %16
store i32 %18, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %3
%21 = icmp ult i32 %20, 2
br i1 %21, label %22, label %11
22: ; preds = %11, %2
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %22, %42
%28 = phi i32 [ %44, %42 ], [ %25, %22 ]
%29 = phi i32 [ %46, %42 ], [ 2, %22 ]
%30 = phi i32 [ %34, %42 ], [ 0, %22 ]
%31 = icmp eq i32 %28, %30
br i1 %31, label %33, label %35
32: ; preds = %42, %22
ret i32 0
33: ; preds = %35, %27
%34 = add nuw i32 %30, 1
br label %47
35: ; preds = %27, %35
%36 = phi i32 [ %38, %35 ], [ 0, %27 ]
%37 = call i32 @putchar(i32 32)
%38 = add nuw nsw i32 %36, 1
%39 = load i32, i32* %3
%40 = sub i32 %39, %30
%41 = icmp ult i32 %38, %40
br i1 %41, label %35, label %33
42: ; preds = %47
%43 = call i32 @putchar(i32 10)
%44 = load i32, i32* %3
%45 = icmp ult i32 %34, %44
%46 = add i32 %29, 1
br i1 %45, label %27, label %32
47: ; preds = %33, %47
%48 = phi i32 [ 1, %33 ], [ %57, %47 ]
%49 = call i32 @factorial(i32 %30)
%50 = sub i32 %34, %48
%51 = call i32 @factorial(i32 %50)
%52 = add nsw i32 %48, -1
%53 = call i32 @factorial(i32 %52)
%54 = mul nsw i32 %53, %51
%55 = sdiv i32 %49, %54
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %55)
%57 = add nuw i32 %48, 1
%58 = icmp eq i32 %57, %29
br i1 %58, label %42, label %47
}