#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*/ uint8_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
uint32_t add_rational(int32_t numerator, int32_t denominator, uint8_t *buffer,
                      uint32_t *data_offset) {
  uint32_t result = *data_offset;
  memcpy(buffer + *data_offset, &numerator, sizeof(int32_t));
  *data_offset += sizeof(int32_t);
  memcpy(buffer + *data_offset, &denominator, sizeof(int32_t));
  *data_offset += sizeof(int32_t);
  return result;
}


x86 assembly (clang, -O0):
<add_rational>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
add    %rax,%rdi
lea    -0x4(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
movslq (%rax),%rcx
add    $0x4,%rcx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq (%rax),%rax
shl    $0x2,%rax
add    %rax,%rdi
lea    -0x8(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    -0x18(%rbp),%rax
movslq (%rax),%rcx
add    $0x4,%rcx
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_rational>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %edi,0xc(%rsp)
mov    %esi,0x8(%rsp)
movslq (%rcx),%r15
lea    (%rdx,%r15,4),%rdi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    (%rbx),%eax
add    $0x4,%eax
mov    %eax,(%rbx)
cltq
lea    (%r14,%rax,4),%rdi
lea    0x8(%rsp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
addl   $0x4,(%rbx)
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @add_rational(i32 %0, i32 %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%10 = load i32*, i32** %8
%11 = load i32, i32* %10
store i32 %11, i32* %9
%12 = load i32*, i32** %7
%13 = load i32*, i32** %8
%14 = load i32, i32* %13
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %12, i64 %15
%17 = call i32 @memcpy(i32* %16, i32* %5, i32 4)
%18 = load i32*, i32** %8
%19 = load i32, i32* %18
%20 = sext i32 %19 to i64
%21 = add i64 %20, 4
%22 = trunc i64 %21 to i32
store i32 %22, i32* %18
%23 = load i32*, i32** %7
%24 = load i32*, i32** %8
%25 = load i32, i32* %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %23, i64 %26
%28 = call i32 @memcpy(i32* %27, i32* %6, i32 4)
%29 = load i32*, i32** %8
%30 = load i32, i32* %29
%31 = sext i32 %30 to i64
%32 = add i64 %31, 4
%33 = trunc i64 %32 to i32
store i32 %33, i32* %29
%34 = load i32, i32* %9
ret i32 %34
}

LLVM IR (-O2):
define i32 @add_rational(i32 %0, i32 %1, i32* %2, i32* nocapture %3) {
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
%7 = load i32, i32* %3
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %2, i64 %8
%10 = call i32 @memcpy(i32* %9, i32* %5, i32 4)
%11 = load i32, i32* %3
%12 = add i32 %11, 4
store i32 %12, i32* %3
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %2, i64 %13
%15 = call i32 @memcpy(i32* %14, i32* %6, i32 4)
%16 = load i32, i32* %3
%17 = add i32 %16, 4
store i32 %17, i32* %3
ret i32 %7
}