#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*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fd_printf(int, char *, int /*<<< orphan*/);
int write_int64_t_array(int fd, int64_t *arr, int n) {
  int i;
  assert(fd > 1 && "Invalid file descriptor");
  for (i = 0; i < n; i++) {
    fd_printf(fd,
              "%"
              "lld"
              "\n",
              arr[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<write_int64_t_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x4(%rbp)
mov    %al,-0x19(%rbp)
jle    114b <write_int64_t_array+0x2b>
mov    $0x1,%al
mov    %al,-0x19(%rbp)
jmp    114b <write_int64_t_array+0x2b>
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1193 <write_int64_t_array+0x73>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
lea    0xe98(%rip),%rsi
call   1040 <fd_printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115f <write_int64_t_array+0x3f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_int64_t_array>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%r12d
xor    %edi,%edi
cmp    $0x2,%r12d
setge  %dil
call   1030 <assert@plt>
test   %r14d,%r14d
jle    1178 <write_int64_t_array+0x58>
mov    %r14d,%ebx
xor    %ebp,%ebp
lea    0xeaf(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r15,%rbp,4),%edx
mov    %r12d,%edi
mov    %r14,%rsi
call   1040 <fd_printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1160 <write_int64_t_array+0x40>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"Invalid file descriptor\00"
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @write_int64_t_array(i32 %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i32 %2, i32* %6
%8 = load i32, i32* %4
%9 = icmp sgt i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %3
br label %11
11: ; preds = %10, %3
%12 = phi i1 [ false, %3 ], [ true, %10 ]
%13 = zext i1 %12 to i32
%14 = call i32 @assert(i32 %13)
store i32 0, i32* %7
br label %15
15: ; preds = %27, %11
%16 = load i32, i32* %7
%17 = load i32, i32* %6
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %30
19: ; preds = %15
%20 = load i32, i32* %4
%21 = load i32*, i32** %5
%22 = load i32, i32* %7
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = call i32 @fd_printf(i32 %20, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %19
%28 = load i32, i32* %7
%29 = add nsw i32 %28, 1
store i32 %29, i32* %7
br label %15
30: ; preds = %15
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%lld\0A\00"
define i32 @write_int64_t_array(i32 %0, i32* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %0, 1
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = icmp sgt i32 %2, 0
br i1 %7, label %8, label %17
8: ; preds = %3
%9 = zext i32 %2 to i64
br label %10
10: ; preds = %8, %10
%11 = phi i64 [ 0, %8 ], [ %15, %10 ]
%12 = getelementptr inbounds i32, i32* %1, i64 %11
%13 = load i32, i32* %12
%14 = tail call i32 @fd_printf(i32 %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = add nuw nsw i64 %11, 1
%16 = icmp eq i64 %15, %9
br i1 %16, label %17, label %10
17: ; preds = %10, %3
ret i32 0
}