#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 */
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  const char *s = "Hello";
  printf("s is at %p; it points to a string at %p\n", &s, s);
  printf("The ASCII value for %c is %d\n", s[0], (int)s[0]);
  printf("The ASCII value for '\\0' is %d\n\n", (int)s[5]);
  const char *s2 = "Hello";
  printf("s2 is at %p; it points to a string at %p\n", &s2, s2);
  char *m = (char *)malloc(6 * sizeof(char));
  printf("Enter a string of AT MOST 5 LETTERS!!!\n");
  scanf("%s", m);
  printf("You entered %s\n", m);
  m[0] = 'X';
  printf("I mutated it to %s\n", m);
  printf("The length of what you entered is %d\n", strlen(m));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xeb1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdx
lea    0xea8(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%esi
mov    -0x8(%rbp),%rax
movsbl (%rax),%edx
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movsbl 0x5(%rax),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe5e(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdx
lea    0xebd(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x6,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xedd(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x18(%rbp),%rsi
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rax
movb   $0x58,(%rax)
mov    -0x18(%rbp),%rsi
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xea4(%rip),%rbx
mov    %rbx,(%rsp)
lea    0xe9f(%rip),%rdi
mov    %rsp,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rax
movsbl (%rax),%edx
lea    0xead(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rax
movsbl 0x5(%rax),%esi
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,0x8(%rsp)
lea    0xec1(%rip),%rdi
lea    0x8(%rsp),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x6,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xf15(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
lea    0xeb0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movb   $0x58,(%rbx)
lea    0xeac(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0xea7(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Hello\00"
@.str.1 = [41 x i8] c"s is at %p; it points to a string at %p\0A\00"
@.str.2 = [30 x i8] c"The ASCII value for %c is %d\0A\00"
@.str.3 = [33 x i8] c"The ASCII value for '\\0' is %d\0A\0A\00"
@.str.4 = [42 x i8] c"s2 is at %p; it points to a string at %p\0A\00"
@.str.5 = [40 x i8] c"Enter a string of AT MOST 5 LETTERS!!!\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [16 x i8] c"You entered %s\0A\00"
@.str.8 = [20 x i8] c"I mutated it to %s\0A\00"
@.str.9 = [38 x i8] c"The length of what you entered is %d\0A\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i8*
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %1
%4 = load i8*, i8** %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8** %1, i8* %4)
%6 = load i8*, i8** %1
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = load i8*, i8** %1
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %13)
%15 = load i8*, i8** %1
%16 = getelementptr inbounds i8, i8* %15, i64 5
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %18)
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
%20 = load i8*, i8** %2
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8** %2, i8* %20)
%22 = call i64 @malloc(i32 6)
%23 = inttoptr i64 %22 to i8*
store i8* %23, i8** %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0))
%25 = load i8*, i8** %3
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %27)
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 0
store i8 88, i8* %30
%31 = load i8*, i8** %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %31)
%33 = load i8*, i8** %3
%34 = call i32 @strlen(i8* %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"Hello\00"
@.str.1 = [41 x i8] c"s is at %p; it points to a string at %p\0A\00"
@.str.2 = [30 x i8] c"The ASCII value for %c is %d\0A\00"
@.str.3 = [33 x i8] c"The ASCII value for '\\0' is %d\0A\0A\00"
@.str.4 = [42 x i8] c"s2 is at %p; it points to a string at %p\0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [16 x i8] c"You entered %s\0A\00"
@.str.8 = [20 x i8] c"I mutated it to %s\0A\00"
@.str.9 = [38 x i8] c"The length of what you entered is %d\0A\00"
@str = [39 x i8] c"Enter a string of AT MOST 5 LETTERS!!!\00"
define i32 @main() {
%1 = alloca i8*
%2 = alloca i8*
%3 = bitcast i8** %1 to i8*
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %1
%4 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%5 = load i8*, i8** %1
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %7)
%9 = load i8*, i8** %1
%10 = getelementptr inbounds i8, i8* %9, i64 5
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = bitcast i8** %2 to i8*
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %2
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i8** %2, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = call i64 @malloc(i32 6)
%17 = inttoptr i64 %16 to i8*
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %17)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %17)
store i8 88, i8* %17
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0), i8* %17)
%22 = call i32 @strlen(i8* %17)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %22)
ret i32 0
}