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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x78(%rbp)
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xeb8(%rip),%rdi
call   1040 <scanf@plt>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11d0 <main+0xb0>
movslq -0x74(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%esi
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x0,%eax
jne    11bd <main+0x9d>
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
mov    -0x78(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    11c2 <main+0xa2>
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    115e <main+0x3e>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x68,%rsp
lea    0xec3(%rip),%rdi
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%al
test   %al,%al
je     1198 <main+0x68>
xor    %ebx,%ebx
jmp    117c <main+0x4c>
mov    $0xa,%edi
call   1030 <putchar@plt>
movslq %ebp,%rbx
movzbl 0x1(%rsp,%rbx,1),%eax
add    $0x1,%rbx
mov    %ebx,%ebp
test   %al,%al
je     1198 <main+0x68>
movsbl %al,%edi
call   1030 <putchar@plt>
movslq %ebx,%rbx
movzbl 0x1(%rsp,%rbx,1),%eax
test   %al,%al
je     1160 <main+0x30>
add    $0x1,%rbx
test   %al,%al
jne    117c <main+0x4c>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"Enter string s: \00"
@.str.1 = [3 x i8] c"%s\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 %29, label %7
7: ; preds = %0, %24
%8 = phi i8 [ %26, %24 ], [ %5, %0 ]
%9 = phi i32 [ %27, %24 ], [ 0, %0 ]
%10 = phi i32 [ %25, %24 ], [ 0, %0 ]
%11 = sext i8 %8 to i32
%12 = call i32 @putchar(i32 %11)
%13 = add nsw i32 %10, 1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 0
br i1 %17, label %18, label %24
18: ; preds = %7
%19 = call i32 @putchar(i32 10)
%20 = add nsw i32 %9, 1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
br label %24
24: ; preds = %7, %18
%25 = phi i32 [ %13, %7 ], [ %20, %18 ]
%26 = phi i8 [ %16, %7 ], [ %23, %18 ]
%27 = phi i32 [ %9, %7 ], [ %20, %18 ]
%28 = icmp eq i8 %26, 0
br i1 %28, label %29, label %7
29: ; preds = %24, %0
ret i32 0
}