#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 */
char *malloc(int);
int main() {
  char *buf = malloc(30);
  void *v;
  short *sp;
  short *sq;
  int *ip;
  int *iq;
  int i;
  for (i = 0; i < 30; i++) {
    buf[i] = i;
  }
  v = buf;
  sp = (short *)(v + 1);
  sq = (short *)(v + 2);
  if (*sp == *sq) {
    return 1;
  }
  ip = (int *)(v + 1);
  iq = (int *)(v + 2);
  if (*ip == *iq) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1e,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x1e,-0x3c(%rbp)
jge    115c <main+0x4c>
mov    -0x3c(%rbp),%eax
mov    %al,%dl
mov    -0x10(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1134 <main+0x24>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
movswl (%rax),%eax
mov    -0x28(%rbp),%rcx
movswl (%rcx),%ecx
cmp    %ecx,%eax
jne    119e <main+0x8e>
movl   $0x1,-0x4(%rbp)
jmp    11db <main+0xcb>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%eax
mov    -0x38(%rbp),%rcx
cmp    (%rcx),%eax
jne    11d4 <main+0xc4>
movl   $0x1,-0x4(%rbp)
jmp    11db <main+0xcb>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x1e,%edi
call   1030 <malloc@plt>
movaps 0xede(%rip),%xmm0
movups %xmm0,(%rax)
movabs $0x1716151413121110,%rcx
15 16 17
mov    %rcx,0x10(%rax)
movl   $0x1b1a1918,0x18(%rax)
movw   $0x1d1c,0x1c(%rax)
movzwl 0x1(%rax),%edx
mov    $0x1,%ecx
cmp    0x2(%rax),%dx
je     115a <main+0x4a>
mov    0x1(%rax),%edx
xor    %ecx,%ecx
cmp    0x2(%rax),%edx
sete   %cl
mov    %ecx,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i16*
%5 = alloca i16*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %1
%9 = call i8* @malloc(i32 30)
store i8* %9, i8** %2
store i32 0, i32* %8
br label %10
10: ; preds = %20, %0
%11 = load i32, i32* %8
%12 = icmp slt i32 %11, 30
br i1 %12, label %13, label %23
13: ; preds = %10
%14 = load i32, i32* %8
%15 = trunc i32 %14 to i8
%16 = load i8*, i8** %2
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 %15, i8* %19
br label %20
20: ; preds = %13
%21 = load i32, i32* %8
%22 = add nsw i32 %21, 1
store i32 %22, i32* %8
br label %10
23: ; preds = %10
%24 = load i8*, i8** %2
store i8* %24, i8** %3
%25 = load i8*, i8** %3
%26 = getelementptr i8, i8* %25, i64 1
%27 = bitcast i8* %26 to i16*
store i16* %27, i16** %4
%28 = load i8*, i8** %3
%29 = getelementptr i8, i8* %28, i64 2
%30 = bitcast i8* %29 to i16*
store i16* %30, i16** %5
%31 = load i16*, i16** %4
%32 = load i16, i16* %31
%33 = sext i16 %32 to i32
%34 = load i16*, i16** %5
%35 = load i16, i16* %34
%36 = sext i16 %35 to i32
%37 = icmp eq i32 %33, %36
br i1 %37, label %38, label %39
38: ; preds = %23
store i32 1, i32* %1
br label %53
39: ; preds = %23
%40 = load i8*, i8** %3
%41 = getelementptr i8, i8* %40, i64 1
%42 = bitcast i8* %41 to i32*
store i32* %42, i32** %6
%43 = load i8*, i8** %3
%44 = getelementptr i8, i8* %43, i64 2
%45 = bitcast i8* %44 to i32*
store i32* %45, i32** %7
%46 = load i32*, i32** %6
%47 = load i32, i32* %46
%48 = load i32*, i32** %7
%49 = load i32, i32* %48
%50 = icmp eq i32 %47, %49
br i1 %50, label %51, label %52
51: ; preds = %39
store i32 1, i32* %1
br label %53
52: ; preds = %39
store i32 0, i32* %1
br label %53
53: ; preds = %52, %51, %38
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call dereferenceable_or_null(30) i8* @malloc(i32 30)
%2 = getelementptr i8, i8* %1, i64 1
%3 = getelementptr i8, i8* %1, i64 2
%4 = bitcast i8* %1 to <16 x i8>*
store <16 x i8> <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, <16 x i8>* %4
%5 = getelementptr inbounds i8, i8* %1, i64 16
store i8 16, i8* %5
%6 = getelementptr inbounds i8, i8* %1, i64 17
store i8 17, i8* %6
%7 = getelementptr inbounds i8, i8* %1, i64 18
store i8 18, i8* %7
%8 = getelementptr inbounds i8, i8* %1, i64 19
store i8 19, i8* %8
%9 = getelementptr inbounds i8, i8* %1, i64 20
store i8 20, i8* %9
%10 = getelementptr inbounds i8, i8* %1, i64 21
store i8 21, i8* %10
%11 = getelementptr inbounds i8, i8* %1, i64 22
store i8 22, i8* %11
%12 = getelementptr inbounds i8, i8* %1, i64 23
store i8 23, i8* %12
%13 = getelementptr inbounds i8, i8* %1, i64 24
store i8 24, i8* %13
%14 = getelementptr inbounds i8, i8* %1, i64 25
store i8 25, i8* %14
%15 = getelementptr inbounds i8, i8* %1, i64 26
store i8 26, i8* %15
%16 = getelementptr inbounds i8, i8* %1, i64 27
store i8 27, i8* %16
%17 = getelementptr inbounds i8, i8* %1, i64 28
store i8 28, i8* %17
%18 = getelementptr inbounds i8, i8* %1, i64 29
store i8 29, i8* %18
%19 = bitcast i8* %2 to i16*
%20 = bitcast i8* %3 to i16*
%21 = load i16, i16* %19
%22 = load i16, i16* %20
%23 = icmp eq i16 %21, %22
br i1 %23, label %31, label %24
24: ; preds = %0
%25 = bitcast i8* %2 to i32*
%26 = bitcast i8* %3 to i32*
%27 = load i32, i32* %25
%28 = load i32, i32* %26
%29 = icmp eq i32 %27, %28
%30 = zext i1 %29 to i32
br label %31
31: ; preds = %24, %0
%32 = phi i32 [ 1, %0 ], [ %30, %24 ]
ret i32 %32
}