#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 write_raw_byte(char, void *, int);
int write_raw_bytes(char *bytes, int bytes_size, void *_buffer, int offset) {
  int i;
  for (i = 0; i < bytes_size; ++i) {
    offset = write_raw_byte((char)*(bytes + i), _buffer, offset);
  }
  return offset;
}


x86 assembly (clang, -O0):
<write_raw_bytes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1164 <write_raw_bytes+0x54>
mov    -0x8(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movsbl %al,%edi
call   1030 <write_raw_byte@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112d <write_raw_bytes+0x1d>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_raw_bytes>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %ecx,%eax
test   %esi,%esi
jle    1148 <write_raw_bytes+0x38>
mov    %rdx,%r14
mov    %rdi,%r15
mov    %esi,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%r15,%rbx,1),%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write_raw_byte@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1130 <write_raw_bytes+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

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