#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 contar_primos(int /*<<< orphan*/, int);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stderr;
char *strerror(scalar_t__);
int strtoull(char *, int /*<<< orphan*/ *, int);
int main(int argc, char *argv[]) {
  int max;
  if (argc < 2) {
    fprintf(stderr, "Uso: %s parametro_numerico\n", argv[0]);
    return 1;
  }
  max = strtoull(argv[1], NULL, 10);
  if (errno) {
    fprintf(stderr, "%s: parametro %s: %s\n", argv[0], argv[1],
            strerror(errno));
    return 2;
  }
  printf("Contando primos hasta el %i\n", max);
  printf("Hay %i primos hasta el %i\n", contar_primos(0, max), max);
}


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)
cmpl   $0x2,-0x8(%rbp)
jge    119a <main+0x4a>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    124c <main+0xfc>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1040 <strtoull@plt>
mov    %eax,-0x14(%rbp)
mov    0x2e1e(%rip),%rax
cmpq   $0x0,(%rax)
je     121e <main+0xce>
mov    0x2e15(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    0x2dea(%rip),%rax
mov    (%rax),%rdi
call   1070 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    %rax,%r8
lea    0xe11(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
jmp    124c <main+0xfc>
mov    -0x14(%rbp),%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
xor    %edi,%edi
call   1050 <contar_primos@plt>
mov    %eax,%esi
mov    -0x14(%rbp),%edx
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
cmp    $0x1,%edi
jg     1181 <main+0x31>
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xe91(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x1,%r14d
jmp    1206 <main+0xb6>
mov    0x8(%rbx),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <strtoull@plt>
mov    %eax,%ebp
mov    0x2e3b(%rip),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     11db <main+0x8b>
mov    0x2e34(%rip),%rax
mov    (%rax),%ebp
mov    (%rbx),%r14
mov    0x8(%rbx),%rbx
call   1070 <strerror@plt>
lea    0xe5b(%rip),%rsi
mov    %ebp,%edi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0x2,%r14d
jmp    1206 <main+0xb6>
lea    0xe50(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %edi,%edi
mov    %ebp,%esi
call   1050 <contar_primos@plt>
lea    0xe54(%rip),%rdi
mov    %eax,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Uso: %s parametro_numerico\0A\00"
@errno = global i64 0
@.str.1 = [22 x i8] c"%s: parametro %s: %s\0A\00"
@.str.2 = [29 x i8] c"Contando primos hasta el %i\0A\00"
@.str.3 = [27 x i8] c"Hay %i primos hasta el %i\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13)
store i32 1, i32* %3
br label %40
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @strtoull(i8* %18, i32* null, i32 10)
store i32 %19, i32* %6
%20 = load i64, i64* @errno
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %33
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 0
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = load i64, i64* @errno
%31 = call i8* @strerror(i64 %30)
%32 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %26, i8* %29, i8* %31)
store i32 2, i32* %3
br label %40
33: ; preds = %15
%34 = load i32, i32* %6
%35 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %6
%37 = call i32 @contar_primos(i32 0, i32 %36)
%38 = load i32, i32* %6
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %37, i32 %38)
br label %40
40: ; preds = %33, %22, %9
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Uso: %s parametro_numerico\0A\00"
@errno = global i64 0
@.str.1 = [22 x i8] c"%s: parametro %s: %s\0A\00"
@.str.2 = [29 x i8] c"Contando primos hasta el %i\0A\00"
@.str.3 = [27 x i8] c"Hay %i primos hasta el %i\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %1
%7 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %24
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32 @strtoull(i8* nocapture %10, i32* null, i32 10)
%12 = load i64, i64* @errno
%13 = icmp eq i64 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %8
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = load i8*, i8** %9
%18 = tail call i8* @strerror(i64 %12)
%19 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %17, i8* %18)
br label %24
20: ; preds = %8
%21 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%22 = tail call i32 @contar_primos(i32 0, i32 %11)
%23 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %11)
br label %24
24: ; preds = %20, %14, %4
%25 = phi i32 [ 1, %4 ], [ 2, %14 ], [ 0, %20 ]
ret i32 %25
}