#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*/ fprintf(int /*<<< orphan*/, char *, unsigned long, void *);
int /*<<< orphan*/ malloc(size_t);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  size_t i;
  for (i = 0; i < 200; i++) {
    uintptr_t addr = (uintptr_t)malloc(i);
    if ((addr % 8) != 0) {
      fprintf(stderr, "allocation of size %lu not 8-byte aligned: %p\n",
              (unsigned long)i, (void *)addr);
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0xc8,-0x18(%rbp)
jae    11ac <main+0x8c>
mov    -0x18(%rbp),%rdi
call   1040 <malloc@plt>
cltq
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
and    $0x7,%rax
cmp    $0x0,%rax
je     1196 <main+0x76>
mov    0x2e6c(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe7b(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11b3 <main+0x93>
jmp    119b <main+0x7b>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    113e <main+0x1e>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbx,%rdi
call   1040 <malloc@plt>
movslq %eax,%rcx
test   $0x7,%cl
jne    1151 <main+0x31>
add    $0x1,%rbx
cmp    $0xc8,%rbx
jne    1130 <main+0x10>
xor    %eax,%eax
pop    %rbx
ret
mov    0x2e88(%rip),%rax
mov    (%rax),%edi
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [47 x i8] c"allocation of size %lu not 8-byte aligned: %p\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %6
br label %8
8: ; preds = %25, %2
%9 = load i64, i64* %6
%10 = icmp ult i64 %9, 200
br i1 %10, label %11, label %28
11: ; preds = %8
%12 = load i64, i64* %6
%13 = call i32 @malloc(i64 %12)
%14 = sext i32 %13 to i64
store i64 %14, i64* %7
%15 = load i64, i64* %7
%16 = urem i64 %15, 8
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %11
%19 = load i32, i32* @stderr
%20 = load i64, i64* %6
%21 = load i64, i64* %7
%22 = inttoptr i64 %21 to i8*
%23 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i64 %20, i8* %22)
store i32 1, i32* %3
br label %29
24: ; preds = %11
br label %25
25: ; preds = %24
%26 = load i64, i64* %6
%27 = add i64 %26, 1
store i64 %27, i64* %6
br label %8
28: ; preds = %8
store i32 0, i32* %3
br label %29
29: ; preds = %28, %18
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [47 x i8] c"allocation of size %lu not 8-byte aligned: %p\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %13
%4 = phi i64 [ 0, %2 ], [ %14, %13 ]
%5 = tail call i32 @malloc(i64 %4)
%6 = sext i32 %5 to i64
%7 = and i64 %6, 7
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %3
%10 = load i32, i32* @stderr
%11 = inttoptr i64 %6 to i8*
%12 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i64 %4, i8* %11)
br label %16
13: ; preds = %3
%14 = add nuw nsw i64 %4, 1
%15 = icmp eq i64 %14, 200
br i1 %15, label %16, label %3
16: ; preds = %13, %9
%17 = phi i32 [ 1, %9 ], [ 0, %13 ]
ret i32 %17
}