#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*/ strlen(char *);
int /*<<< orphan*/ swapa(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ swapm(double *, double *, int);
int main(int argc, char **argv) {
  (void)argc;
  printf("%s:\n\n", argv[0]);
  double d1 = 3;
  double d2 = 6;
  printf("d1 = %g, d2 = %g\n", d1, d2);
  swapm(&d1, &d2, sizeof(double));
  printf("d1 = %g, d2 = %g\n\n", d1, d2);
  char s1[] = "Hello, World.";
  char s2[] = "This is a test of swapa.";
  printf("s1 = \"%s\", s2 = \"%s\"\n", s1, s2);
  swapa(s1, s2, strlen(s1));
  printf("s1 = \"%s\", s2 = \"%s\"\n\n", s1, s2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsd  0xe95(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe80(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe80(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
call   1050 <swapm@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe68(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0xe6d(%rip),%rax
mov    %rax,-0x2e(%rbp)
mov    0xe6b(%rip),%eax
mov    %eax,-0x26(%rbp)
mov    0xe65(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    0xe93(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe90(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe8d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe8b(%rip),%al
mov    %al,-0x38(%rbp)
lea    -0x2e(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x2e(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x2e(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
call   1060 <swapa@plt>
lea    -0x2e(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    (%rsi),%rsi
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movabs $0x4008000000000000,%rax
mov    %rax,0x8(%rsp)
movabs $0x4018000000000000,%rax
mov    %rax,(%rsp)
lea    0xe9a(%rip),%rdi
movsd  0xe7c(%rip),%xmm0
movsd  0xe7c(%rip),%xmm1
mov    $0x2,%al
call   1040 <printf@plt>
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x8,%edx
call   1050 <swapm@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
lea    0xe71(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movabs $0x2e646c726f5720,%rax
mov    %rax,0x16(%rsp)
movabs $0x57202c6f6c6c6548,%rax
2c 20 57
mov    %rax,0x10(%rsp)
movups 0xea6(%rip),%xmm0
movups %xmm0,0x29(%rsp)
movaps 0xe91(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xe4e(%rip),%rdi
lea    0x10(%rsp),%rbx
lea    0x20(%rsp),%r14
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <swapa@plt>
lea    0xe31(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%s:\0A\0A\00"
@.str.1 = [18 x i8] c"d1 = %g, d2 = %g\0A\00"
@.str.2 = [19 x i8] c"d1 = %g, d2 = %g\0A\0A\00"
@__const.main.s1 = [14 x i8] c"Hello, World.\00"
@__const.main.s2 = [25 x i8] c"This is a test of swapa.\00"
@.str.3 = [22 x i8] c"s1 = \22%s\22, s2 = \22%s\22\0A\00"
@.str.4 = [23 x i8] c"s1 = \22%s\22, s2 = \22%s\22\0A\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca [14 x i8]
%9 = alloca [25 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %13)
store double 3.000000e+00, double* %6
store double 6.000000e+00, double* %7
%15 = load double, double* %6
%16 = load double, double* %7
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double %15, double %16)
%18 = call i32 @swapm(double* %6, double* %7, i32 8)
%19 = load double, double* %6
%20 = load double, double* %7
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %19, double %20)
%22 = bitcast [14 x i8]* %8 to i8*
%23 = bitcast [25 x i8]* %9 to i8*
%24 = getelementptr inbounds [14 x i8], [14 x i8]* %8, i64 0, i64 0
%25 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %25)
%27 = getelementptr inbounds [14 x i8], [14 x i8]* %8, i64 0, i64 0
%28 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%29 = getelementptr inbounds [14 x i8], [14 x i8]* %8, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = call i32 @swapa(i8* %27, i8* %28, i32 %30)
%32 = getelementptr inbounds [14 x i8], [14 x i8]* %8, i64 0, i64 0
%33 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %32, i8* %33)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s:\0A\0A\00"
@.str.1 = [18 x i8] c"d1 = %g, d2 = %g\0A\00"
@.str.2 = [19 x i8] c"d1 = %g, d2 = %g\0A\0A\00"
@__const.main.s1 = [14 x i8] c"Hello, World.\00"
@__const.main.s2 = [25 x i8] c"This is a test of swapa.\00"
@.str.3 = [22 x i8] c"s1 = \22%s\22, s2 = \22%s\22\0A\00"
@.str.4 = [23 x i8] c"s1 = \22%s\22, s2 = \22%s\22\0A\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca [14 x i8]
%6 = alloca [25 x i8]
%7 = load i8*, i8** %1
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %7)
%9 = bitcast double* %3 to i8*
store double 3.000000e+00, double* %3
%10 = bitcast double* %4 to i8*
store double 6.000000e+00, double* %4
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double 3.000000e+00, double 6.000000e+00)
%12 = call i32 @swapm(double* %3, double* %4, i32 8)
%13 = load double, double* %3
%14 = load double, double* %4
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %13, double %14)
%16 = getelementptr inbounds [14 x i8], [14 x i8]* %5, i64 0, i64 0
%17 = getelementptr inbounds [25 x i8], [25 x i8]* %6, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %16, i8* %17)
%19 = call i32 @strlen(i8* %16)
%20 = call i32 @swapa(i8* %16, i8* %17, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i8* %16, i8* %17)
ret i32 0
}