#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 */
struct Stack {
  int dummy;
};

/* Variables and functions */
struct Stack *createStack(int);
char pop(struct Stack *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ push(struct Stack *, char);
int strlen(char *);
int main() {
  struct Stack *root = createStack(100);
  char arr[] = "Hello world.";
  int n = strlen(arr);
  int i;
  for (i = 0; i < n; i++) {
    push(root, arr[i]);
  }
  for (i = 0; i < n; i++) {
    arr[i] = pop(root);
  }
  printf("%s\n", arr);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x64,%edi
call   1060 <createStack@plt>
mov    %rax,-0x10(%rbp)
mov    0xe8c(%rip),%rax
mov    %rax,-0x1d(%rbp)
mov    0xe8a(%rip),%eax
mov    %eax,-0x15(%rbp)
mov    0xe85(%rip),%al
mov    %al,-0x11(%rbp)
lea    -0x1d(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11c9 <main+0x79>
mov    -0x10(%rbp),%rdi
movslq -0x28(%rbp),%rax
movsbl -0x1d(%rbp,%rax,1),%esi
call   1070 <push@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    119d <main+0x4d>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    11fd <main+0xad>
mov    -0x10(%rbp),%rdi
call   1050 <pop@plt>
mov    %al,%cl
movslq -0x28(%rbp),%rax
mov    %cl,-0x1d(%rbp,%rax,1)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11d0 <main+0x80>
lea    -0x1d(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0x64,%edi
call   1060 <createStack@plt>
mov    %rax,%r15
movabs $0x2e646c726f7720,%rax
mov    %rax,0xd(%rsp)
movabs $0x6f77206f6c6c6548,%rax
20 77 6f
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    11d5 <main+0x85>
mov    %eax,%r14d
mov    %eax,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
movsbl 0x8(%rsp,%rbx,1),%esi
mov    %r15,%rdi
call   1070 <push@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11a0 <main+0x50>
test   %r14d,%r14d
jle    11d5 <main+0x85>
xor    %ebx,%ebx
nopl   (%rax)
mov    %r15,%rdi
call   1050 <pop@plt>
mov    %al,0x8(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11c0 <main+0x70>
lea    0xe31(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.Stack = type { i32 }
@__const.main.arr = [13 x i8] c"Hello world.\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [13 x i8]
%2 = tail call %struct.Stack* @createStack(i32 100)
%3 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%4 = call i32 @strlen(i8* %3)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %24
6: ; preds = %0
%7 = zext i32 %4 to i64
br label %11
8: ; preds = %11
br i1 %5, label %9, label %24
9: ; preds = %8
%10 = zext i32 %4 to i64
br label %18
11: ; preds = %6, %11
%12 = phi i64 [ 0, %6 ], [ %16, %11 ]
%13 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %12
%14 = load i8, i8* %13
%15 = call i32 @push(%struct.Stack* %2, i8 signext %14)
%16 = add nuw nsw i64 %12, 1
%17 = icmp eq i64 %16, %7
br i1 %17, label %8, label %11
18: ; preds = %9, %18
%19 = phi i64 [ 0, %9 ], [ %22, %18 ]
%20 = call signext i8 @pop(%struct.Stack* %2)
%21 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 %19
store i8 %20, i8* %21
%22 = add nuw nsw i64 %19, 1
%23 = icmp eq i64 %22, %10
br i1 %23, label %24, label %18
24: ; preds = %18, %0, %8
%25 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %3)
ret i32 0
}