#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 */
char *malloc(int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
main() {
  char *q, temp, temp2;
  int i;
  q = malloc(1000000);
  scanf("%s", q);
  i = 0;
  if (strlen(q) % 2 != 0) {
    temp2 = *(q + (strlen(q) - 1));
  }
  while (i < strlen(q)) {
    temp = *(q + i);
    *(q + i) = *(q + (i + 1));
    *(q + (i + 1)) = temp;
    i = i + 2;
  }
  *(q + (strlen(q) - 1)) = temp2;
  printf("%s", q);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0xf4240,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11b1 <main+0x71>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x12(%rbp)
jmp    11b6 <main+0x76>
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    121c <main+0xdc>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x11(%rbp),%dl
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    11b6 <main+0x76>
mov    -0x12(%rbp),%al
mov    %al,-0x31(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x31(%rbp),%dl
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rsi
lea    0xdb0(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0xf4240,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
lea    0xea8(%rip),%rdi
mov    %rax,%rsi
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   $0x1,%al
je     117b <main+0x3b>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
mov    -0x1(%rax,%rbx,1),%r14b
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11a5 <main+0x65>
xor    %ebp,%ebp
nopl   0x0(%rax)
rolw   $0x8,(%rbx,%rbp,1)
add    $0x2,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmp    %ebp,%eax
jg     1190 <main+0x50>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
mov    %r14b,-0x1(%rax,%rbx,1)
lea    0xe45(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8
%4 = alloca i8
%5 = alloca i32
store i32 0, i32* %1
%6 = call i8* @malloc(i32 1000000)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %7)
store i32 0, i32* %5
%9 = load i8*, i8** %2
%10 = call i32 @strlen(i8* %9)
%11 = srem i32 %10, 2
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %0
%14 = load i8*, i8** %2
%15 = load i8*, i8** %2
%16 = call i32 @strlen(i8* %15)
%17 = sub nsw i32 %16, 1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %14, i64 %18
%20 = load i8, i8* %19
store i8 %20, i8* %4
br label %21
21: ; preds = %13, %0
br label %22
22: ; preds = %27, %21
%23 = load i32, i32* %5
%24 = load i8*, i8** %2
%25 = call i32 @strlen(i8* %24)
%26 = icmp slt i32 %23, %25
br i1 %26, label %27, label %51
27: ; preds = %22
%28 = load i8*, i8** %2
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
store i8 %32, i8* %3
%33 = load i8*, i8** %2
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
%38 = load i8, i8* %37
%39 = load i8*, i8** %2
%40 = load i32, i32* %5
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
store i8 %38, i8* %42
%43 = load i8, i8* %3
%44 = load i8*, i8** %2
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i8, i8* %44, i64 %47
store i8 %43, i8* %48
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 2
store i32 %50, i32* %5
br label %22
51: ; preds = %22
%52 = load i8, i8* %4
%53 = load i8*, i8** %2
%54 = load i8*, i8** %2
%55 = call i32 @strlen(i8* %54)
%56 = sub nsw i32 %55, 1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8, i8* %53, i64 %57
store i8 %52, i8* %58
%59 = load i8*, i8** %2
%60 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %59)
%61 = load i32, i32* %1
ret i32 %61
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
define i32 @main() {
%1 = tail call dereferenceable_or_null(1000000) i8* @malloc(i32 1000000)
%2 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
%3 = tail call i32 @strlen(i8* %1)
%4 = and i32 %3, 1
%5 = icmp eq i32 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %0
%7 = tail call i32 @strlen(i8* %1)
%8 = add nsw i32 %7, -1
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds i8, i8* %1, i64 %9
%11 = load i8, i8* %10
br label %12
12: ; preds = %6, %0
%13 = phi i8 [ %11, %6 ], [ undef, %0 ]
%14 = tail call i32 @strlen(i8* %1)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %12, %16
%17 = phi i64 [ %23, %16 ], [ 0, %12 ]
%18 = getelementptr inbounds i8, i8* %1, i64 %17
%19 = load i8, i8* %18
%20 = or i64 %17, 1
%21 = getelementptr inbounds i8, i8* %1, i64 %20
%22 = load i8, i8* %21
store i8 %22, i8* %18
store i8 %19, i8* %21
%23 = add nuw i64 %17, 2
%24 = tail call i32 @strlen(i8* %1)
%25 = trunc i64 %23 to i32
%26 = icmp sgt i32 %24, %25
br i1 %26, label %16, label %27
27: ; preds = %16, %12
%28 = tail call i32 @strlen(i8* %1)
%29 = add nsw i32 %28, -1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %1, i64 %30
store i8 %13, i8* %31
%32 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %1)
ret i32 0
}