#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 *, int, char *,
                          char const *);
int *strpbrk(char const *, char const *);
void fig08_22() {
  const char *string1 = "This is a test";
  const char *string2 = "beware";
  printf("%s\"%s\"\n\'%c\'%s\n\"%s\"\n", "Of the characters in ", string2,
         *strpbrk(string1, string2), " appears earliest in ", string1);
}


x86 assembly (clang, -O0):
<fig08_22>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xed5(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <strpbrk@plt>
mov    -0x18(%rbp),%rdx
mov    (%rax),%ecx
mov    -0x8(%rbp),%r9
lea    0xeb2(%rip),%rdi
lea    0xebf(%rip),%rsi
lea    0xece(%rip),%r8
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig08_22>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%r14
lea    0xedd(%rip),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strpbrk@plt>
mov    (%rax),%ecx
lea    0xed0(%rip),%rdi
lea    0xedd(%rip),%rsi
lea    0xeec(%rip),%r8
mov    %rbx,%rdx
mov    %r14,%r9
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"This is a test\00"
@.str.1 = [7 x i8] c"beware\00"
@.str.2 = [20 x i8] c"%s\22%s\22\0A'%c'%s\0A\22%s\22\0A\00"
@.str.3 = [22 x i8] c"Of the characters in \00"
@.str.4 = [22 x i8] c" appears earliest in \00"
define void @fig08_22() {
%1 = alloca i8*
%2 = alloca i8*
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %2
%3 = load i8*, i8** %2
%4 = load i8*, i8** %1
%5 = load i8*, i8** %2
%6 = call i32* @strpbrk(i8* %4, i8* %5)
%7 = load i32, i32* %6
%8 = load i8*, i8** %1
%9 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %3, i32 %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %8)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"This is a test\00"
@.str.1 = [7 x i8] c"beware\00"
@.str.2 = [20 x i8] c"%s\22%s\22\0A'%c'%s\0A\22%s\22\0A\00"
@.str.3 = [22 x i8] c"Of the characters in \00"
@.str.4 = [22 x i8] c" appears earliest in \00"
define void @fig08_22() {
%1 = tail call i32* @strpbrk(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%2 = load i32, i32* %1
%3 = tail call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %2, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
ret void
}