#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
typedef TYPE_1__ *XdmcpBufferPtr;
struct TYPE_3__ {
  scalar_t__ pointer;
  scalar_t__ size;
  scalar_t__ *data;
};
typedef scalar_t__ BYTE;

/* Variables and functions */
int FALSE;
int TRUE;
int XdmcpWriteCARD8(XdmcpBufferPtr buffer, unsigned value) {
  if (buffer->pointer >= buffer->size)
    return FALSE;
  buffer->data[buffer->pointer++] = (BYTE)value;
  return TRUE;
}


x86 assembly (clang, -O0):
<XdmcpWriteCARD8>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
cmp    0x8(%rcx),%rax
jl     1131 <XdmcpWriteCARD8+0x31>
mov    0x2eb1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    115f <XdmcpWriteCARD8+0x5f>
mov    -0x14(%rbp),%eax
mov    %eax,%edx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x10(%rbp),%rsi
mov    (%rsi),%rcx
mov    %rcx,%rdi
add    $0x1,%rdi
mov    %rdi,(%rsi)
mov    %rdx,(%rax,%rcx,8)
mov    0x2e8e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<XdmcpWriteCARD8>:
mov    (%rdi),%rax
cmp    0x8(%rdi),%rax
jge    1124 <XdmcpWriteCARD8+0x24>
mov    %esi,%ecx
mov    0x10(%rdi),%rdx
lea    0x1(%rax),%rsi
mov    %rsi,(%rdi)
mov    %rcx,(%rdx,%rax,8)
mov    0x2ec7(%rip),%rax
mov    (%rax),%eax
ret
mov    0x2ead(%rip),%rax
mov    (%rax),%eax
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64, i64, i64* }
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @XdmcpWriteCARD8(%struct.TYPE_3__* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.TYPE_3__*
%5 = alloca i32
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %4
store i32 %1, i32* %5
%6 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %6, i32 0, i32 0
%8 = load i64, i64* %7
%9 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %9, i32 0, i32 1
%11 = load i64, i64* %10
%12 = icmp sge i64 %8, %11
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = load i32, i32* @FALSE
store i32 %14, i32* %3
br label %27
15: ; preds = %2
%16 = load i32, i32* %5
%17 = zext i32 %16 to i64
%18 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 2
%20 = load i64*, i64** %19
%21 = load %struct.TYPE_3__*, %struct.TYPE_3__** %4
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %21, i32 0, i32 0
%23 = load i64, i64* %22
%24 = add nsw i64 %23, 1
store i64 %24, i64* %22
%25 = getelementptr inbounds i64, i64* %20, i64 %23
store i64 %17, i64* %25
%26 = load i32, i32* @TRUE
store i32 %26, i32* %3
br label %27
27: ; preds = %15, %13
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i64, i64* }
@FALSE = global i32 0
@TRUE = global i32 0
define i32 @XdmcpWriteCARD8(%struct.TYPE_3__* nocapture %0, i32 %1) {
%3 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%4 = load i64, i64* %3
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%6 = load i64, i64* %5
%7 = icmp slt i64 %4, %6
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = zext i32 %1 to i64
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 2
%11 = load i64*, i64** %10
%12 = add nsw i64 %4, 1
store i64 %12, i64* %3
%13 = getelementptr inbounds i64, i64* %11, i64 %4
store i64 %9, i64* %13
br label %14
14: ; preds = %2, %8
%15 = phi i32* [ @TRUE, %8 ], [ @FALSE, %2 ]
%16 = load i32, i32* %15
ret i32 %16
}