#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 *addCharToString(char *, char);
char *concatestrings(char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ swap_chars(char *, int /*<<< orphan*/, int);
int main(void) {
  char *s1 = "Hello ";
  char *s2 = "World!!!";
  char *s3 = concatestrings(s1, s2);
  printf("s1 + j: %s\n", addCharToString(s1, 'j'));
  printf("s3: %s\n", s3);
  swap_chars(s3, 0, 4);
  printf("Swqaped s3: %s\n", s3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xea6(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <concatestrings@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x6a,%esi
call   1060 <addCharToString@plt>
mov    %rax,%rsi
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <swap_chars@plt>
mov    -0x20(%rbp),%rsi
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%r14
lea    0xeb5(%rip),%rsi
mov    %r14,%rdi
call   1050 <concatestrings@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    $0x6a,%esi
call   1060 <addCharToString@plt>
lea    0xe9f(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
lea    0xea4(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <swap_chars@plt>
lea    0xe7e(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Hello \00"
@.str.1 = [9 x i8] c"World!!!\00"
@.str.2 = [12 x i8] c"s1 + j: %s\0A\00"
@.str.3 = [8 x i8] c"s3: %s\0A\00"
@.str.4 = [16 x i8] c"Swqaped s3: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %3
%5 = load i8*, i8** %2
%6 = load i8*, i8** %3
%7 = call i8* @concatestrings(i8* %5, i8* %6)
store i8* %7, i8** %4
%8 = load i8*, i8** %2
%9 = call i8* @addCharToString(i8* %8, i8 signext 106)
%10 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %4
%12 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %4
%14 = call i32 @swap_chars(i8* %13, i32 0, i32 4)
%15 = load i8*, i8** %4
%16 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %15)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"Hello \00"
@.str.1 = [9 x i8] c"World!!!\00"
@.str.2 = [12 x i8] c"s1 + j: %s\0A\00"
@.str.3 = [8 x i8] c"s3: %s\0A\00"
@.str.4 = [16 x i8] c"Swqaped s3: %s\0A\00"
define i32 @main() {
%1 = tail call i8* @concatestrings(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i8* @addCharToString(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8 signext 106)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %1)
%5 = tail call i32 @swap_chars(i8* %1, i32 0, i32 4)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i8* %1)
ret i32 0
}