#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 */
uint32_t add_rational(int32_t numerator, int32_t denominator, uint8_t *buffer,
                      uint32_t *data_offset) {
  uint32_t result = *data_offset;
  *(int32_t *)(buffer + *data_offset) = numerator;
  *data_offset += sizeof(int32_t);
  *(int32_t *)(buffer + *data_offset) = denominator;
  *data_offset += sizeof(int32_t);
  return result;
}


x86 assembly (clang, -O0):
<add_rational>:
push   %rbp
mov    %rsp,%rbp
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    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq (%rax),%rcx
add    $0x4,%rcx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
movslq (%rax),%rcx
add    $0x4,%rcx
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_rational>:
movslq (%rcx),%rax
mov    %edi,(%rdx,%rax,4)
mov    (%rcx),%edi
add    $0x4,%edi
mov    %edi,(%rcx)
movslq %edi,%rdi
mov    %esi,(%rdx,%rdi,4)
addl   $0x4,(%rcx)
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* %5
%13 = load i32*, i32** %7
%14 = load i32*, i32** %8
%15 = load i32, i32* %14
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %13, i64 %16
store i32 %12, i32* %17
%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* %6
%24 = load i32*, i32** %7
%25 = load i32*, i32** %8
%26 = load i32, i32* %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %24, i64 %27
store i32 %23, i32* %28
%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* nocapture writeonly %2, i32* nocapture %3) {
%5 = load i32, i32* %3
%6 = sext i32 %5 to i64
%7 = getelementptr inbounds i32, i32* %2, i64 %6
store i32 %0, i32* %7
%8 = load i32, i32* %3
%9 = add i32 %8, 4
store i32 %9, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds i32, i32* %2, i64 %10
store i32 %1, i32* %11
%12 = load i32, i32* %3
%13 = add i32 %12, 4
store i32 %13, i32* %3
ret i32 %5
}