#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 strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void swap(int num[], int x, int y, char arr[][1000]) {
  int t, lx, ly;
  char tc[1000];
  t = num[x];
  num[x] = num[y];
  num[y] = t;
  lx = strlen(arr[x]);
  ly = strlen(arr[y]);
  strncpy(tc, arr[x], lx + 1);
  strncpy(arr[x], arr[y], ly + 1);
  strncpy(arr[y], tc, lx + 1);
}


x86 assembly (clang, -O0):
<swap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%edx
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rdi
movslq -0xc(%rbp),%rax
imul   $0x3e8,%rax,%rax
add    %rax,%rdi
call   1040 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
movslq -0x10(%rbp),%rax
imul   $0x3e8,%rax,%rax
add    %rax,%rdi
call   1040 <strlen@plt>
mov    %eax,-0x24(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x18(%rbp),%rsi
movslq -0xc(%rbp),%rax
imul   $0x3e8,%rax,%rax
add    %rax,%rsi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rdi
movslq -0xc(%rbp),%rax
imul   $0x3e8,%rax,%rax
add    %rax,%rdi
mov    -0x18(%rbp),%rsi
movslq -0x10(%rbp),%rax
imul   $0x3e8,%rax,%rax
add    %rax,%rsi
mov    -0x24(%rbp),%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x18(%rbp),%rdi
movslq -0x10(%rbp),%rax
imul   $0x3e8,%rax,%rax
add    %rax,%rdi
lea    -0x410(%rbp),%rsi
mov    -0x20(%rbp),%edx
add    $0x1,%edx
call   1030 <strncpy@plt>
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x3f0,%rsp
mov    %rcx,%r14
movslq %esi,%rax
mov    (%rdi,%rax,4),%ecx
movslq %edx,%rbp
mov    (%rdi,%rbp,4),%edx
mov    %edx,(%rdi,%rax,4)
mov    %ecx,(%rdi,%rbp,4)
imul   $0x3e8,%rax,%rbx
add    %r14,%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r15d
imul   $0x3e8,%rbp,%rbp
add    %r14,%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
add    $0x1,%r15d
mov    %rsp,%r12
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
add    $0x1,%r14d
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14d,%edx
call   1030 <strncpy@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1030 <strncpy@plt>
add    $0x3f0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @swap(i32* %0, i32 %1, i32 %2, [1000 x i8]* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1000 x i8]*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [1000 x i8]
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store [1000 x i8]* %3, [1000 x i8]** %8
%13 = load i32*, i32** %5
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i32, i32* %13, i64 %15
%17 = load i32, i32* %16
store i32 %17, i32* %9
%18 = load i32*, i32** %5
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = load i32*, i32** %5
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
store i32 %22, i32* %26
%27 = load i32, i32* %9
%28 = load i32*, i32** %5
%29 = load i32, i32* %7
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
store i32 %27, i32* %31
%32 = load [1000 x i8]*, [1000 x i8]** %8
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [1000 x i8], [1000 x i8]* %32, i64 %34
%36 = getelementptr inbounds [1000 x i8], [1000 x i8]* %35, i64 0, i64 0
%37 = call i32 @strlen(i8* %36)
store i32 %37, i32* %10
%38 = load [1000 x i8]*, [1000 x i8]** %8
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1000 x i8], [1000 x i8]* %38, i64 %40
%42 = getelementptr inbounds [1000 x i8], [1000 x i8]* %41, i64 0, i64 0
%43 = call i32 @strlen(i8* %42)
store i32 %43, i32* %11
%44 = getelementptr inbounds [1000 x i8], [1000 x i8]* %12, i64 0, i64 0
%45 = load [1000 x i8]*, [1000 x i8]** %8
%46 = load i32, i32* %6
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [1000 x i8], [1000 x i8]* %45, i64 %47
%49 = getelementptr inbounds [1000 x i8], [1000 x i8]* %48, i64 0, i64 0
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
%52 = call i32 @strncpy(i8* %44, i8* %49, i32 %51)
%53 = load [1000 x i8]*, [1000 x i8]** %8
%54 = load i32, i32* %6
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds [1000 x i8], [1000 x i8]* %53, i64 %55
%57 = getelementptr inbounds [1000 x i8], [1000 x i8]* %56, i64 0, i64 0
%58 = load [1000 x i8]*, [1000 x i8]** %8
%59 = load i32, i32* %7
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [1000 x i8], [1000 x i8]* %58, i64 %60
%62 = getelementptr inbounds [1000 x i8], [1000 x i8]* %61, i64 0, i64 0
%63 = load i32, i32* %11
%64 = add nsw i32 %63, 1
%65 = call i32 @strncpy(i8* %57, i8* %62, i32 %64)
%66 = load [1000 x i8]*, [1000 x i8]** %8
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [1000 x i8], [1000 x i8]* %66, i64 %68
%70 = getelementptr inbounds [1000 x i8], [1000 x i8]* %69, i64 0, i64 0
%71 = getelementptr inbounds [1000 x i8], [1000 x i8]* %12, i64 0, i64 0
%72 = load i32, i32* %10
%73 = add nsw i32 %72, 1
%74 = call i32 @strncpy(i8* %70, i8* %71, i32 %73)
ret void
}

LLVM IR (-O2):
define void @swap(i32* nocapture %0, i32 %1, i32 %2, [1000 x i8]* %3) {
%5 = alloca [1000 x i8]
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %5, i64 0, i64 0
%7 = sext i32 %1 to i64
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = load i32, i32* %8
%10 = sext i32 %2 to i64
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
store i32 %12, i32* %8
store i32 %9, i32* %11
%13 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 %7, i64 0
%14 = tail call i32 @strlen(i8* %13)
%15 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 %10, i64 0
%16 = tail call i32 @strlen(i8* %15)
%17 = add nsw i32 %14, 1
%18 = call i32 @strncpy(i8* %6, i8* %13, i32 %17)
%19 = add nsw i32 %16, 1
%20 = call i32 @strncpy(i8* %13, i8* %15, i32 %19)
%21 = call i32 @strncpy(i8* %15, i8* %6, i32 %17)
ret void
}