#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 */
typedef int /*<<< orphan*/ buffer2;
typedef int /*<<< orphan*/ buffer1;

/* Variables and functions */
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ swap_int(int *, int *);
int main(void) {
  int a, b;
  char buffer1[42], buffer2[20];
  size_t i;
  for (i = 0; i < sizeof(buffer1); i++) {
    buffer1[i] = (char)i;
  }
  memcpy(buffer2, buffer1, sizeof(buffer2));
  a = buffer2[10];
  b = buffer2[0];
  swap_int(&a, &b);
  return a;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x68(%rbp)
cmpq   $0x2a,-0x68(%rbp)
jae    1161 <main+0x41>
mov    -0x68(%rbp),%rax
mov    %al,%cl
mov    -0x68(%rbp),%rax
mov    %cl,-0x40(%rbp,%rax,1)
mov    -0x68(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x68(%rbp)
jmp    1137 <main+0x17>
lea    -0x60(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x14,%edx
call   1030 <memcpy@plt>
movsbl -0x56(%rbp),%eax
mov    %eax,-0x8(%rbp)
movsbl -0x60(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <swap_int@plt>
mov    -0x8(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xed9(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movabs $0x2726252423222120,%rax
25 26 27
mov    %rax,0x50(%rsp)
movw   $0x2928,0x58(%rsp)
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rsi
mov    $0x14,%edx
call   1030 <memcpy@plt>
movsbl 0x1a(%rsp),%eax
mov    %eax,0x8(%rsp)
movsbl 0x10(%rsp),%eax
mov    %eax,0xc(%rsp)
lea    0x8(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1040 <swap_int@plt>
mov    0x8(%rsp),%eax
add    $0x68,%rsp
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [42 x i8]
%5 = alloca [20 x i8]
%6 = alloca i64
store i32 0, i32* %1
store i64 0, i64* %6
br label %7
7: ; preds = %15, %0
%8 = load i64, i64* %6
%9 = icmp ult i64 %8, 42
br i1 %9, label %10, label %18
10: ; preds = %7
%11 = load i64, i64* %6
%12 = trunc i64 %11 to i8
%13 = load i64, i64* %6
%14 = getelementptr inbounds [42 x i8], [42 x i8]* %4, i64 0, i64 %13
store i8 %12, i8* %14
br label %15
15: ; preds = %10
%16 = load i64, i64* %6
%17 = add i64 %16, 1
store i64 %17, i64* %6
br label %7
18: ; preds = %7
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%20 = getelementptr inbounds [42 x i8], [42 x i8]* %4, i64 0, i64 0
%21 = call i32 @memcpy(i8* %19, i8* %20, i32 20)
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 10
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
store i32 %24, i32* %2
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
store i32 %27, i32* %3
%28 = call i32 @swap_int(i32* %2, i32* %3)
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [42 x i8]
%4 = alloca [20 x i8]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%9 = bitcast [42 x i8]* %3 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>* %9
%10 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 16
%11 = bitcast i8* %10 to <16 x i8>*
store <16 x i8> <i8 16, i8 17, i8 18, i8 19, i8 20, i8 21, i8 22, i8 23, i8 24, i8 25, i8 26, i8 27, i8 28, i8 29, i8 30, i8 31>, <16 x i8>* %11
%12 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 32
store i8 32, i8* %12
%13 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 33
store i8 33, i8* %13
%14 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 34
store i8 34, i8* %14
%15 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 35
store i8 35, i8* %15
%16 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 36
store i8 36, i8* %16
%17 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 37
store i8 37, i8* %17
%18 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 38
store i8 38, i8* %18
%19 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 39
store i8 39, i8* %19
%20 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 40
store i8 40, i8* %20
%21 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 41
store i8 41, i8* %21
%22 = call i32 @memcpy(i8* %8, i8* %7, i32 20)
%23 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 10
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
store i32 %25, i32* %1
%26 = load i8, i8* %8
%27 = sext i8 %26 to i32
store i32 %27, i32* %2
%28 = call i32 @swap_int(i32* %1, i32* %2)
%29 = load i32, i32* %1
ret i32 %29
}