#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*/ scanf(char *, ...);
int main(void) {
  char choice;
  float byte, kb, mb, gb;
  printf("Enter size in bytes: ");
  scanf("%f", &byte);
  printf("Conversion Options - \n");
  printf("1. byte to KB\n");
  printf("2. byte to MB\n");
  printf("3. byte to GB\n");
  printf("Enter choice: ");
  scanf("%d", &choice);
  switch (choice) {
  case 1:
    kb = byte / 1024;
    printf("Size in KB: %f KB", kb);
    break;
  case 2:
    mb = byte / (1024 * 1024);
    printf("Size in MB: %f MB", mb);
    break;
  case 3:
    gb = byte / (1024 * 1024 * 1024);
    printf("Size in GB: %f GB", gb);
    break;
  default:
    printf("Enter a valid choice.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed6(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x1d(%rbp)
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xed8(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1d(%rbp),%al
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xed0(%rip),%rdi
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     11e8 <main+0xc8>
jmp    11c6 <main+0xa6>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     121a <main+0xfa>
jmp    11d7 <main+0xb7>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
je     124c <main+0x12c>
jmp    127e <main+0x15e>
movss  -0xc(%rbp),%xmm0
movss  0xe13(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128c <main+0x16c>
movss  -0xc(%rbp),%xmm0
movss  0xddd(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe4d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128c <main+0x16c>
movss  -0xc(%rbp),%xmm0
movss  0xda7(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    128c <main+0x16c>
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf34(%rip),%rdi
call   1030 <puts@plt>
lea    0xf36(%rip),%rdi
call   1030 <puts@plt>
lea    0xf38(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe9d(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0x3(%rsp),%eax
cmp    $0x3,%eax
je     11d2 <main+0xa2>
cmp    $0x2,%eax
je     11ed <main+0xbd>
cmp    $0x1,%eax
jne    120f <main+0xdf>
movss  0x4(%rsp),%xmm0
mulss  0xe43(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe67(%rip),%rdi
jmp    1206 <main+0xd6>
movss  0x4(%rsp),%xmm0
mulss  0xe20(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe70(%rip),%rdi
jmp    1206 <main+0xd6>
movss  0x4(%rsp),%xmm0
mulss  0xe09(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe43(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    121d <main+0xed>
lea    0xe57(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter size in bytes: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [23 x i8] c"Conversion Options - \0A\00"
@.str.3 = [15 x i8] c"1. byte to KB\0A\00"
@.str.4 = [15 x i8] c"2. byte to MB\0A\00"
@.str.5 = [15 x i8] c"3. byte to GB\0A\00"
@.str.6 = [15 x i8] c"Enter choice: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [18 x i8] c"Size in KB: %f KB\00"
@.str.9 = [18 x i8] c"Size in MB: %f MB\00"
@.str.10 = [18 x i8] c"Size in GB: %f GB\00"
@.str.11 = [22 x i8] c"Enter a valid choice.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %2)
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
switch i32 %16, label %35 [
i32 1, label %17
i32 2, label %23
i32 3, label %29
]
17: ; preds = %0
%18 = load float, float* %3
%19 = fdiv float %18, 1.024000e+03
store float %19, float* %4
%20 = load float, float* %4
%21 = fpext float %20 to double
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), double %21)
br label %37
23: ; preds = %0
%24 = load float, float* %3
%25 = fdiv float %24, 0x4130000000000000
store float %25, float* %5
%26 = load float, float* %5
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), double %27)
br label %37
29: ; preds = %0
%30 = load float, float* %3
%31 = fdiv float %30, 0x41D0000000000000
store float %31, float* %6
%32 = load float, float* %6
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), double %33)
br label %37
35: ; preds = %0
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
br label %37
37: ; preds = %35, %29, %23, %17
ret i32 0
}

LLVM IR (-O2):
@.str = [22 x i8] c"Enter size in bytes: \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.6 = [15 x i8] c"Enter choice: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [18 x i8] c"Size in KB: %f KB\00"
@.str.9 = [18 x i8] c"Size in MB: %f MB\00"
@.str.10 = [18 x i8] c"Size in GB: %f GB\00"
@.str.11 = [22 x i8] c"Enter a valid choice.\00"
@str = [22 x i8] c"Conversion Options - \00"
@str.12 = [14 x i8] c"1. byte to KB\00"
@str.13 = [14 x i8] c"2. byte to MB\00"
@str.14 = [14 x i8] c"3. byte to GB\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca float
%3 = bitcast float* %2 to i8*
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.13, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.14, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i8* %1)
%12 = load i8, i8* %1
%13 = sext i8 %12 to i32
switch i32 %13, label %29 [
i32 1, label %14
i32 2, label %19
i32 3, label %24
]
14: ; preds = %0
%15 = load float, float* %2
%16 = fmul float %15, 0x3F50000000000000
%17 = fpext float %16 to double
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), double %17)
br label %31
19: ; preds = %0
%20 = load float, float* %2
%21 = fmul float %20, 0x3EB0000000000000
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0), double %22)
br label %31
24: ; preds = %0
%25 = load float, float* %2
%26 = fmul float %25, 0x3E10000000000000
%27 = fpext float %26 to double
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0), double %27)
br label %31
29: ; preds = %0
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.11, i64 0, i64 0))
br label %31
31: ; preds = %29, %24, %19, %14
ret i32 0
}