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

/* Variables and functions */
int /*<<< orphan*/ elfrw_write_Phdr(int /*<<< orphan*/ *,
                                    int /*<<< orphan*/ const *);
int elfrw_write_Phdrs(FILE *fp, Elf64_Phdr const *out, int count) {
  int i;
  for (i = 0; i < count; ++i)
    if (!elfrw_write_Phdr(fp, &out[i]))
      break;
  return i;
}


x86 assembly (clang, -O0):
<elfrw_write_Phdrs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    116f <elfrw_write_Phdrs+0x5f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x18(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <elfrw_write_Phdr@plt>
cmp    $0x0,%eax
jne    115c <elfrw_write_Phdrs+0x4c>
jmp    116f <elfrw_write_Phdrs+0x5f>
jmp    1161 <elfrw_write_Phdrs+0x51>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <elfrw_write_Phdrs+0x1a>
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elfrw_write_Phdrs>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1151 <elfrw_write_Phdrs+0x41>
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %edx,%r12d
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <elfrw_write_Phdr@plt>
test   %eax,%eax
je     1154 <elfrw_write_Phdrs+0x44>
add    $0x1,%r14
add    $0x4,%rbx
cmp    %r14,%r12
jne    1130 <elfrw_write_Phdrs+0x20>
mov    %r12d,%r14d
jmp    1154 <elfrw_write_Phdrs+0x44>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @elfrw_write_Phdrs(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
store i32 0, i32* %7
br label %8
8: ; preds = %22, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = load i32*, i32** %4
%14 = load i32*, i32** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = call i32 @elfrw_write_Phdr(i32* %13, i32* %17)
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %12
br label %25
21: ; preds = %12
br label %22
22: ; preds = %21
%23 = load i32, i32* %7
%24 = add nsw i32 %23, 1
store i32 %24, i32* %7
br label %8
25: ; preds = %20, %8
%26 = load i32, i32* %7
ret i32 %26
}

LLVM IR (-O2):
define i32 @elfrw_write_Phdrs(i32* %0, i32* %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %17
5: ; preds = %3
%6 = zext i32 %2 to i64
br label %7
7: ; preds = %5, %12
%8 = phi i64 [ 0, %5 ], [ %13, %12 ]
%9 = getelementptr inbounds i32, i32* %1, i64 %8
%10 = tail call i32 @elfrw_write_Phdr(i32* %0, i32* %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %15, label %12
12: ; preds = %7
%13 = add nuw nsw i64 %8, 1
%14 = icmp eq i64 %13, %6
br i1 %14, label %17, label %7
15: ; preds = %7
%16 = trunc i64 %8 to i32
br label %17
17: ; preds = %12, %15, %3
%18 = phi i32 [ 0, %3 ], [ %16, %15 ], [ %2, %12 ]
ret i32 %18
}