#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 uint32_t;

/* Variables and functions */
int HadTu_alignment(void const *);
int HadTu_size(void const *);
void *HadTu_next(const void *my, const void *hadTu) {
  uint32_t size;
  uint32_t alignment;
  size_t paddedSize;
  size = HadTu_size(hadTu);
  alignment = HadTu_alignment(my);
  paddedSize =
      (size & (alignment - 1)) ? (size & ~(alignment - 1)) + alignment : size;
  return (void *)((char *)hadTu + paddedSize);
}


x86 assembly (clang, -O0):
<HadTu_next>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <HadTu_size@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <HadTu_alignment@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1175 <HadTu_next+0x55>
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    117b <HadTu_next+0x5b>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
add    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HadTu_next>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <HadTu_size@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <HadTu_alignment@plt>
lea    -0x1(%rax),%ecx
mov    %eax,%edx
neg    %edx
and    %ebp,%edx
add    %eax,%edx
test   %ebp,%ecx
cmove  %ebp,%edx
movslq %edx,%rax
add    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i8* @HadTu_next(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %4
%9 = call i32 @HadTu_size(i8* %8)
store i32 %9, i32* %5
%10 = load i8*, i8** %3
%11 = call i32 @HadTu_alignment(i8* %10)
store i32 %11, i32* %6
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = sub nsw i32 %13, 1
%15 = and i32 %12, %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %25
17: ; preds = %2
%18 = load i32, i32* %5
%19 = load i32, i32* %6
%20 = sub nsw i32 %19, 1
%21 = xor i32 %20, -1
%22 = and i32 %18, %21
%23 = load i32, i32* %6
%24 = add nsw i32 %22, %23
br label %27
25: ; preds = %2
%26 = load i32, i32* %5
br label %27
27: ; preds = %25, %17
%28 = phi i32 [ %24, %17 ], [ %26, %25 ]
%29 = sext i32 %28 to i64
store i64 %29, i64* %7
%30 = load i8*, i8** %4
%31 = load i64, i64* %7
%32 = getelementptr inbounds i8, i8* %30, i64 %31
ret i8* %32
}

LLVM IR (-O2):
define i8* @HadTu_next(i8* %0, i8* %1) {
%3 = tail call i32 @HadTu_size(i8* %1)
%4 = tail call i32 @HadTu_alignment(i8* %0)
%5 = add nsw i32 %4, -1
%6 = and i32 %5, %3
%7 = icmp eq i32 %6, 0
%8 = sub i32 0, %4
%9 = and i32 %3, %8
%10 = add nsw i32 %9, %4
%11 = select i1 %7, i32 %3, i32 %10
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %1, i64 %12
ret i8* %13
}