#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*/ scanf(char *, char *);
int main(void) {
  char *s, string[101];
  printf("Input a string:\n");
  scanf("%100s", string);
  for (s = string; *s != '\0'; s++)
    printf("%c\n", *s);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xec6(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x80(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     118e <main+0x6e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1158 <main+0x38>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xecc(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb6(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%al
test   %al,%al
je     1188 <main+0x58>
lea    0x1(%rsp),%rbx
lea    0xea1(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"Input a string:\0A\00"
@.str.1 = [6 x i8] c"%100s\00"
@.str.2 = [4 x i8] c"%c\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca [101 x i8]
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [101 x i8], [101 x i8]* %3, i64 0, i64 0
store i8* %7, i8** %2
br label %8
8: ; preds = %18, %0
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = load i8*, i8** %2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %13
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %2
br label %8
21: ; preds = %8
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str.1 = [6 x i8] c"%100s\00"
@.str.2 = [4 x i8] c"%c\0A\00"
@str = [16 x i8] c"Input a string:\00"
define i32 @main() {
%1 = alloca [101 x i8]
%2 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = load i8, i8* %2
%6 = icmp eq i8 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %0, %7
%8 = phi i8 [ %13, %7 ], [ %5, %0 ]
%9 = phi i8* [ %12, %7 ], [ %2, %0 ]
%10 = sext i8 %8 to i32
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds i8, i8* %9, i64 1
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 0
br i1 %14, label %15, label %7
15: ; preds = %7, %0
ret i32 0
}