#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 string1[20];
  char string2[] = "string literal";
  int i;
  printf("Enter a string: ");
  scanf("%s", string1);
  printf("string1 is: %s\nstring2 is: %s\n"
         "string1 with spaces between characters is:\n",
         string1, string2);
  for (i = 0; string1[i] != '\0'; i++) {
    printf("%c ", string1[i]);
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x2f(%rbp)
mov    0xec8(%rip),%eax
mov    %eax,-0x27(%rbp)
mov    0xec2(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xeba(%rip),%al
mov    %al,-0x21(%rbp)
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xeb0(%rip),%rdi
call   1040 <scanf@plt>
lea    -0x20(%rbp),%rsi
lea    -0x2f(%rbp),%rdx
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11c9 <main+0xa9>
movslq -0x34(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1192 <main+0x72>
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movabs $0x6c61726574696c,%rax
mov    %rax,0x7(%rsp)
movabs $0x6c20676e69727473,%rax
67 20 6c
mov    %rax,(%rsp)
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    0x10(%rsp),%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xea6(%rip),%rdi
mov    %rsp,%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%al
test   %al,%al
je     11b8 <main+0x88>
lea    0x11(%rsp),%rbx
lea    0xecf(%rip),%r14
xchg   %ax,%ax
movsbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    11a0 <main+0x70>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.string2 = [15 x i8] c"string literal\00"
@.str = [17 x i8] c"Enter a string: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [74 x i8] c"string1 is: %s\0Astring2 is: %s\0Astring1 with spaces between characters is:\0A\00"
@.str.3 = [4 x i8] c"%c \00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = alloca [15 x i8]
%4 = alloca i32
store i32 0, i32* %1
%5 = bitcast [15 x i8]* %3 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* %9, i8* %10)
store i32 0, i32* %4
br label %12
12: ; preds = %26, %0
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %29
19: ; preds = %12
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %19
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %12
29: ; preds = %12
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@__const.main.string2 = [15 x i8] c"string literal\00"
@.str = [17 x i8] c"Enter a string: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [74 x i8] c"string1 is: %s\0Astring2 is: %s\0Astring1 with spaces between characters is:\0A\00"
@.str.3 = [4 x i8] c"%c \00"
define i32 @main() {
%1 = alloca [20 x i8]
%2 = alloca [15 x i8]
%3 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [15 x i8], [15 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.2, i64 0, i64 0), i8* %3, i8* %4)
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %0, %10
%11 = phi i64 [ %15, %10 ], [ 0, %0 ]
%12 = phi i8 [ %17, %10 ], [ %8, %0 ]
%13 = sext i8 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = add nuw i64 %11, 1
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %10
19: ; preds = %10, %0
%20 = call i32 @putchar(i32 10)
ret i32 0
}