#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 *);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, int *, double *);
int /*<<< orphan*/ sprintf(char *, char *, int, double);
void fig08_12() {
  char s[80];
  int x;
  double y;
  puts("Enter an integer and a double:");
  scanf("%d%lf", &x, &y);
  sprintf(s, "integer:%6d\ndouble:%8.2f", x, y);
  printf("%s\n%s\n", "The formatted output stored in array s is:", s);
}


x86 assembly (clang, -O0):
<fig08_12>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xeb1(%rip),%rdi
call   1030 <puts@plt>
lea    0xec4(%rip),%rdi
lea    -0x54(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1050 <scanf@plt>
lea    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%edx
movsd  -0x60(%rbp),%xmm0
lea    0xeaa(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x50(%rbp),%rdx
lea    0xeb3(%rip),%rdi
lea    0xeb3(%rip),%rsi
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig08_12>:
push   %rbx
sub    $0x60,%rsp
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xec7(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x8(%rsp),%rdx
call   1050 <scanf@plt>
mov    0x4(%rsp),%edx
movsd  0x8(%rsp),%xmm0
lea    0xead(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sprintf@plt>
lea    0xeb2(%rip),%rdi
lea    0xeb2(%rip),%rsi
mov    %rbx,%rdx
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Enter an integer and a double:\00"
@.str.1 = [6 x i8] c"%d%lf\00"
@.str.2 = [25 x i8] c"integer:%6d\0Adouble:%8.2f\00"
@.str.3 = [7 x i8] c"%s\0A%s\0A\00"
@.str.4 = [43 x i8] c"The formatted output stored in array s is:\00"
define void @fig08_12() {
%1 = alloca [80 x i8]
%2 = alloca i32
%3 = alloca double
%4 = call i32 @puts(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, double* %3)
%6 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%7 = load i32, i32* %2
%8 = load double, double* %3
%9 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %7, double %8)
%10 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%11 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %10)
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"Enter an integer and a double:\00"
@.str.1 = [6 x i8] c"%d%lf\00"
@.str.2 = [25 x i8] c"integer:%6d\0Adouble:%8.2f\00"
@.str.3 = [7 x i8] c"%s\0A%s\0A\00"
@.str.4 = [43 x i8] c"The formatted output stored in array s is:\00"
define void @fig08_12() {
%1 = alloca [80 x i8]
%2 = alloca i32
%3 = alloca double
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, double* %3)
%9 = load i32, i32* %2
%10 = load double, double* %3
%11 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %9, double %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.4, i64 0, i64 0), i8* %4)
ret void
}