#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 *, char *, char const *, char *, char const *,
                          char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strcspn(char const *, char const *);
void fig08_21() {
  const char *string1 = "The value is 3.14159";
  const char *string2 = "1234567890";
  printf("%s%s\n%s%s\n\n%s\n%s%u\n", "string1 = ", string1,
         "string2 = ", string2, "The length of the initial segment of string1",
         "containing no characters from string2 = ", strcspn(string1, string2));
}


x86 assembly (clang, -O0):
<fig08_21>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xedb(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strcspn@plt>
mov    -0x20(%rbp),%rdx
mov    -0x18(%rbp),%r8
lea    0xeb6(%rip),%rdi
lea    0xec3(%rip),%rsi
lea    0xf12(%rip),%rcx
lea    0xec0(%rip),%r9
lea    0xee6(%rip),%r10
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig08_21>:
push   %rax
lea    0xf54(%rip),%rax
lea    0xf01(%rip),%rdi
lea    0xf0e(%rip),%rsi
lea    0xed3(%rip),%rdx
lea    0xf56(%rip),%rcx
lea    0xeda(%rip),%r8
lea    0xefd(%rip),%r9
push   $0xd
push   %rax
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rax
ret

LLVM IR (-O0):
@.str = [21 x i8] c"The value is 3.14159\00"
@.str.1 = [11 x i8] c"1234567890\00"
@.str.2 = [20 x i8] c"%s%s\0A%s%s\0A\0A%s\0A%s%u\0A\00"
@.str.3 = [11 x i8] c"string1 = \00"
@.str.4 = [11 x i8] c"string2 = \00"
@.str.5 = [45 x i8] c"The length of the initial segment of string1\00"
@.str.6 = [41 x i8] c"containing no characters from string2 = \00"
define void @fig08_21() {
%1 = alloca i8*
%2 = alloca i8*
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %2
%3 = load i8*, i8** %1
%4 = load i8*, i8** %2
%5 = load i8*, i8** %1
%6 = load i8*, i8** %2
%7 = call i32 @strcspn(i8* %5, i8* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %3, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i32 %7)
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"The value is 3.14159\00"
@.str.1 = [11 x i8] c"1234567890\00"
@.str.2 = [20 x i8] c"%s%s\0A%s%s\0A\0A%s\0A%s%u\0A\00"
@.str.3 = [11 x i8] c"string1 = \00"
@.str.4 = [11 x i8] c"string2 = \00"
@.str.5 = [45 x i8] c"The length of the initial segment of string1\00"
@.str.6 = [41 x i8] c"containing no characters from string2 = \00"
define void @fig08_21() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0), i32 13)
ret void
}