#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
float cross_sectional_area(int, int);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
float moment_of_inertia(int, int);
float section_modulus(int, int);
int main(void) {
  int b, h;
  float crossArea, inertia, modulus;
  FILE *fout = fopen("a5.4.out", "w");
  fprintf(fout, "Lumber Size     Cross sectional     Moment of       Section\n "
                "                   Area            Inertia         "
                "Modulus\n-----------------------------------------------------"
                "-------\n");
  for (b = 2; b <= 10; b += 2) {
    for (h = 2; h <= 12; h += 2) {
      crossArea = cross_sectional_area(b, h);
      inertia = moment_of_inertia(b, h);
      modulus = section_modulus(b, h);
      fprintf(fout, "%2d x %2d %16.2f %16.2f %16.2f\n", b, h, crossArea,
              inertia, modulus);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
lea    0xe9c(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x2,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jg     122e <main+0xde>
movl   $0x2,-0xc(%rbp)
cmpl   $0xc,-0xc(%rbp)
jg     121b <main+0xcb>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1060 <cross_sectional_area@plt>
movss  %xmm0,-0x10(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <moment_of_inertia@plt>
movss  %xmm0,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <section_modulus@plt>
movss  %xmm0,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x14(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x18(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xebb(%rip),%rsi
mov    $0x3,%al
call   1040 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
jmp    11a0 <main+0x50>
jmp    1220 <main+0xd0>
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    118f <main+0x3f>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe90(%rip),%rdi
lea    0xe92(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
lea    0xe85(%rip),%rdi
mov    $0xb5,%esi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
mov    $0x2,%ebx
lea    0xf1d(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
mov    $0x2,%esi
call   1060 <cross_sectional_area@plt>
movss  %xmm0,0xc(%rsp)
mov    %ebx,%edi
mov    $0x2,%esi
call   1030 <moment_of_inertia@plt>
movss  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    $0x2,%esi
call   1050 <section_modulus@plt>
movss  0xc(%rsp),%xmm1
xorps  %xmm3,%xmm3
cvtss2sd %xmm1,%xmm3
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    $0x2,%ecx
movaps %xmm3,%xmm0
mov    $0x3,%al
call   1040 <fprintf@plt>
mov    %ebx,%edi
mov    $0x4,%esi
call   1060 <cross_sectional_area@plt>
movss  %xmm0,0xc(%rsp)
mov    %ebx,%edi
mov    $0x4,%esi
call   1030 <moment_of_inertia@plt>
movss  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    $0x4,%esi
call   1050 <section_modulus@plt>
movss  0xc(%rsp),%xmm1
xorps  %xmm3,%xmm3
cvtss2sd %xmm1,%xmm3
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    $0x4,%ecx
movaps %xmm3,%xmm0
mov    $0x3,%al
call   1040 <fprintf@plt>
mov    %ebx,%edi
mov    $0x6,%esi
call   1060 <cross_sectional_area@plt>
movss  %xmm0,0xc(%rsp)
mov    %ebx,%edi
mov    $0x6,%esi
call   1030 <moment_of_inertia@plt>
movss  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    $0x6,%esi
call   1050 <section_modulus@plt>
movss  0xc(%rsp),%xmm1
xorps  %xmm3,%xmm3
cvtss2sd %xmm1,%xmm3
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    $0x6,%ecx
movaps %xmm3,%xmm0
mov    $0x3,%al
call   1040 <fprintf@plt>
mov    %ebx,%edi
mov    $0x8,%esi
call   1060 <cross_sectional_area@plt>
movss  %xmm0,0xc(%rsp)
mov    %ebx,%edi
mov    $0x8,%esi
call   1030 <moment_of_inertia@plt>
movss  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    $0x8,%esi
call   1050 <section_modulus@plt>
movss  0xc(%rsp),%xmm1
xorps  %xmm3,%xmm3
cvtss2sd %xmm1,%xmm3
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    $0x8,%ecx
movaps %xmm3,%xmm0
mov    $0x3,%al
call   1040 <fprintf@plt>
mov    %ebx,%edi
mov    $0xa,%esi
call   1060 <cross_sectional_area@plt>
movss  %xmm0,0xc(%rsp)
mov    %ebx,%edi
mov    $0xa,%esi
call   1030 <moment_of_inertia@plt>
movss  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    $0xa,%esi
call   1050 <section_modulus@plt>
movss  0xc(%rsp),%xmm1
xorps  %xmm3,%xmm3
cvtss2sd %xmm1,%xmm3
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    $0xa,%ecx
movaps %xmm3,%xmm0
mov    $0x3,%al
call   1040 <fprintf@plt>
mov    %ebx,%edi
mov    $0xc,%esi
call   1060 <cross_sectional_area@plt>
movss  %xmm0,0xc(%rsp)
mov    %ebx,%edi
mov    $0xc,%esi
call   1030 <moment_of_inertia@plt>
movss  %xmm0,0x8(%rsp)
mov    %ebx,%edi
mov    $0xc,%esi
call   1050 <section_modulus@plt>
movss  0xc(%rsp),%xmm1
xorps  %xmm3,%xmm3
cvtss2sd %xmm1,%xmm3
movss  0x8(%rsp),%xmm1
cvtss2sd %xmm1,%xmm1
xorps  %xmm2,%xmm2
cvtss2sd %xmm0,%xmm2
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
mov    $0xc,%ecx
movaps %xmm3,%xmm0
mov    $0x3,%al
call   1040 <fprintf@plt>
lea    0x2(%rbx),%eax
cmp    $0x9,%ebx
mov    %eax,%ebx
jb     11b0 <main+0x50>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [9 x i8] c"a5.4.out\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [182 x i8] c"Lumber Size Cross sectional Moment of Section\0A Area Inertia Modulus\0A------------------------------------------------------------\0A\00"
@.str.3 = [32 x i8] c"%2d x %2d %16.2f %16.2f %16.2f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32*
store i32 0, i32* %1
%8 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %7
%9 = load i32*, i32** %7
%10 = call i32 (i32*, i8*, ...) @fprintf(i32* %9, i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.2, i64 0, i64 0))
store i32 2, i32* %2
br label %11
11: ; preds = %42, %0
%12 = load i32, i32* %2
%13 = icmp sle i32 %12, 10
br i1 %13, label %14, label %45
14: ; preds = %11
store i32 2, i32* %3
br label %15
15: ; preds = %38, %14
%16 = load i32, i32* %3
%17 = icmp sle i32 %16, 12
br i1 %17, label %18, label %41
18: ; preds = %15
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = call float @cross_sectional_area(i32 %19, i32 %20)
store float %21, float* %4
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call float @moment_of_inertia(i32 %22, i32 %23)
store float %24, float* %5
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = call float @section_modulus(i32 %25, i32 %26)
store float %27, float* %6
%28 = load i32*, i32** %7
%29 = load i32, i32* %2
%30 = load i32, i32* %3
%31 = load float, float* %4
%32 = fpext float %31 to double
%33 = load float, float* %5
%34 = fpext float %33 to double
%35 = load float, float* %6
%36 = fpext float %35 to double
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %28, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %29, i32 %30, double %32, double %34, double %36)
br label %38
38: ; preds = %18
%39 = load i32, i32* %3
%40 = add nsw i32 %39, 2
store i32 %40, i32* %3
br label %15
41: ; preds = %15
br label %42
42: ; preds = %41
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 2
store i32 %44, i32* %2
br label %11
45: ; preds = %11
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str = [9 x i8] c"a5.4.out\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [182 x i8] c"Lumber Size Cross sectional Moment of Section\0A Area Inertia Modulus\0A------------------------------------------------------------\0A\00"
@.str.3 = [32 x i8] c"%2d x %2d %16.2f %16.2f %16.2f\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = tail call i64 @fwrite(i8* getelementptr inbounds ([182 x i8], [182 x i8]* @.str.2, i64 0, i64 0), i64 181, i64 1, i32* %1)
br label %3
3: ; preds = %0, %3
%4 = phi i32 [ 2, %0 ], [ %47, %3 ]
%5 = tail call float @cross_sectional_area(i32 %4, i32 2)
%6 = tail call float @moment_of_inertia(i32 %4, i32 2)
%7 = tail call float @section_modulus(i32 %4, i32 2)
%8 = fpext float %5 to double
%9 = fpext float %6 to double
%10 = fpext float %7 to double
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 2, double %8, double %9, double %10)
%12 = tail call float @cross_sectional_area(i32 %4, i32 4)
%13 = tail call float @moment_of_inertia(i32 %4, i32 4)
%14 = tail call float @section_modulus(i32 %4, i32 4)
%15 = fpext float %12 to double
%16 = fpext float %13 to double
%17 = fpext float %14 to double
%18 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 4, double %15, double %16, double %17)
%19 = tail call float @cross_sectional_area(i32 %4, i32 6)
%20 = tail call float @moment_of_inertia(i32 %4, i32 6)
%21 = tail call float @section_modulus(i32 %4, i32 6)
%22 = fpext float %19 to double
%23 = fpext float %20 to double
%24 = fpext float %21 to double
%25 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 6, double %22, double %23, double %24)
%26 = tail call float @cross_sectional_area(i32 %4, i32 8)
%27 = tail call float @moment_of_inertia(i32 %4, i32 8)
%28 = tail call float @section_modulus(i32 %4, i32 8)
%29 = fpext float %26 to double
%30 = fpext float %27 to double
%31 = fpext float %28 to double
%32 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 8, double %29, double %30, double %31)
%33 = tail call float @cross_sectional_area(i32 %4, i32 10)
%34 = tail call float @moment_of_inertia(i32 %4, i32 10)
%35 = tail call float @section_modulus(i32 %4, i32 10)
%36 = fpext float %33 to double
%37 = fpext float %34 to double
%38 = fpext float %35 to double
%39 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 10, double %36, double %37, double %38)
%40 = tail call float @cross_sectional_area(i32 %4, i32 12)
%41 = tail call float @moment_of_inertia(i32 %4, i32 12)
%42 = tail call float @section_modulus(i32 %4, i32 12)
%43 = fpext float %40 to double
%44 = fpext float %41 to double
%45 = fpext float %42 to double
%46 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %1, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 12, double %43, double %44, double %45)
%47 = add nuw nsw i32 %4, 2
%48 = icmp ult i32 %4, 9
br i1 %48, label %3, label %49
49: ; preds = %3
ret i32 0
}