#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*/ gen_swap(int *, int *, int);
int /*<<< orphan*/ limit2_i32(int *, int, int);
int mksym_i32();
int swap(int *, int *);
void test_swap() {
  int x = 28;
  int y = 42;
  int r = 0;
  x = mksym_i32();
  y = mksym_i32();
  limit2_i32(&x, 0, 28);
  limit2_i32(&y, 42, 101);
  if (x == y)
    x++;
  r = swap(&x, &y);
  gen_swap(&x, &y, r);
}


x86 assembly (clang, -O0):
<test_swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1c,-0x4(%rbp)
movl   $0x2a,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <mksym_i32@plt>
mov    %eax,-0x4(%rbp)
mov    $0x0,%al
call   1040 <mksym_i32@plt>
mov    %eax,-0x8(%rbp)
lea    -0x4(%rbp),%rdi
xor    %esi,%esi
mov    $0x1c,%edx
call   1050 <limit2_i32@plt>
lea    -0x8(%rbp),%rdi
mov    $0x2a,%esi
mov    $0x65,%edx
call   1050 <limit2_i32@plt>
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11a9 <test_swap+0x69>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <swap@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edx
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1030 <gen_swap@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_swap>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <mksym_i32@plt>
mov    %eax,(%rsp)
xor    %eax,%eax
call   1040 <mksym_i32@plt>
mov    %eax,0x4(%rsp)
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0x1c,%edx
call   1050 <limit2_i32@plt>
lea    0x4(%rsp),%rdi
mov    $0x2a,%esi
mov    $0x65,%edx
call   1050 <limit2_i32@plt>
mov    (%rsp),%eax
cmp    0x4(%rsp),%eax
jne    118b <test_swap+0x4b>
add    $0x1,%eax
mov    %eax,(%rsp)
mov    %rsp,%rbx
lea    0x4(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <swap@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <gen_swap@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @test_swap() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 28, i32* %1
store i32 42, i32* %2
store i32 0, i32* %3
%4 = call i32 (...) @mksym_i32()
store i32 %4, i32* %1
%5 = call i32 (...) @mksym_i32()
store i32 %5, i32* %2
%6 = call i32 @limit2_i32(i32* %1, i32 0, i32 28)
%7 = call i32 @limit2_i32(i32* %2, i32 42, i32 101)
%8 = load i32, i32* %1
%9 = load i32, i32* %2
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
br label %14
14: ; preds = %11, %0
%15 = call i32 @swap(i32* %1, i32* %2)
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = call i32 @gen_swap(i32* %1, i32* %2, i32 %16)
ret void
}

LLVM IR (-O2):
define void @test_swap() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 (...) @mksym_i32()
store i32 %5, i32* %1
%6 = tail call i32 (...) @mksym_i32()
store i32 %6, i32* %2
%7 = call i32 @limit2_i32(i32* %1, i32 0, i32 28)
%8 = call i32 @limit2_i32(i32* %2, i32 42, i32 101)
%9 = load i32, i32* %1
%10 = load i32, i32* %2
%11 = icmp eq i32 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %0
%13 = add nsw i32 %9, 1
store i32 %13, i32* %1
br label %14
14: ; preds = %12, %0
%15 = call i32 @swap(i32* %1, i32* %2)
%16 = call i32 @gen_swap(i32* %1, i32* %2, i32 %15)
ret void
}