#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 /*<<< orphan*/ strcpy(char *, char const *);
void foo(const char *input) {
  char buf[10];
  printf("My stack looks "
         "like:\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%"
         "p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n\n");
  strcpy(buf, input);
  printf("%s\n", buf);
  printf("Now the stack looks "
         "like:\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%"
         "p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n%p\n\n");
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x12(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x12(%rbp),%rsi
lea    0xf0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf03(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xebf(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe(%rsp),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0xef8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [95 x i8] c"My stack looks like:\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [100 x i8] c"Now the stack looks like:\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A\0A\00"
define void @foo(i8* %0) {
%2 = alloca i8*
%3 = alloca [10 x i8]
store i8* %0, i8** %2
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([95 x i8], [95 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%6 = load i8*, i8** %2
%7 = call i32 @strcpy(i8* %5, i8* %6)
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [95 x i8] c"My stack looks like:\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A\0A\00"
@.str.2 = [100 x i8] c"Now the stack looks like:\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A%p\0A\0A\00"
define void @foo(i8* %0) {
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([95 x i8], [95 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @strcpy(i8* %3, i8* %0)
%6 = call i32 @puts(i8* %3)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([100 x i8], [100 x i8]* @.str.2, i64 0, i64 0))
ret void
}