#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", *argv);
  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", 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", 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    0xe7e(%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    0xe54(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    0xe58(%rip),%rax
mov    %rax,-0x2e(%rbp)
mov    0xe56(%rip),%eax
mov    %eax,-0x26(%rbp)
mov    0xe50(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    0xe63(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe60(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe5d(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe5b(%rip),%al
mov    %al,-0x38(%rbp)
lea    -0x2e(%rbp),%rsi
lea    -0x50(%rbp),%rdx
lea    0xe15(%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    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x40,%rsp
mov    (%rsi),%rdi
call   1030 <puts@plt>
movabs $0x4008000000000000,%rax
mov    %rax,0x8(%rsp)
movabs $0x4018000000000000,%rax
mov    %rax,(%rsp)
lea    0xe8b(%rip),%rbx
movsd  0xe73(%rip),%xmm0
movsd  0xe73(%rip),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1050 <printf@plt>
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x8,%edx
call   1060 <swapm@plt>
movsd  0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
mov    %rbx,%rdi
mov    $0x2,%al
call   1050 <printf@plt>
movabs $0x2e646c726f5720,%rax
mov    %rax,0x16(%rsp)
movabs $0x57202c6f6c6c6548,%rax
2c 20 57
mov    %rax,0x10(%rsp)
movups 0xe6e(%rip),%xmm0
movups %xmm0,0x29(%rsp)
movaps 0xe59(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
lea    0xe2d(%rip),%r14
lea    0x10(%rsp),%rbx
lea    0x20(%rsp),%r15
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1070 <swapa@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [18 x i8] c"d1 = %g, d2 = %g\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.2 = [22 x i8] c"s1 = \22%s\22, s2 = \22%s\22\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 = load i8*, i8** %11
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
store double 3.000000e+00, double* %6
store double 6.000000e+00, double* %7
%14 = load double, double* %6
%15 = load double, double* %7
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double %14, double %15)
%17 = call i32 @swapm(double* %6, double* %7, i32 8)
%18 = load double, double* %6
%19 = load double, double* %7
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), double %18, double %19)
%21 = bitcast [14 x i8]* %8 to i8*
%22 = bitcast [25 x i8]* %9 to i8*
%23 = getelementptr inbounds [14 x i8], [14 x i8]* %8, i64 0, i64 0
%24 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %23, i8* %24)
%26 = getelementptr inbounds [14 x i8], [14 x i8]* %8, i64 0, i64 0
%27 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%28 = getelementptr inbounds [14 x i8], [14 x i8]* %8, i64 0, i64 0
%29 = call i32 @strlen(i8* %28)
%30 = call i32 @swapa(i8* %26, i8* %27, i32 %29)
%31 = getelementptr inbounds [14 x i8], [14 x i8]* %8, i64 0, i64 0
%32 = getelementptr inbounds [25 x i8], [25 x i8]* %9, i64 0, i64 0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %31, i8* %32)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"d1 = %g, d2 = %g\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.2 = [22 x i8] c"s1 = \22%s\22, s2 = \22%s\22\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 @puts(i8* dereferenceable(1) %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 ([18 x i8], [18 x i8]* @.str.1, 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.2, 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 ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %16, i8* %17)
ret i32 0
}