#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() {
  char s[100];
  char i = 0;
  printf("Enter string s: ");
  scanf("%s", s);
  for (i; s[i] != '\0'; i++) {
    printf("\n%c", s[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x0,-0x71(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xec2(%rip),%rdi
call   1040 <scanf@plt>
movsbq -0x71(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     118c <main+0x6c>
movsbq -0x71(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x71(%rbp),%al
add    $0x1,%al
mov    %al,-0x71(%rbp)
jmp    1154 <main+0x34>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x68,%rsp
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed5(%rip),%rdi
mov    %rsp,%rsi
call   1040 <scanf@plt>
mov    (%rsp),%al
test   %al,%al
je     117c <main+0x5c>
mov    $0x1,%bl
lea    0xec0(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movsbq %bl,%rbx
movzbl (%rsp,%rbx,1),%eax
add    $0x1,%bl
test   %al,%al
jne    1160 <main+0x40>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r14
ret

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

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