#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*/ assert(int);
int *myalloc(int);
int main() {
  int *x = myalloc(sizeof(int));
  int *y = myalloc(sizeof(int));
  int *p;
  *x = 0;
  *y = 1;
  assert(*x == 0);
  assert(*y == 1);
  p = x;
  x = y;
  y = p;
  assert(*x == 1);
  assert(*y == 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x4,%edi
call   1030 <myalloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x4,%edi
call   1030 <myalloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x1,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x1,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x4,%edi
call   1030 <myalloc@plt>
mov    %rax,%r14
mov    $0x4,%edi
call   1030 <myalloc@plt>
mov    %rax,%rbx
movl   $0x0,(%r14)
movl   $0x1,(%rax)
xor    %edi,%edi
cmpl   $0x0,(%r14)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x1,(%rbx)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x1,(%rbx)
sete   %dil
call   1040 <assert@plt>
xor    %edi,%edi
cmpl   $0x0,(%r14)
sete   %dil
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
store i32 0, i32* %1
%5 = call i32* @myalloc(i32 4)
store i32* %5, i32** %2
%6 = call i32* @myalloc(i32 4)
store i32* %6, i32** %3
%7 = load i32*, i32** %2
store i32 0, i32* %7
%8 = load i32*, i32** %3
store i32 1, i32* %8
%9 = load i32*, i32** %2
%10 = load i32, i32* %9
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32*, i32** %3
%15 = load i32, i32* %14
%16 = icmp eq i32 %15, 1
%17 = zext i1 %16 to i32
%18 = call i32 @assert(i32 %17)
%19 = load i32*, i32** %2
store i32* %19, i32** %4
%20 = load i32*, i32** %3
store i32* %20, i32** %2
%21 = load i32*, i32** %4
store i32* %21, i32** %3
%22 = load i32*, i32** %2
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 1
%25 = zext i1 %24 to i32
%26 = call i32 @assert(i32 %25)
%27 = load i32*, i32** %3
%28 = load i32, i32* %27
%29 = icmp eq i32 %28, 0
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32* @myalloc(i32 4)
%2 = tail call i32* @myalloc(i32 4)
store i32 0, i32* %1
store i32 1, i32* %2
%3 = load i32, i32* %1
%4 = icmp eq i32 %3, 0
%5 = zext i1 %4 to i32
%6 = tail call i32 @assert(i32 %5)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 1
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = load i32, i32* %2
%12 = icmp eq i32 %11, 1
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = tail call i32 @assert(i32 %17)
ret i32 0
}