#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 /*<<< orphan*/ ctr128_inc(unsigned char *);
void ctr128_inc_aligned(unsigned char *counter) {
  size_t *data, c, n;
  const union {
    long one;
    char little;
  } is_endian = {1};
  if (is_endian.little) {
    ctr128_inc(counter);
    return;
  }
  data = (size_t *)counter;
  n = 16 / sizeof(size_t);
  do {
    --n;
    c = data[n];
    ++c;
    data[n] = c;
    if (c)
      return;
  } while (n);
}


x86 assembly (clang, -O0):
<ctr128_inc_aligned>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x28(%rbp)
cmpb   $0x0,-0x28(%rbp)
je     113f <ctr128_inc_aligned+0x2f>
mov    -0x8(%rbp),%rdi
call   1030 <ctr128_inc@plt>
jmp    11a7 <ctr128_inc_aligned+0x97>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
movq   $0x2,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
cmpq   $0x0,-0x18(%rbp)
je     1197 <ctr128_inc_aligned+0x87>
jmp    11a7 <ctr128_inc_aligned+0x97>
jmp    119c <ctr128_inc_aligned+0x8c>
cmpq   $0x0,-0x20(%rbp)
jne    114f <ctr128_inc_aligned+0x3f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ctr128_inc_aligned>:
jmp    1030 <ctr128_inc@plt>

LLVM IR (-O0):
%union.anon = type { i64 }
@__const.ctr128_inc_aligned.is_endian = %union.anon { i64 1 }
define void @ctr128_inc_aligned(i8* %0) {
%2 = alloca i8*
%3 = alloca i64*
%4 = alloca i64
%5 = alloca i64
%6 = alloca %union.anon
store i8* %0, i8** %2
%7 = bitcast %union.anon* %6 to i8*
%8 = bitcast %union.anon* %6 to i8*
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = load i8*, i8** %2
%13 = call i32 @ctr128_inc(i8* %12)
br label %37
14: ; preds = %1
%15 = load i8*, i8** %2
%16 = bitcast i8* %15 to i64*
store i64* %16, i64** %3
store i64 2, i64* %5
br label %17
17: ; preds = %34, %14
%18 = load i64, i64* %5
%19 = add i64 %18, -1
store i64 %19, i64* %5
%20 = load i64*, i64** %3
%21 = load i64, i64* %5
%22 = getelementptr inbounds i64, i64* %20, i64 %21
%23 = load i64, i64* %22
store i64 %23, i64* %4
%24 = load i64, i64* %4
%25 = add i64 %24, 1
store i64 %25, i64* %4
%26 = load i64, i64* %4
%27 = load i64*, i64** %3
%28 = load i64, i64* %5
%29 = getelementptr inbounds i64, i64* %27, i64 %28
store i64 %26, i64* %29
%30 = load i64, i64* %4
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %17
br label %37
33: ; preds = %17
br label %34
34: ; preds = %33
%35 = load i64, i64* %5
%36 = icmp ne i64 %35, 0
br i1 %36, label %17, label %37
37: ; preds = %11, %32, %34
ret void
}

LLVM IR (-O2):
define void @ctr128_inc_aligned(i8* %0) {
%2 = tail call i32 @ctr128_inc(i8* %0)
ret void
}