#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 *, ...);
int /*<<< orphan*/ puts(char *);
void fig09_09() {
  int i = 873;
  double f = 123.94536;
  char s[] = "Happy Birthday";
  puts("Using precision for integers");
  printf("\t%.4d\n\t%.9d\n\n", i, i);
  puts("Using precision for floating-point numbers");
  printf("\t%.3f\n\t%.3e\n\t%.3g\n\n", f, f, f);
  puts("Using precision for sting");
  printf("\t%.11s\n", s);
}


x86 assembly (clang, -O0):
<fig09_09>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x369,-0x4(%rbp)
movsd  0xec9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0xec5(%rip),%rax
mov    %rax,-0x1f(%rbp)
mov    0xec3(%rip),%eax
mov    %eax,-0x17(%rbp)
mov    0xebd(%rip),%ax
mov    %ax,-0x13(%rbp)
mov    0xeb5(%rip),%al
mov    %al,-0x11(%rbp)
lea    0xeac(%rip),%rdi
call   1030 <puts@plt>
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
call   1030 <puts@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
lea    0xec7(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
lea    0xecd(%rip),%rdi
call   1030 <puts@plt>
lea    -0x1f(%rbp),%rsi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig09_09>:
sub    $0x18,%rsp
movabs $0x79616468747269,%rax
mov    %rax,0xf(%rsp)
movabs $0x6942207970706148,%rax
20 42 69
mov    %rax,0x8(%rsp)
lea    0xece(%rip),%rdi
call   1030 <puts@plt>
lea    0xedf(%rip),%rdi
mov    $0x369,%esi
mov    $0x369,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
lea    0xef4(%rip),%rdi
movsd  0xe7f(%rip),%xmm0
movaps %xmm0,%xmm1
movaps %xmm0,%xmm2
mov    $0x3,%al
call   1040 <printf@plt>
lea    0xeec(%rip),%rdi
call   1030 <puts@plt>
lea    0xefa(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x18,%rsp
ret

LLVM IR (-O0):
@__const.fig09_09.s = [15 x i8] c"Happy Birthday\00"
@.str = [29 x i8] c"Using precision for integers\00"
@.str.1 = [14 x i8] c"\09%.4d\0A\09%.9d\0A\0A\00"
@.str.2 = [43 x i8] c"Using precision for floating-point numbers\00"
@.str.3 = [20 x i8] c"\09%.3f\0A\09%.3e\0A\09%.3g\0A\0A\00"
@.str.4 = [26 x i8] c"Using precision for sting\00"
@.str.5 = [8 x i8] c"\09%.11s\0A\00"
define void @fig09_09() {
%1 = alloca i32
%2 = alloca double
%3 = alloca [15 x i8]
store i32 873, i32* %1
store double 0x405EFC80C73ABC94, double* %2
%4 = bitcast [15 x i8]* %3 to i8*
%5 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%6 = load i32, i32* %1
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7)
%9 = call i32 @puts(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%10 = load double, double* %2
%11 = load double, double* %2
%12 = load double, double* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double %10, double %11, double %12)
%14 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%15 = getelementptr inbounds [15 x i8], [15 x i8]* %3, i64 0, i64 0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %15)
ret void
}

LLVM IR (-O2):
@__const.fig09_09.s = [15 x i8] c"Happy Birthday\00"
@.str = [29 x i8] c"Using precision for integers\00"
@.str.1 = [14 x i8] c"\09%.4d\0A\09%.9d\0A\0A\00"
@.str.2 = [43 x i8] c"Using precision for floating-point numbers\00"
@.str.3 = [20 x i8] c"\09%.3f\0A\09%.3e\0A\09%.3g\0A\0A\00"
@.str.4 = [26 x i8] c"Using precision for sting\00"
@.str.5 = [8 x i8] c"\09%.11s\0A\00"
define void @fig09_09() {
%1 = alloca [15 x i8]
%2 = getelementptr inbounds [15 x i8], [15 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i32 873, i32 873)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), double 0x405EFC80C73ABC94, double 0x405EFC80C73ABC94, double 0x405EFC80C73ABC94)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %2)
ret void
}