#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 atoi(char *);
int /*<<< orphan*/ binary(int *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(int *);
scalar_t__ malloc(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  int n;
  int *vet;
  if (argc != 2) {
    fprintf(stderr, "Errore numero argomenti.\n");
    return -1;
  }
  n = atoi(argv[1]);
  vet = (int *)malloc(n * sizeof(int));
  if (vet == NULL) {
    fprintf(stderr, "Errore allocazione vet.\n");
    return -2;
  }
  fprintf(stdout, "Numeri binari: \n");
  binary(vet, n);
  free(vet);
  return 0;
}


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)
cmpl   $0x2,-0x8(%rbp)
je     1191 <main+0x41>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe80(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <main+0xc1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e0 <main+0x90>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe4b(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1211 <main+0xc1>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
lea    0xe43(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <binary@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
cmp    $0x2,%edi
jne    11a6 <main+0x56>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%r14d
lea    0x0(,%r14,4),%edi
call   1060 <malloc@plt>
test   %rax,%rax
je     11c2 <main+0x72>
mov    %rax,%rbx
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xea9(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14d,%esi
call   1040 <binary@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
jmp    11dc <main+0x8c>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
jmp    11dc <main+0x8c>
mov    0x2e17(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xfffffffe,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [26 x i8] c"Errore numero argomenti.\0A\00"
@.str.1 = [25 x i8] c"Errore allocazione vet.\0A\00"
@stdout = global i32 0
@.str.2 = [17 x i8] c"Numeri binari: \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 2
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %37
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = mul i64 %19, 4
%21 = trunc i64 %20 to i32
%22 = call i64 @malloc(i32 %21)
%23 = inttoptr i64 %22 to i32*
store i32* %23, i32** %7
%24 = load i32*, i32** %7
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %29
26: ; preds = %13
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
store i32 -2, i32* %3
br label %37
29: ; preds = %13
%30 = load i32, i32* @stdout
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32*, i32** %7
%33 = load i32, i32* %6
%34 = call i32 @binary(i32* %32, i32 %33)
%35 = load i32*, i32** %7
%36 = call i32 @free(i32* %35)
store i32 0, i32* %3
br label %37
37: ; preds = %29, %26, %10
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [26 x i8] c"Errore numero argomenti.\0A\00"
@.str.1 = [25 x i8] c"Errore allocazione vet.\0A\00"
@stdout = global i32 0
@.str.2 = [17 x i8] c"Numeri binari: \0A\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 i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %23
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i32 @atoi(i8* %9)
%11 = shl i32 %10, 2
%12 = tail call i64 @malloc(i32 %11)
%13 = inttoptr i64 %12 to i32*
%14 = icmp eq i64 %12, 0
br i1 %14, label %15, label %18
15: ; preds = %7
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
br label %23
18: ; preds = %7
%19 = load i32, i32* @stdout
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @binary(i32* %13, i32 %10)
%22 = tail call i32 @free(i32* %13)
br label %23
23: ; preds = %18, %15, %4
%24 = phi i32 [ -1, %4 ], [ -2, %15 ], [ 0, %18 ]
ret i32 %24
}