#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 *, ...);
void playWithStrings() {
  char foo[] = "Hello World!";
  char words[] = {'a', 'b', 'c', '1', 0};
  foo[0] = 'J';
  for (int i = 0; i < 4; i++) {
    printf("int val is %d, char is %c\n", words[i], words[i]);
  }
  printf("string is %s\n", words);
}


x86 assembly (clang, -O0):
<playWithStrings>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xee1(%rip),%rax
mov    %rax,-0xd(%rbp)
mov    0xedf(%rip),%eax
mov    %eax,-0x5(%rbp)
mov    0xeda(%rip),%al
mov    %al,-0x1(%rbp)
mov    0xed2(%rip),%eax
mov    %eax,-0x12(%rbp)
mov    0xecd(%rip),%al
mov    %al,-0xe(%rbp)
movb   $0x4a,-0xd(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x4,-0x18(%rbp)
jge    118a <playWithStrings+0x7a>
movslq -0x18(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%esi
movslq -0x18(%rbp),%rax
movsbl -0x12(%rbp,%rax,1),%edx
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1152 <playWithStrings+0x42>
lea    -0x12(%rbp),%rsi
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<playWithStrings>:
push   %rbx
sub    $0x10,%rsp
movb   $0x0,0xc(%rsp)
movl   $0x31636261,0x8(%rsp)
31
lea    0xedc(%rip),%rbx
mov    %rbx,%rdi
mov    $0x61,%esi
mov    $0x61,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x62,%esi
mov    $0x62,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x63,%esi
mov    $0x63,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0x31,%esi
mov    $0x31,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea0(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.playWithStrings.foo = [13 x i8] c"Hello World!\00"
@__const.playWithStrings.words = [5 x i8] c"abc1\00"
@.str = [27 x i8] c"int val is %d, char is %c\0A\00"
@.str.1 = [14 x i8] c"string is %s\0A\00"
define void @playWithStrings() {
%1 = alloca [13 x i8]
%2 = alloca [5 x i8]
%3 = alloca i32
%4 = bitcast [13 x i8]* %1 to i8*
%5 = bitcast [5 x i8]* %2 to i8*
%6 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
store i8 74, i8* %6
store i32 0, i32* %3
br label %7
7: ; preds = %22, %0
%8 = load i32, i32* %3
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = load i32, i32* %3
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %20)
br label %22
22: ; preds = %10
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %7
25: ; preds = %7
%26 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %26)
ret void
}

LLVM IR (-O2):
@__const.playWithStrings.words = [5 x i8] c"abc1\00"
@.str = [27 x i8] c"int val is %d, char is %c\0A\00"
@.str.1 = [14 x i8] c"string is %s\0A\00"
define void @playWithStrings() {
%1 = alloca [5 x i8]
%2 = getelementptr inbounds [5 x i8], [5 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 97, i32 97)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 98, i32 98)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 99, i32 99)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 49, i32 49)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret void
}