#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*/ printf(char *, ...);
int /*<<< orphan*/ swap(void **, void **);
int main(void) {
  int a = 2;
  int b = 5;
  int *elementos[] = {&a, &b};
  swap((void **)&elementos[0], (void **)&elementos[1]);
  if (a == 5 && b == 2) {
    printf("OK\n");
  } else {
    printf("NO OK\n");
  }
  printf("a=%i b=%i \n", *elementos[0], *elementos[1]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x8,%rsi
call   1040 <swap@plt>
cmpl   $0x5,-0x8(%rbp)
jne    1185 <main+0x65>
cmpl   $0x2,-0xc(%rbp)
jne    1185 <main+0x65>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1193 <main+0x73>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x28,%rsp
movl   $0x2,0xc(%rsp)
movl   $0x5,0x8(%rsp)
lea    0xc(%rsp),%rax
mov    %rax,0x10(%rsp)
lea    0x18(%rsp),%rsi
lea    0x8(%rsp),%rax
mov    %rax,0x18(%rsp)
lea    0x10(%rsp),%rdi
call   1050 <swap@plt>
mov    0xc(%rsp),%eax
xor    $0x5,%eax
mov    0x8(%rsp),%ecx
xor    $0x2,%ecx
lea    0xe93(%rip),%rdx
lea    0xe89(%rip),%rdi
or     %eax,%ecx
cmove  %rdx,%rdi
call   1030 <puts@plt>
mov    0x10(%rsp),%rax
mov    0x18(%rsp),%rcx
mov    (%rax),%esi
mov    (%rcx),%edx
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"OK\0A\00"
@.str.1 = [7 x i8] c"NO OK\0A\00"
@.str.2 = [12 x i8] c"a=%i b=%i \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i32*]
store i32 0, i32* %1
store i32 2, i32* %2
store i32 5, i32* %3
%5 = getelementptr inbounds [2 x i32*], [2 x i32*]* %4, i64 0, i64 0
store i32* %2, i32** %5
%6 = getelementptr inbounds i32*, i32** %5, i64 1
store i32* %3, i32** %6
%7 = getelementptr inbounds [2 x i32*], [2 x i32*]* %4, i64 0, i64 0
%8 = bitcast i32** %7 to i8**
%9 = getelementptr inbounds [2 x i32*], [2 x i32*]* %4, i64 0, i64 1
%10 = bitcast i32** %9 to i8**
%11 = call i32 @swap(i8** %8, i8** %10)
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, 5
br i1 %13, label %14, label %19
14: ; preds = %0
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 2
br i1 %16, label %17, label %19
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
br label %21
19: ; preds = %14, %0
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
%22 = getelementptr inbounds [2 x i32*], [2 x i32*]* %4, i64 0, i64 0
%23 = load i32*, i32** %22
%24 = load i32, i32* %23
%25 = getelementptr inbounds [2 x i32*], [2 x i32*]* %4, i64 0, i64 1
%26 = load i32*, i32** %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %27)
ret i32 0
}

LLVM IR (-O2):
@.str.2 = [12 x i8] c"a=%i b=%i \0A\00"
@str = [6 x i8] c"NO OK\00"
@str.3 = [3 x i8] c"OK\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [2 x i32*]
%4 = bitcast i32* %1 to i8*
store i32 2, i32* %1
%5 = bitcast i32* %2 to i8*
store i32 5, i32* %2
%6 = bitcast [2 x i32*]* %3 to i8*
%7 = getelementptr inbounds [2 x i32*], [2 x i32*]* %3, i64 0, i64 0
store i32* %1, i32** %7
%8 = getelementptr inbounds [2 x i32*], [2 x i32*]* %3, i64 0, i64 1
store i32* %2, i32** %8
%9 = bitcast [2 x i32*]* %3 to i8**
%10 = bitcast i32** %8 to i8**
%11 = call i32 @swap(i8** %9, i8** %10)
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 5
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 2
%16 = select i1 %13, i1 %15, i1 false
%17 = select i1 %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @str.3, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0)
%18 = call i32 @puts(i8* dereferenceable(1) %17)
%19 = load i32*, i32** %7
%20 = load i32, i32* %19
%21 = load i32*, i32** %8
%22 = load i32, i32* %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %20, i32 %22)
ret i32 0
}