#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 /*<<< orphan*/ putc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
size_t print_output(int *buffer, size_t n) {
  for (size_t i = 0; i < n; i++) {
    putc(buffer[i], stderr);
    putc(buffer[i], stdout);
  }
  return n;
}


x86 assembly (clang, -O0):
<print_output>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    1179 <print_output+0x69>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2e98(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    0x2e77(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1128 <print_output+0x18>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_output>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
test   %rsi,%rsi
je     1163 <print_output+0x53>
mov    %rdi,%r15
xor    %ebx,%ebx
mov    0x2eb3(%rip),%r12
mov    0x2ea4(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    (%r15,%rbx,4),%edi
mov    (%r12),%esi
call   1030 <putc@plt>
mov    (%r15,%rbx,4),%edi
mov    0x0(%r13),%esi
call   1030 <putc@plt>
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1140 <print_output+0x30>
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@stderr = global i32 0
@stdout = global i32 0
define i64 @print_output(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
store i64 0, i64* %5
br label %6
6: ; preds = %23, %2
%7 = load i64, i64* %5
%8 = load i64, i64* %4
%9 = icmp ult i64 %7, %8
br i1 %9, label %10, label %26
10: ; preds = %6
%11 = load i32*, i32** %3
%12 = load i64, i64* %5
%13 = getelementptr inbounds i32, i32* %11, i64 %12
%14 = load i32, i32* %13
%15 = load i32, i32* @stderr
%16 = call i32 @putc(i32 %14, i32 %15)
%17 = load i32*, i32** %3
%18 = load i64, i64* %5
%19 = getelementptr inbounds i32, i32* %17, i64 %18
%20 = load i32, i32* %19
%21 = load i32, i32* @stdout
%22 = call i32 @putc(i32 %20, i32 %21)
br label %23
23: ; preds = %10
%24 = load i64, i64* %5
%25 = add i64 %24, 1
store i64 %25, i64* %5
br label %6
26: ; preds = %6
%27 = load i64, i64* %4
ret i64 %27
}

LLVM IR (-O2):
@stderr = global i32 0
@stdout = global i32 0
define i64 @print_output(i32* nocapture %0, i64 returned %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %4, label %5
4: ; preds = %5, %2
ret i64 %1
5: ; preds = %2, %5
%6 = phi i64 [ %14, %5 ], [ 0, %2 ]
%7 = getelementptr inbounds i32, i32* %0, i64 %6
%8 = load i32, i32* %7
%9 = load i32, i32* @stderr
%10 = tail call i32 @putc(i32 %8, i32 %9)
%11 = load i32, i32* %7
%12 = load i32, i32* @stdout
%13 = tail call i32 @putc(i32 %11, i32 %12)
%14 = add nuw i64 %6, 1
%15 = icmp eq i64 %14, %1
br i1 %15, label %4, label %5
}