#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 */
struct cell {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ cell_dispose(struct cell *);
int cell_get(struct cell *);
int /*<<< orphan*/ cell_set(struct cell *, int);
int /*<<< orphan*/ cell_swap(struct cell *, struct cell *);
struct cell *create_cell();
int main() {
  struct cell *c1 = create_cell();
  struct cell *c2 = create_cell();
  cell_set(c1, 5);
  cell_set(c2, 10);
  cell_swap(c1, c2);
  int tmp = cell_get(c1);
  assert(tmp == 10);
  cell_dispose(c1);
  cell_dispose(c2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <create_cell@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1080 <create_cell@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
call   1070 <cell_set@plt>
mov    -0x18(%rbp),%rdi
mov    $0xa,%esi
call   1070 <cell_set@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <cell_swap@plt>
mov    -0x10(%rbp),%rdi
call   1040 <cell_get@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1030 <cell_dispose@plt>
mov    -0x18(%rbp),%rdi
call   1030 <cell_dispose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1080 <create_cell@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1080 <create_cell@plt>
mov    %rax,%r14
mov    %rbx,%rdi
mov    $0x5,%esi
call   1070 <cell_set@plt>
mov    %r14,%rdi
mov    $0xa,%esi
call   1070 <cell_set@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <cell_swap@plt>
mov    %rbx,%rdi
call   1040 <cell_get@plt>
xor    %edi,%edi
cmp    $0xa,%eax
sete   %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1030 <cell_dispose@plt>
mov    %r14,%rdi
call   1030 <cell_dispose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.cell = type { i32 }
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.cell*
%3 = alloca %struct.cell*
%4 = alloca i32
store i32 0, i32* %1
%5 = call %struct.cell* (...) @create_cell()
store %struct.cell* %5, %struct.cell** %2
%6 = call %struct.cell* (...) @create_cell()
store %struct.cell* %6, %struct.cell** %3
%7 = load %struct.cell*, %struct.cell** %2
%8 = call i32 @cell_set(%struct.cell* %7, i32 5)
%9 = load %struct.cell*, %struct.cell** %3
%10 = call i32 @cell_set(%struct.cell* %9, i32 10)
%11 = load %struct.cell*, %struct.cell** %2
%12 = load %struct.cell*, %struct.cell** %3
%13 = call i32 @cell_swap(%struct.cell* %11, %struct.cell* %12)
%14 = load %struct.cell*, %struct.cell** %2
%15 = call i32 @cell_get(%struct.cell* %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, 10
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = load %struct.cell*, %struct.cell** %2
%21 = call i32 @cell_dispose(%struct.cell* %20)
%22 = load %struct.cell*, %struct.cell** %3
%23 = call i32 @cell_dispose(%struct.cell* %22)
ret i32 0
}

LLVM IR (-O2):
%struct.cell = type { i32 }
define i32 @main() {
%1 = tail call %struct.cell* (...) @create_cell()
%2 = tail call %struct.cell* (...) @create_cell()
%3 = tail call i32 @cell_set(%struct.cell* %1, i32 5)
%4 = tail call i32 @cell_set(%struct.cell* %2, i32 10)
%5 = tail call i32 @cell_swap(%struct.cell* %1, %struct.cell* %2)
%6 = tail call i32 @cell_get(%struct.cell* %1)
%7 = icmp eq i32 %6, 10
%8 = zext i1 %7 to i32
%9 = tail call i32 @assert(i32 %8)
%10 = tail call i32 @cell_dispose(%struct.cell* %1)
%11 = tail call i32 @cell_dispose(%struct.cell* %2)
ret i32 0
}