#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 *, double);
void fig09_14() {
  int c = 1427;
  double p = 1427.0;
  printf("%#o\n", c);
  printf("%#x\n", c);
  printf("%#X\n", c);
  printf("\n%g\n", p);
  printf("%#g\n", p);
}


x86 assembly (clang, -O0):
<fig09_14>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x593,-0x4(%rbp)
movsd  0xed9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x4(%rbp),%xmm0
lea    0xec4(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x4(%rbp),%xmm0
lea    0xeb8(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x10(%rbp),%xmm0
lea    0xea0(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fig09_14>:
push   %rax
lea    0xef0(%rip),%rdi
movsd  0xee0(%rip),%xmm0
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
movsd  0xecc(%rip),%xmm0
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
movsd  0xeb8(%rip),%xmm0
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
movsd  0xea4(%rip),%xmm0
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
movsd  0xe90(%rip),%xmm0
pop    %rax
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%#o\0A\00"
@.str.1 = [5 x i8] c"%#x\0A\00"
@.str.2 = [5 x i8] c"%#X\0A\00"
@.str.3 = [5 x i8] c"\0A%g\0A\00"
@.str.4 = [5 x i8] c"%#g\0A\00"
define void @fig09_14() {
%1 = alloca i32
%2 = alloca double
store i32 1427, i32* %1
store double 1.427000e+03, double* %2
%3 = load i32, i32* %1
%4 = sitofp i32 %3 to double
%5 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %4)
%6 = load i32, i32* %1
%7 = sitofp i32 %6 to double
%8 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %7)
%9 = load i32, i32* %1
%10 = sitofp i32 %9 to double
%11 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %10)
%12 = load double, double* %2
%13 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double %12)
%14 = load double, double* %2
%15 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double %14)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%#o\0A\00"
@.str.1 = [5 x i8] c"%#x\0A\00"
@.str.2 = [5 x i8] c"%#X\0A\00"
@.str.3 = [5 x i8] c"\0A%g\0A\00"
@.str.4 = [5 x i8] c"%#g\0A\00"
define void @fig09_14() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double 1.427000e+03)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double 1.427000e+03)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double 1.427000e+03)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), double 1.427000e+03)
%5 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), double 1.427000e+03)
ret void
}