#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*/ bzero(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ swab(char *, char *, int);
int main(int argc, char *argv[]) {
  char src[32], dst[32];
  int n;
  n = 8;
  sprintf(src, "abcdefgh");
  swab(src, dst, n);
  printf("'%s' => '%s' (%u)\r\n", src, dst, n);
  n = 2;
  bzero(dst, strlen(dst));
  sprintf(src, "123456789");
  swab(src, dst, n);
  printf("'%s' => '%s' (%u)\r\n", src, dst, n);
  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)
movl   $0x8,-0x54(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   1030 <swab@plt>
lea    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    -0x54(%rbp),%ecx
lea    0xe6a(%rip),%rdi
call   1050 <printf@plt>
movl   $0x2,-0x54(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x60(%rbp)
lea    -0x50(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x60(%rbp),%rdi
mov    %eax,%esi
call   1060 <bzero@plt>
lea    -0x30(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x30(%rbp),%rdi
lea    -0x50(%rbp),%rsi
mov    -0x54(%rbp),%edx
call   1030 <swab@plt>
lea    -0x30(%rbp),%rsi
lea    -0x50(%rbp),%rdx
mov    -0x54(%rbp),%ecx
lea    0xe10(%rip),%rdi
call   1050 <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
movabs $0x6867666564636261,%rax
66 67 68
mov    %rax,(%rsp)
movb   $0x0,0x8(%rsp)
mov    %rsp,%r14
lea    0x20(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1030 <swab@plt>
lea    0xe8e(%rip),%r15
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x8,%ecx
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1060 <bzero@plt>
movabs $0x3837363534333231,%rax
36 37 38
mov    %rax,(%rsp)
movw   $0x39,0x8(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x2,%edx
call   1030 <swab@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    $0x2,%ecx
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"abcdefgh\00"
@.str.1 = [20 x i8] c"'%s' => '%s' (%u)\0D\0A\00"
@.str.2 = [10 x i8] c"123456789\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 8, i32* %8
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%10 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%13 = load i32, i32* %8
%14 = call i32 @swab(i8* %11, i8* %12, i32 %13)
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%17 = load i32, i32* %8
%18 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16, i32 %17)
store i32 2, i32* %8
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%21 = call i32 @strlen(i8* %20)
%22 = call i32 @bzero(i8* %19, i32 %21)
%23 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%24 = call i32 @sprintf(i8* %23, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%26 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%27 = load i32, i32* %8
%28 = call i32 @swab(i8* %25, i8* %26, i32 %27)
%29 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%30 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%31 = load i32, i32* %8
%32 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %29, i8* %30, i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"abcdefgh\00"
@.str.1 = [20 x i8] c"'%s' => '%s' (%u)\0D\0A\00"
@.str.2 = [10 x i8] c"123456789\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%7 = call i32 @swab(i8* %5, i8* %6, i32 8)
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %6, i32 8)
%9 = call i32 @strlen(i8* %6)
%10 = call i32 @bzero(i8* %6, i32 %9)
%11 = call i32 @swab(i8* %5, i8* %6, i32 2)
%12 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %6, i32 2)
ret i32 0
}