#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*/ getchar();
int /*<<< orphan*/ modifystr(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ reversestr(char *);
int /*<<< orphan*/ strconcat(char *, char *, int);
int main_str() {
  char *s = "This is a string";
  char *orig;
  char istr[] = "abcd";
  char s1[] = "abc";
  char s2[] = "123";
  orig = s;
  orig = istr;
  printf("%s\n", s);
  printf("%s\n", orig);
  printf("%s\n", s);
  reversestr(s1);
  printf("%s\n", s1);
  strconcat(s1, s2, 1);
  printf("%s\n", s1);
  printf("%s\n", s2);
  modifystr(s1);
  printf("%s\n", s1);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    0xea8(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xea3(%rip),%al
mov    %al,-0x11(%rbp)
mov    0xe9b(%rip),%eax
mov    %eax,-0x19(%rbp)
mov    0xe96(%rip),%eax
mov    %eax,-0x1d(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x15(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe7c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe6c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
lea    -0x19(%rbp),%rdi
call   1060 <reversestr@plt>
lea    -0x19(%rbp),%rsi
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
lea    -0x19(%rbp),%rdi
lea    -0x1d(%rbp),%rsi
mov    $0x1,%edx
call   1030 <strconcat@plt>
lea    -0x19(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1d(%rbp),%rsi
lea    0xe11(%rip),%rdi
call   1040 <printf@plt>
lea    -0x19(%rbp),%rdi
call   1070 <modifystr@plt>
lea    -0x19(%rbp),%rsi
lea    0xdf8(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main_str>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0x4(%rsp)
movl   $0x64636261,(%rsp)
movl   $0x636261,0xc(%rsp)
movl   $0x333231,0x8(%rsp)
lea    0xe9a(%rip),%r14
lea    0xe7d(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <reversestr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0x8(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <strconcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1070 <modifystr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [17 x i8] c"This is a string\00"
@__const.main_str.istr = [5 x i8] c"abcd\00"
@__const.main_str.s1 = [4 x i8] c"abc\00"
@__const.main_str.s2 = [4 x i8] c"123\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main_str() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca [5 x i8]
%4 = alloca [4 x i8]
%5 = alloca [4 x i8]
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %1
%6 = bitcast [5 x i8]* %3 to i8*
%7 = bitcast [4 x i8]* %4 to i8*
%8 = bitcast [4 x i8]* %5 to i8*
%9 = load i8*, i8** %1
store i8* %9, i8** %2
%10 = getelementptr inbounds [5 x i8], [5 x i8]* %3, i64 0, i64 0
store i8* %10, i8** %2
%11 = load i8*, i8** %1
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %2
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = load i8*, i8** %1
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%18 = call i32 @reversestr(i8* %17)
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%23 = call i32 @strconcat(i8* %21, i8* %22, i32 1)
%24 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
%27 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%29 = call i32 @modifystr(i8* %28)
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %4, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [17 x i8] c"This is a string\00"
@__const.main_str.istr = [5 x i8] c"abcd\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main_str() {
%1 = alloca [5 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
store i32 6513249, i32* %2
%6 = bitcast i32* %3 to i8*
store i32 3355185, i32* %3
%7 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @reversestr(i8* %5)
%11 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%12 = call i32 @strconcat(i8* %5, i8* %6, i32 1)
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %6)
%15 = call i32 @modifystr(i8* %5)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%17 = call i32 (...) @getchar()
ret i32 0
}