#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 */
long atol(char *);
int collatz(long, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  long inicio = 1;
  int cod_salida = 0;
  if (argc != 2) {
    printf("Error -> Llamada correcta: \n\t%s <número_inicial>\n", argv[0]);
    return -1;
  }
  inicio = atol(argv[1]);
  printf("\nNúmero inicial: %li\n", inicio);
  if ((cod_salida = collatz(inicio, 0)) == 0) {
    printf("\n---- FIN DE LA SERIE ----\n");
  }
  return cod_salida;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1180 <main+0x50>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ce <main+0x9e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
call   1030 <collatz@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jne    11c8 <main+0x98>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    1173 <main+0x33>
mov    0x8(%rsi),%rdi
call   1060 <atol@plt>
mov    %rax,%rbx
lea    0xeda(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <collatz@plt>
test   %eax,%eax
je     118b <main+0x4b>
pop    %rbx
ret
mov    (%rsi),%rsi
lea    0xe83(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
lea    0xeb8(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [51 x i8] c"Error -> Llamada correcta: \0A\09%s <n\C3\BAmero_inicial>\0A\00"
@.str.1 = [23 x i8] c"\0AN\C3\BAmero inicial: %li\0A\00"
@.str.2 = [28 x i8] c"\0A---- FIN DE LA SERIE ----\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 1, i64* %6
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 -1, i32* %3
br label %29
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i64 @atol(i8* %18)
store i64 %19, i64* %6
%20 = load i64, i64* %6
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %20)
%22 = load i64, i64* %6
%23 = call i32 @collatz(i64 %22, i32 0)
store i32 %23, i32* %7
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %15
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %27
27: ; preds = %25, %15
%28 = load i32, i32* %7
store i32 %28, i32* %3
br label %29
29: ; preds = %27, %10
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@.str = [51 x i8] c"Error -> Llamada correcta: \0A\09%s <n\C3\BAmero_inicial>\0A\00"
@.str.1 = [23 x i8] c"\0AN\C3\BAmero inicial: %li\0A\00"
@str = [27 x i8] c"\0A---- FIN DE LA SERIE ----\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %16
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @atol(i8* %9)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %10)
%12 = tail call i32 @collatz(i64 %10, i32 0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %7
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
br label %16
16: ; preds = %7, %14, %4
%17 = phi i32 [ -1, %4 ], [ 0, %14 ], [ %12, %7 ]
ret i32 %17
}