#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*/ puts(char *);
int /*<<< orphan*/ scanf(char *, char *);
void fig06_10() {
  char string1[20];
  char string2[] = "string literal";
  size_t i;
  printf("%s", "Enter a string (no longer than 19 characters):");
  scanf("%19s", string1);
  printf("string1 is: %s\nstring2 is: %s\n"
         "string1 with spaces between characters is:\n",
         string1, string2);
  for (i = 0; i < 20 && string1[i] != '\0'; ++i) {
    printf("%c ", string1[i]);
  }
  puts("");
}


x86 assembly (clang, -O0):
<fig06_10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x2f(%rbp)
mov    0xebf(%rip),%eax
mov    %eax,-0x27(%rbp)
mov    0xeb9(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xeb1(%rip),%al
mov    %al,-0x21(%rbp)
lea    0xea8(%rip),%rdi
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xec1(%rip),%rdi
call   1050 <scanf@plt>
lea    -0x20(%rbp),%rsi
lea    -0x2f(%rbp),%rdx
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x38(%rbp)
xor    %eax,%eax
cmpq   $0x14,-0x38(%rbp)
mov    %al,-0x39(%rbp)
jae    11c5 <fig06_10+0x95>
mov    -0x38(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    11d5 <fig06_10+0xa5>
jmp    11fd <fig06_10+0xcd>
mov    -0x38(%rbp),%rax
movsbl -0x20(%rbp,%rax,1),%esi
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11a3 <fig06_10+0x73>
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig06_10>:
push   %rbx
sub    $0x30,%rsp
movabs $0x6c61726574696c,%rax
mov    %rax,0x27(%rsp)
movabs $0x6c20676e69727473,%rax
67 20 6c
mov    %rax,0x20(%rsp)
lea    0xeb5(%rip),%rdi
lea    0xeb1(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed2(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
lea    0xec5(%rip),%rdi
lea    0x20(%rsp),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl (%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xeed(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x1(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x2(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xeb7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x3(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x4(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xe81(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x5(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xe66(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x6(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x7(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x8(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xe15(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x9(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xdfa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xa(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xddf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xb(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xdc4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xc(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xda9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xd(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xd8e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xe(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xd73(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0xf(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xd5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x10(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xd45(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x11(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xd2e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x12(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xd17(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsbl 0x13(%rsp),%esi
test   %esi,%esi
je     1397 <fig06_10+0x267>
lea    0xd00(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x30,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@__const.fig06_10.string2 = [15 x i8] c"string literal\00"
@.str = [3 x i8] c"%s\00"
@.str.1 = [47 x i8] c"Enter a string (no longer than 19 characters):\00"
@.str.2 = [5 x i8] c"%19s\00"
@.str.3 = [74 x i8] c"string1 is: %s\0Astring2 is: %s\0Astring1 with spaces between characters is:\0A\00"
@.str.4 = [4 x i8] c"%c \00"
define void @fig06_10() {
%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 ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %3, i8* %4)
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 0
br i1 %9, label %127, label %10
10: ; preds = %0
%11 = sext i8 %8 to i32
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %11)
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 1
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
br i1 %15, label %127, label %16
16: ; preds = %10
%17 = sext i8 %14 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 2
%20 = load i8, i8* %19
%21 = icmp eq i8 %20, 0
br i1 %21, label %127, label %22
22: ; preds = %16
%23 = sext i8 %20 to i32
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 3
%26 = load i8, i8* %25
%27 = icmp eq i8 %26, 0
br i1 %27, label %127, label %28
28: ; preds = %22
%29 = sext i8 %26 to i32
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 4
%32 = load i8, i8* %31
%33 = icmp eq i8 %32, 0
br i1 %33, label %127, label %34
34: ; preds = %28
%35 = sext i8 %32 to i32
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 5
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %127, label %40
40: ; preds = %34
%41 = sext i8 %38 to i32
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 6
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 0
br i1 %45, label %127, label %46
46: ; preds = %40
%47 = sext i8 %44 to i32
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 7
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 0
br i1 %51, label %127, label %52
52: ; preds = %46
%53 = sext i8 %50 to i32
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %53)
%55 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 8
%56 = load i8, i8* %55
%57 = icmp eq i8 %56, 0
br i1 %57, label %127, label %58
58: ; preds = %52
%59 = sext i8 %56 to i32
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %59)
%61 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 9
%62 = load i8, i8* %61
%63 = icmp eq i8 %62, 0
br i1 %63, label %127, label %64
64: ; preds = %58
%65 = sext i8 %62 to i32
%66 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %65)
%67 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 10
%68 = load i8, i8* %67
%69 = icmp eq i8 %68, 0
br i1 %69, label %127, label %70
70: ; preds = %64
%71 = sext i8 %68 to i32
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %71)
%73 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 11
%74 = load i8, i8* %73
%75 = icmp eq i8 %74, 0
br i1 %75, label %127, label %76
76: ; preds = %70
%77 = sext i8 %74 to i32
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %77)
%79 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 12
%80 = load i8, i8* %79
%81 = icmp eq i8 %80, 0
br i1 %81, label %127, label %82
82: ; preds = %76
%83 = sext i8 %80 to i32
%84 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %83)
%85 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 13
%86 = load i8, i8* %85
%87 = icmp eq i8 %86, 0
br i1 %87, label %127, label %88
88: ; preds = %82
%89 = sext i8 %86 to i32
%90 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %89)
%91 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 14
%92 = load i8, i8* %91
%93 = icmp eq i8 %92, 0
br i1 %93, label %127, label %94
94: ; preds = %88
%95 = sext i8 %92 to i32
%96 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %95)
%97 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 15
%98 = load i8, i8* %97
%99 = icmp eq i8 %98, 0
br i1 %99, label %127, label %100
100: ; preds = %94
%101 = sext i8 %98 to i32
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %101)
%103 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 16
%104 = load i8, i8* %103
%105 = icmp eq i8 %104, 0
br i1 %105, label %127, label %106
106: ; preds = %100
%107 = sext i8 %104 to i32
%108 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %107)
%109 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 17
%110 = load i8, i8* %109
%111 = icmp eq i8 %110, 0
br i1 %111, label %127, label %112
112: ; preds = %106
%113 = sext i8 %110 to i32
%114 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %113)
%115 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 18
%116 = load i8, i8* %115
%117 = icmp eq i8 %116, 0
br i1 %117, label %127, label %118
118: ; preds = %112
%119 = sext i8 %116 to i32
%120 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %119)
%121 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 19
%122 = load i8, i8* %121
%123 = icmp eq i8 %122, 0
br i1 %123, label %127, label %124
124: ; preds = %118
%125 = sext i8 %122 to i32
%126 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %125)
br label %127
127: ; preds = %124, %118, %112, %106, %100, %94, %88, %82, %76, %70, %64, %58, %52, %46, %40, %34, %28, %22, %16, %10, %0
%128 = call i32 @putchar(i32 10)
ret void
}