void fig08_13() {
  char s[] = "31298 87.375";
  int x;
  double y;
  sscanf(s, "%d%lf", &x, &y);
  printf("%s\n%s%6d\n%s%8.3f\n",
         "The values stored in character array s are:", "integer:", x,
         "double:", y);
}


x86 assembly (clang, -O0):
<fig08_13>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0xed1(%rip),%rax
mov    %rax,-0xd(%rbp)
mov    0xecf(%rip),%eax
mov    %eax,-0x5(%rbp)
mov    0xeca(%rip),%al
mov    %al,-0x1(%rbp)
lea    -0xd(%rbp),%rdi
lea    0xebd(%rip),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x20(%rbp),%rcx
mov    $0x0,%al
call   1040 <sscanf@plt>
mov    -0x14(%rbp),%ecx
movsd  -0x20(%rbp),%xmm0
lea    0xea5(%rip),%rdi
lea    0xeb0(%rip),%rsi
lea    0xed5(%rip),%rdx
lea    0xed7(%rip),%r8
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig08_13>:
sub    $0x28,%rsp
movabs $0x3537332e373820,%rax
mov    %rax,0x1d(%rsp)
movabs $0x3738203839323133,%rax
20 38 37
mov    %rax,0x18(%rsp)
lea    0xec4(%rip),%rsi
lea    0x18(%rsp),%rdi
lea    0xc(%rsp),%rdx
lea    0x10(%rsp),%rcx
xor    %eax,%eax
call   1040 <sscanf@plt>
mov    0xc(%rsp),%ecx
movsd  0x10(%rsp),%xmm0
lea    0xea3(%rip),%rdi
lea    0xeae(%rip),%rsi
lea    0xed3(%rip),%rdx
lea    0xed5(%rip),%r8
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x28,%rsp
ret

LLVM IR (-O0):
@__const.fig08_13.s = [13 x i8] c"31298 87.375\00"
@.str = [6 x i8] c"%d%lf\00"
@.str.1 = [18 x i8] c"%s\0A%s%6d\0A%s%8.3f\0A\00"
@.str.2 = [44 x i8] c"The values stored in character array s are:\00"
@.str.3 = [9 x i8] c"integer:\00"
@.str.4 = [8 x i8] c"double:\00"
define void @fig08_13() {
%1 = alloca [13 x i8]
%2 = alloca i32
%3 = alloca double
%4 = bitcast [13 x i8]* %1 to i8*
%5 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%6 = call i32 (i8*, i8*, ...) @sscanf(i8* %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, double* %3)
%7 = load i32, i32* %2
%8 = load double, double* %3
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %8)
ret void
}

LLVM IR (-O2):
@__const.fig08_13.s = [13 x i8] c"31298 87.375\00"
@.str = [6 x i8] c"%d%lf\00"
@.str.1 = [18 x i8] c"%s\0A%s%6d\0A%s%8.3f\0A\00"
@.str.2 = [44 x i8] c"The values stored in character array s are:\00"
@.str.3 = [9 x i8] c"integer:\00"
@.str.4 = [8 x i8] c"double:\00"
define void @fig08_13() {
%1 = alloca [13 x i8]
%2 = alloca i32
%3 = alloca double
%4 = getelementptr inbounds [13 x i8], [13 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = call i32 (i8*, i8*, ...) @sscanf(i8* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %2, double* %3)
%8 = load i32, i32* %2
%9 = load double, double* %3
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i32 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %9)
ret void
}