void fig08_08() {
  const char *string = "1234567abc";
  char *remainderPtr;
  long x;
  x = strtoul(string, &remainderPtr, 0);
  printf("%s\"%s\"\n%s%lu\n%s\"%s\"\n%s%ld\n", "The original string is ",
         string, "The converted value is ", x,
         "The remainder of the original string is ", remainderPtr,
         "The converted value minus 567 is ", x - 567);
}


x86 assembly (clang, -O0):
<fig08_08>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1040 <strtoul@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%r8
mov    -0x10(%rbp),%r11
mov    -0x18(%rbp),%rax
sub    $0x237,%rax
lea    0xea8(%rip),%rdi
lea    0xebc(%rip),%rsi
lea    0xecd(%rip),%rcx
lea    0xede(%rip),%r9
lea    0xf00(%rip),%r10
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig08_08>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%r14
mov    %rsp,%rsi
mov    %r14,%rdi
xor    %edx,%edx
call   1040 <strtoul@plt>
lea    -0x237(%rax),%rbx
sub    $0x8,%rsp
lea    0xf35(%rip),%r10
lea    0xeba(%rip),%rdi
lea    0xece(%rip),%rsi
lea    0xedf(%rip),%rcx
lea    0xef0(%rip),%r9
mov    %r14,%rdx
mov    %rax,%r8
xor    %eax,%eax
push   %rbx
push   %r10
push   0x18(%rsp)
call   1030 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [11 x i8] c"1234567abc\00"
@.str.1 = [27 x i8] c"%s\22%s\22\0A%s%lu\0A%s\22%s\22\0A%s%ld\0A\00"
@.str.2 = [24 x i8] c"The original string is \00"
@.str.3 = [24 x i8] c"The converted value is \00"
@.str.4 = [41 x i8] c"The remainder of the original string is \00"
@.str.5 = [34 x i8] c"The converted value minus 567 is \00"
define void @fig08_08() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i64
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %1
%4 = load i8*, i8** %1
%5 = call i64 @strtoul(i8* %4, i8** %2, i32 0)
store i64 %5, i64* %3
%6 = load i8*, i8** %1
%7 = load i64, i64* %3
%8 = load i8*, i8** %2
%9 = load i64, i64* %3
%10 = sub nsw i64 %9, 567
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 %7, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i8* %8, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i64 %10)
ret void
}

LLVM IR (-O2):
@.str = [11 x i8] c"1234567abc\00"
@.str.1 = [27 x i8] c"%s\22%s\22\0A%s%lu\0A%s\22%s\22\0A%s%ld\0A\00"
@.str.2 = [24 x i8] c"The original string is \00"
@.str.3 = [24 x i8] c"The converted value is \00"
@.str.4 = [41 x i8] c"The remainder of the original string is \00"
@.str.5 = [34 x i8] c"The converted value minus 567 is \00"
define void @fig08_08() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = call i64 @strtoul(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8** %1, i32 0)
%4 = load i8*, i8** %1
%5 = add nsw i64 %3, -567
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i64 %3, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i8* %4, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0), i64 %5)
ret void
}