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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%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    0xf54(%rip),%rdi
mov    %rdi,-0x28(%rbp)
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1d(%rbp),%al
lea    0xec1(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x1d(%rbp),%al
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1d(%rbp),%al
lea    -0x5(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x5(%rbp),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x31,%eax
je     11e9 <main+0xc9>
jmp    11c7 <main+0xa7>
mov    -0x1c(%rbp),%eax
sub    $0x32,%eax
je     1216 <main+0xf6>
jmp    11d8 <main+0xb8>
mov    -0x1c(%rbp),%eax
sub    $0x33,%eax
je     1243 <main+0x123>
jmp    1270 <main+0x150>
movss  -0xc(%rbp),%xmm0
movss  0xe12(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xe6e(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127e <main+0x15e>
movss  -0xc(%rbp),%xmm0
movss  0xde1(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x14(%rbp)
lea    0xe50(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127e <main+0x15e>
movss  -0xc(%rbp),%xmm0
movss  0xdb0(%rip),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xe32(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127e <main+0x15e>
lea    0xe2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf11(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xefe(%rip),%rdi
call   1030 <puts@plt>
lea    0xf07(%rip),%rdi
call   1030 <puts@plt>
lea    0xf09(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x7(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0x7(%rsp),%eax
cmp    $0x33,%eax
je     11d7 <main+0xa7>
cmp    $0x32,%eax
je     11f4 <main+0xc4>
cmp    $0x31,%eax
jne    121d <main+0xed>
movss  0xc(%rsp),%xmm0
mulss  0xe40(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xe5c(%rip),%rdi
jmp    120f <main+0xdf>
movss  0xc(%rsp),%xmm0
mulss  0xe1b(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xe5d(%rip),%rdi
jmp    120f <main+0xdf>
movss  0xc(%rsp),%xmm0
mulss  0xe02(%rip),%xmm0
movss  %xmm0,0x8(%rsp)
lea    0xe31(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1229 <main+0xf9>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Enter size in bytes: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [22 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 = [15 x i8] c"Size in KB: %d\00"
@.str.8 = [15 x i8] c"Size in MB: %d\00"
@.str.9 = [15 x i8] c"Size in GB: %d\00"
@.str.10 = [23 x i8] c"Enter a valid choice.\0A\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 ([22 x i8], [22 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.1, i64 0, i64 0), i8* %2)
%15 = load i8, i8* %2
%16 = sext i8 %15 to i32
switch i32 %16, label %29 [
i32 49, label %17
i32 50, label %21
i32 51, label %25
]
17: ; preds = %0
%18 = load float, float* %3
%19 = fdiv float %18, 1.024000e+03
store float %19, float* %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0), float* %4)
br label %31
21: ; preds = %0
%22 = load float, float* %3
%23 = fdiv float %22, 0x4130000000000000
store float %23, float* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), float* %5)
br label %31
25: ; preds = %0
%26 = load float, float* %3
%27 = fdiv float %26, 0x41D0000000000000
store float %27, float* %6
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0), float* %6)
br label %31
29: ; preds = %0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.10, i64 0, i64 0))
br label %31
31: ; preds = %29, %25, %21, %17
ret i32 0
}

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