#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*/ printf(char *, char *, int, char);
int /*<<< orphan*/ strcat(char *, char *);
int main() {
  int i;
  char *str0 = "hello";
  char *str1 = "world";
  for (i = 0; i < 100; i++) {
    printf("%p, %i - %c\n", (str0 + i), i, str0[i]);
  }
  strcat(str0, str1);
  for (i = 0; i < 100; i++) {
    printf("%p, %i - %c\n", (str0 + i), i, str0[i]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xec5(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    118a <main+0x6a>
mov    -0x10(%rbp),%rsi
movslq -0x8(%rbp),%rax
add    %rax,%rsi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
lea    0xe99(%rip),%rdi
movsbl (%rax,%rcx,1),%ecx
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    114c <main+0x2c>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcat@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x64,-0x8(%rbp)
jge    11dc <main+0xbc>
mov    -0x10(%rbp),%rsi
movslq -0x8(%rbp),%rax
add    %rax,%rsi
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
lea    0xe47(%rip),%rdi
movsbl (%rax,%rcx,1),%ecx
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119e <main+0x7e>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %ebx,%ebx
lea    0xed2(%rip),%r14
lea    0xed7(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r14,%rbx,1),%rsi
movsbl (%rbx,%r14,1),%ecx
mov    %r15,%rdi
mov    %ebx,%edx
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1140 <main+0x20>
lea    0xea2(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcat@plt>
xor    %ebx,%ebx
lea    0xe97(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%r14,%rbx,1),%rsi
movsbl (%rbx,%r14,1),%ecx
mov    %r15,%rdi
mov    %ebx,%edx
call   1030 <printf@plt>
add    $0x1,%rbx
cmp    $0x64,%rbx
jne    1180 <main+0x60>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"hello\00"
@.str.1 = [6 x i8] c"world\00"
@.str.2 = [13 x i8] c"%p, %i - %c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %4
store i32 0, i32* %2
br label %5
5: ; preds = %20, %0
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 100
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = load i8*, i8** %3
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i32, i32* %2
%14 = load i8*, i8** %3
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %12, i32 %13, i8 signext %18)
br label %20
20: ; preds = %8
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %5
23: ; preds = %5
%24 = load i8*, i8** %3
%25 = load i8*, i8** %4
%26 = call i32 @strcat(i8* %24, i8* %25)
store i32 0, i32* %2
br label %27
27: ; preds = %42, %23
%28 = load i32, i32* %2
%29 = icmp slt i32 %28, 100
br i1 %29, label %30, label %45
30: ; preds = %27
%31 = load i8*, i8** %3
%32 = load i32, i32* %2
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = load i32, i32* %2
%36 = load i8*, i8** %3
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %34, i32 %35, i8 signext %40)
br label %42
42: ; preds = %30
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
br label %27
45: ; preds = %27
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str = [6 x i8] c"hello\00"
@.str.1 = [6 x i8] c"world\00"
@.str.2 = [13 x i8] c"%p, %i - %c\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 0, %0 ], [ %7, %1 ]
%3 = getelementptr inbounds [6 x i8], [6 x i8]* @.str, i64 0, i64 %2
%4 = load i8, i8* %3
%5 = trunc i64 %2 to i32
%6 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %3, i32 %5, i8 signext %4)
%7 = add nuw nsw i64 %2, 1
%8 = icmp eq i64 %7, 100
br i1 %8, label %9, label %1
9: ; preds = %1
%10 = tail call i32 @strcat(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %17, %11 ]
%13 = getelementptr inbounds [6 x i8], [6 x i8]* @.str, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = trunc i64 %12 to i32
%16 = tail call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %13, i32 %15, i8 signext %14)
%17 = add nuw nsw i64 %12, 1
%18 = icmp eq i64 %17, 100
br i1 %18, label %19, label %11
19: ; preds = %11
ret i32 0
}