#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 *, ...);
int main(int argc, char **argv) {
  char *names[3];
  char a[] = "Alice";
  char b[] = "Bob";
  char c[] = "Cindy";
  size_t i;
  names[0] = a;
  names[1] = b;
  names[2] = c;
  for (i = 0; i < 3; i++)
    printf("Hello %s\n", names[i]);
  printf("\nDefacing Bob...\n\n");
  b[1] = 'a';
  b[2] = 'd';
  for (i = 0; i < 3; i++)
    printf("Hello %s\n", names[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0xed4(%rip),%eax
mov    %eax,-0x36(%rbp)
mov    0xece(%rip),%ax
mov    %ax,-0x32(%rbp)
mov    0xec6(%rip),%eax
mov    %eax,-0x3a(%rbp)
mov    0xec1(%rip),%eax
mov    %eax,-0x40(%rbp)
mov    0xebb(%rip),%ax
mov    %ax,-0x3c(%rbp)
lea    -0x36(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x3a(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x48(%rbp)
cmpq   $0x3,-0x48(%rbp)
jae    11aa <main+0x9a>
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    1177 <main+0x67>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x61,-0x39(%rbp)
movb   $0x64,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
cmpq   $0x3,-0x48(%rbp)
jae    11fb <main+0xeb>
mov    -0x48(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rsi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x48(%rbp)
jmp    11c8 <main+0xb8>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
movw   $0x65,0x14(%rsp)
movl   $0x63696c41,0x10(%rsp)
63
movl   $0x626f42,0x4(%rsp)
movw   $0x79,0xc(%rsp)
movl   $0x646e6943,0x8(%rsp)
64
lea    0xeb4(%rip),%rbx
lea    0x10(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x8(%rsp),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe81(%rip),%rdi
call   1030 <puts@plt>
movw   $0x6461,0x5(%rsp)
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@__const.main.a = [6 x i8] c"Alice\00"
@__const.main.c = [6 x i8] c"Cindy\00"
@.str = [10 x i8] c"Hello %s\0A\00"
@str = [18 x i8] c"\0ADefacing Bob...\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [6 x i8]
%4 = alloca i32
%5 = alloca [6 x i8]
%6 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%7 = bitcast i32* %4 to i8*
store i32 6451010, i32* %4
%8 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %6)
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %4)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %8)
%12 = bitcast i32* %4 to [4 x i8]*
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %12, i64 0, i64 1
store i8 97, i8* %14
%15 = getelementptr inbounds [4 x i8], [4 x i8]* %12, i64 0, i64 2
store i8 100, i8* %15
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %6)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32* %4)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* %8)
ret i32 0
}