#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 compute_speed(float, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, float *);
int main(void) {
  float speed;
  float bps;
  int i, j;
  int t2;
  printf("MHz? ");
  scanf(" %f", &speed);
  for (i = 0; i < 32; i++) {
    printf("%3d: ", 8 * i);
    for (j = 0; j < 8; j++) {
      t2 = j + 8 * i;
      bps = speed * 1000000 / (2 * (t2 + 2));
      printf("%6.0f|", bps);
    }
    printf("\n");
  }
  printf("SC: %d\n", compute_speed(speed * 16.0, 16.0));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x20,-0x10(%rbp)
jge    1205 <main+0xd5>
mov    -0x10(%rbp),%esi
shl    $0x3,%esi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11e9 <main+0xb9>
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x3,%ecx
add    %ecx,%eax
mov    %eax,-0x18(%rbp)
movss  0xe5f(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%eax
add    $0x2,%eax
shl    $0x1,%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe48(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1189 <main+0x59>
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1164 <main+0x34>
movss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdea(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movsd  0xdda(%rip),%xmm1
call   1030 <compute_speed@plt>
mov    %eax,%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeba(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0x12,%ebx
lea    0xea8(%rip),%r14
lea    0xea7(%rip),%r15
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    -0xe(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
movss  0xe5c(%rip),%xmm2
mulss  %xmm2,%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0xc(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
mulss  0xe2b(%rip),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0xa(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
mulss  0xdfe(%rip),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0x8(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
mulss  0xdd1(%rip),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0x6(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
mulss  0xda4(%rip),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0x4(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
mulss  0xd77(%rip),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    -0x2(%rbx),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x4(%rsp),%xmm1
mulss  0xd4a(%rip),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
movss  0x4(%rsp),%xmm1
mulss  0xd20(%rip),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
mov    %r15,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
add    $0x10,%ebx
add    $0x8,%ebp
cmp    $0x212,%ebx
jne    1180 <main+0x40>
movss  0x4(%rsp),%xmm0
mulss  0xce5(%rip),%xmm0
movsd  0xce1(%rip),%xmm1
call   1040 <compute_speed@plt>
lea    0xcf4(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"MHz? \00"
@.str.1 = [4 x i8] c" %f\00"
@.str.2 = [6 x i8] c"%3d: \00"
@.str.3 = [7 x i8] c"%6.0f|\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [8 x i8] c"SC: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float* %2)
store i32 0, i32* %4
br label %9
9: ; preds = %39, %0
%10 = load i32, i32* %4
%11 = icmp slt i32 %10, 32
br i1 %11, label %12, label %42
12: ; preds = %9
%13 = load i32, i32* %4
%14 = mul nsw i32 8, %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %14)
store i32 0, i32* %5
br label %16
16: ; preds = %34, %12
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 8
br i1 %18, label %19, label %37
19: ; preds = %16
%20 = load i32, i32* %5
%21 = load i32, i32* %4
%22 = mul nsw i32 8, %21
%23 = add nsw i32 %20, %22
store i32 %23, i32* %6
%24 = load float, float* %2
%25 = fmul float %24, 1.000000e+06
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 2
%28 = mul nsw i32 2, %27
%29 = sitofp i32 %28 to float
%30 = fdiv float %25, %29
store float %30, float* %3
%31 = load float, float* %3
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %32)
br label %34
34: ; preds = %19
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
br label %16
37: ; preds = %16
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %39
39: ; preds = %37
%40 = load i32, i32* %4
%41 = add nsw i32 %40, 1
store i32 %41, i32* %4
br label %9
42: ; preds = %9
%43 = load float, float* %2
%44 = fpext float %43 to double
%45 = fmul double %44, 1.600000e+01
%46 = fptrunc double %45 to float
%47 = call i32 @compute_speed(float %46, double 1.600000e+01)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %47)
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"MHz? \00"
@.str.1 = [4 x i8] c" %f\00"
@.str.2 = [6 x i8] c"%3d: \00"
@.str.3 = [7 x i8] c"%6.0f|\00"
@.str.5 = [8 x i8] c"SC: %d\0A\00"
define i32 @main() {
%1 = alloca float
%2 = bitcast float* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), float* %1)
br label %5
5: ; preds = %0, %5
%6 = phi i32 [ 0, %0 ], [ %74, %5 ]
%7 = shl nuw nsw i32 %6, 3
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %7)
%9 = load float, float* %1
%10 = fmul float %9, 1.000000e+06
%11 = shl nuw i32 %6, 4
%12 = or i32 %11, 4
%13 = sitofp i32 %12 to float
%14 = fdiv float %10, %13
%15 = fpext float %14 to double
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %15)
%17 = load float, float* %1
%18 = fmul float %17, 1.000000e+06
%19 = shl i32 %6, 4
%20 = or i32 %19, 6
%21 = sitofp i32 %20 to float
%22 = fdiv float %18, %21
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %23)
%25 = load float, float* %1
%26 = fmul float %25, 1.000000e+06
%27 = shl i32 %6, 4
%28 = or i32 %27, 8
%29 = sitofp i32 %28 to float
%30 = fdiv float %26, %29
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %31)
%33 = load float, float* %1
%34 = fmul float %33, 1.000000e+06
%35 = shl i32 %6, 4
%36 = or i32 %35, 10
%37 = sitofp i32 %36 to float
%38 = fdiv float %34, %37
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %39)
%41 = load float, float* %1
%42 = fmul float %41, 1.000000e+06
%43 = shl i32 %6, 4
%44 = or i32 %43, 12
%45 = sitofp i32 %44 to float
%46 = fdiv float %42, %45
%47 = fpext float %46 to double
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %47)
%49 = load float, float* %1
%50 = fmul float %49, 1.000000e+06
%51 = shl i32 %6, 4
%52 = or i32 %51, 14
%53 = sitofp i32 %52 to float
%54 = fdiv float %50, %53
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %55)
%57 = load float, float* %1
%58 = fmul float %57, 1.000000e+06
%59 = shl i32 %6, 4
%60 = add i32 %59, 16
%61 = sitofp i32 %60 to float
%62 = fdiv float %58, %61
%63 = fpext float %62 to double
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %63)
%65 = load float, float* %1
%66 = fmul float %65, 1.000000e+06
%67 = shl i32 %6, 4
%68 = add i32 %67, 18
%69 = sitofp i32 %68 to float
%70 = fdiv float %66, %69
%71 = fpext float %70 to double
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), double %71)
%73 = call i32 @putchar(i32 10)
%74 = add nuw nsw i32 %6, 1
%75 = icmp eq i32 %74, 32
br i1 %75, label %76, label %5
76: ; preds = %5
%77 = load float, float* %1
%78 = fmul float %77, 1.600000e+01
%79 = call i32 @compute_speed(float %78, double 1.600000e+01)
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i32 %79)
ret i32 0
}