#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*/);
int /*<<< orphan*/ push(int *, char **, char);
int main() {
  int sp = 0;
  char *sample = "abcde";
  char ss[100];
  char *p = ss;
  char c;
  int i = 0;
  while ((c = sample[i]) != '\0') {
    push(&sp, &p, c);
    i++;
  }
  p = ss;
  for (int j = 0; j < 5; j++) {
    printf("%c\n", *(p++));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xec0(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x90(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x90(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x89(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
je     11a4 <main+0x84>
lea    -0x8(%rbp),%rdi
lea    -0x88(%rbp),%rsi
movsbl -0x89(%rbp),%edx
call   1040 <push@plt>
mov    -0x90(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x90(%rbp)
jmp    1159 <main+0x39>
lea    -0x80(%rbp),%rax
mov    %rax,-0x88(%rbp)
movl   $0x0,-0x94(%rbp)
cmpl   $0x5,-0x94(%rbp)
jge    11fe <main+0xde>
mov    -0x88(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x88(%rbp)
movsbl (%rax),%esi
lea    0xe21(%rip),%rdi
call   1030 <printf@plt>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    11b9 <main+0x99>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
movl   $0x0,0xc(%rsp)
lea    0x10(%rsp),%rax
mov    %rax,(%rsp)
lea    0xc(%rsp),%rbx
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x61,%edx
call   1040 <push@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x62,%edx
call   1040 <push@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x63,%edx
call   1040 <push@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x64,%edx
call   1040 <push@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x65,%edx
call   1040 <push@plt>
lea    0x11(%rsp),%rax
mov    %rax,(%rsp)
movsbl 0x10(%rsp),%esi
lea    0xe5b(%rip),%rbx
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movsbl (%rax),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movsbl (%rax),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movsbl (%rax),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
mov    (%rsp),%rax
lea    0x1(%rax),%rcx
mov    %rcx,(%rsp)
movsbl (%rax),%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"abcde\00"
@.str.1 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [100 x i8]
%5 = alloca i8*
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %3
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
store i8* %9, i8** %5
store i32 0, i32* %7
br label %10
10: ; preds = %18, %0
%11 = load i8*, i8** %3
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
store i8 %15, i8* %6
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %10
%19 = load i8, i8* %6
%20 = call i32 @push(i32* %2, i8** %5, i8 signext %19)
%21 = load i32, i32* %7
%22 = add nsw i32 %21, 1
store i32 %22, i32* %7
br label %10
23: ; preds = %10
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
store i8* %24, i8** %5
store i32 0, i32* %8
br label %25
25: ; preds = %34, %23
%26 = load i32, i32* %8
%27 = icmp slt i32 %26, 5
br i1 %27, label %28, label %37
28: ; preds = %25
%29 = load i8*, i8** %5
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %5
%31 = load i8, i8* %29
%32 = sext i8 %31 to i32
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %28
%35 = load i32, i32* %8
%36 = add nsw i32 %35, 1
store i32 %36, i32* %8
br label %25
37: ; preds = %25
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
%3 = alloca i8*
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = bitcast i8** %3 to i8*
store i8* %5, i8** %3
%7 = call i32 @push(i32* %1, i8** %3, i8 signext 97)
%8 = call i32 @push(i32* %1, i8** %3, i8 signext 98)
%9 = call i32 @push(i32* %1, i8** %3, i8 signext 99)
%10 = call i32 @push(i32* %1, i8** %3, i8 signext 100)
%11 = call i32 @push(i32* %1, i8** %3, i8 signext 101)
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 1
store i8* %12, i8** %3
%13 = load i8, i8* %5
%14 = sext i8 %13 to i32
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
store i8* %17, i8** %3
%18 = load i8, i8* %16
%19 = sext i8 %18 to i32
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i64 1
store i8* %22, i8** %3
%23 = load i8, i8* %21
%24 = sext i8 %23 to i32
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %27, i8** %3
%28 = load i8, i8* %26
%29 = sext i8 %28 to i32
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i8*, i8** %3
%32 = getelementptr inbounds i8, i8* %31, i64 1
store i8* %32, i8** %3
%33 = load i8, i8* %31
%34 = sext i8 %33 to i32
%35 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %34)
ret i32 0
}