#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 fig09_05() {
  char character = 'A';
  char string[] = "This is a string";
  const char *stringPtr = "This is also a string";
  printf("%c\n", character);
  printf("%s\n", "This is a string");
  printf("%s\n", string);
  printf("%s\n", stringPtr);
}


x86 assembly (clang, -O0):
<fig09_05>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movb   $0x41,-0x1(%rbp)
mov    0xedd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeda(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xed8(%rip),%al
mov    %al,-0x10(%rbp)
lea    0xecf(%rip),%rax
mov    %rax,-0x28(%rbp)
movsbl -0x1(%rbp),%esi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0xec9(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rsi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig09_05>:
push   %rbx
sub    $0x20,%rsp
movaps 0xef4(%rip),%xmm0
movaps %xmm0,(%rsp)
movb   $0x0,0x10(%rsp)
lea    0xee4(%rip),%rbx
lea    0xed3(%rip),%rdi
mov    $0x41,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rsp,%rdi
call   1030 <puts@plt>
lea    0xe9a(%rip),%rdi
add    $0x20,%rsp
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
@__const.fig09_05.string = [17 x i8] c"This is a string\00"
@.str = [22 x i8] c"This is also a string\00"
@.str.1 = [4 x i8] c"%c\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [17 x i8] c"This is a string\00"
define void @fig09_05() {
%1 = alloca i8
%2 = alloca [17 x i8]
%3 = alloca i8*
store i8 65, i8* %1
%4 = bitcast [17 x i8]* %2 to i8*
store i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8** %3
%5 = load i8, i8* %1
%6 = sext i8 %5 to i32
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%9 = getelementptr inbounds [17 x i8], [17 x i8]* %2, i64 0, i64 0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %9)
%11 = load i8*, i8** %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %11)
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"This is also a string\00"
@.str.1 = [4 x i8] c"%c\0A\00"
@.str.3 = [17 x i8] c"This is a string\00"
define void @fig09_05() {
%1 = alloca [17 x i8]
%2 = getelementptr inbounds [17 x i8], [17 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 65)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 @puts(i8* %2)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
ret void
}