#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ STDOUT_FILENO;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ snprintf(char *, int, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
scalar_t__ write(int /*<<< orphan*/, char *, int /*<<< orphan*/);
void print_line(int n) {
  char buf[64];
  snprintf(buf, sizeof(buf), "Redirezione con dup2() - Linea '%d'\n", n);
  if (write(STDOUT_FILENO, buf, strlen(buf)) < 0) {
    fprintf(stderr, "Err.(%s) write() failed\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<print_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x50(%rbp),%rdi
mov    -0x4(%rbp),%ecx
mov    $0x40,%esi
lea    0xe82(%rip),%rdx
call   1050 <snprintf@plt>
mov    0x2e66(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
cmp    $0x0,%rax
jge    11f2 <print_line+0x92>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2e05(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x60(%rbp),%edi
mov    %rax,%rdx
lea    0xe46(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_line>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
mov    %edi,%ecx
lea    0xe91(%rip),%rdx
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1050 <snprintf@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
test   %rax,%rax
js     11a8 <print_line+0x48>
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2e29(%rip),%rax
mov    (%rax),%ebx
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe5f(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1060 <fprintf@plt>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [37 x i8] c"Redirezione con dup2() - Linea '%d'\0A\00"
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str.1 = [25 x i8] c"Err.(%s) write() failed\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @print_line(i32 %0) {
%2 = alloca i32
%3 = alloca [64 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* %2
%6 = call i32 @snprintf(i8* %4, i32 64, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = load i32, i32* @STDOUT_FILENO
%8 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = call i64 @write(i32 %7, i8* %8, i32 %10)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %1
%14 = load i32, i32* @stderr
%15 = load i32, i32* @errno
%16 = call i8* @strerror(i32 %15)
%17 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %1
ret void
}

LLVM IR (-O2):
@.str = [37 x i8] c"Redirezione con dup2() - Linea '%d'\0A\00"
@STDOUT_FILENO = global i32 0
@stderr = global i32 0
@.str.1 = [25 x i8] c"Err.(%s) write() failed\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @print_line(i32 %0) {
%2 = alloca [64 x i8]
%3 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%4 = call i32 @snprintf(i8* %3, i32 64, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 %0)
%5 = load i32, i32* @STDOUT_FILENO
%6 = call i32 @strlen(i8* %3)
%7 = call i64 @write(i32 %5, i8* %3, i32 %6)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = call i8* @strerror(i32 %11)
%13 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = call i32 @exit(i32 %14)
unreachable
16: ; preds = %1
ret void
}