#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 *, ...);
void main() {
  int distance, distm, distcm, distin;
  char option;
  printf("enter the distance in kms \n");
  scanf("%d", &distance);
  distm = distance * 1000;
  distin = distance * 39;
  distcm = distance * distm * 100;
  printf("please select option below \n");
  printf("to calculate distance in inches press a \n");
  printf("to calculate distance in metres press b \n");
  printf("to calculate distance in centimetres press c \n");
  scanf("%s", &option);
  switch (option) {
  case 'a':
    printf("the distance in inches is %d inches\n", distin);
    break;
  case 'b':
    printf("the distance in metres is %d metres \n", distm);
    break;
  case 'c':
    printf("the distance in centimetres is %d cms \n", distcm);
    break;
  default:
    printf("invalid option \n");
    break;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x19(%rbp)
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xed9(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x19(%rbp),%al
mov    -0x4(%rbp),%ecx
imul   $0x3e8,%ecx,%ecx
mov    %ecx,-0x8(%rbp)
mov    -0x4(%rbp),%ecx
imul   $0x27,%ecx,%ecx
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%edx
imul   %edx,%ecx
imul   $0x64,%ecx,%ecx
mov    %ecx,-0xc(%rbp)
lea    0xea5(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xece(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xee9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x19(%rbp),%al
lea    0xf09(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1040 <scanf@plt>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x18(%rbp)
sub    $0x61,%eax
je     11f6 <main+0xd6>
jmp    11d4 <main+0xb4>
mov    -0x18(%rbp),%eax
sub    $0x62,%eax
je     120c <main+0xec>
jmp    11e5 <main+0xc5>
mov    -0x18(%rbp),%eax
sub    $0x63,%eax
je     1222 <main+0x102>
jmp    1238 <main+0x118>
mov    -0x10(%rbp),%esi
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1246 <main+0x126>
mov    -0x8(%rbp),%esi
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1246 <main+0x126>
mov    -0xc(%rbp),%esi
lea    0xee1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1246 <main+0x126>
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xf3f(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%ebp
imul   $0x3e8,%ebp,%ebx
lea    0xf31(%rip),%rdi
call   1030 <puts@plt>
lea    0xf41(%rip),%rdi
call   1030 <puts@plt>
lea    0xf5e(%rip),%rdi
call   1030 <puts@plt>
lea    0xf7b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe70(%rip),%rdi
lea    0x3(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movsbl 0x3(%rsp),%eax
cmp    $0x63,%eax
je     11bf <main+0x8f>
cmp    $0x62,%eax
je     11ce <main+0x9e>
cmp    $0x61,%eax
jne    11e0 <main+0xb0>
imul   $0x27,%ebp,%esi
lea    0xe49(%rip),%rdi
jmp    11d7 <main+0xa7>
imul   %ebx,%ebp
imul   $0x64,%ebp,%esi
lea    0xe85(%rip),%rdi
jmp    11d7 <main+0xa7>
lea    0xe56(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ec <main+0xbc>
lea    0xf49(%rip),%rdi
call   1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c"enter the distance in kms \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [29 x i8] c"please select option below \0A\00"
@.str.3 = [42 x i8] c"to calculate distance in inches press a \0A\00"
@.str.4 = [42 x i8] c"to calculate distance in metres press b \0A\00"
@.str.5 = [47 x i8] c"to calculate distance in centimetres press c \0A\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [37 x i8] c"the distance in inches is %d inches\0A\00"
@.str.8 = [38 x i8] c"the distance in metres is %d metres \0A\00"
@.str.9 = [40 x i8] c"the distance in centimetres is %d cms \0A\00"
@.str.10 = [17 x i8] c"invalid option \0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = mul nsw i32 %8, 1000
store i32 %9, i32* %2
%10 = load i32, i32* %1
%11 = mul nsw i32 %10, 39
store i32 %11, i32* %4
%12 = load i32, i32* %1
%13 = load i32, i32* %2
%14 = mul nsw i32 %12, %13
%15 = mul nsw i32 %14, 100
store i32 %15, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%21 = load i8, i8* %5
%22 = sext i8 %21 to i32
switch i32 %22, label %32 [
i32 97, label %23
i32 98, label %26
i32 99, label %29
]
23: ; preds = %0
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %24)
br label %34
26: ; preds = %0
%27 = load i32, i32* %2
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %27)
br label %34
29: ; preds = %0
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i32 %30)
br label %34
32: ; preds = %0
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.10, i64 0, i64 0))
br label %34
34: ; preds = %32, %29, %26, %23
ret void
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.6 = [3 x i8] c"%s\00"
@.str.7 = [37 x i8] c"the distance in inches is %d inches\0A\00"
@.str.8 = [38 x i8] c"the distance in metres is %d metres \0A\00"
@.str.9 = [40 x i8] c"the distance in centimetres is %d cms \0A\00"
@str = [27 x i8] c"enter the distance in kms \00"
@str.11 = [28 x i8] c"please select option below \00"
@str.12 = [41 x i8] c"to calculate distance in inches press a \00"
@str.13 = [41 x i8] c"to calculate distance in metres press b \00"
@str.14 = [46 x i8] c"to calculate distance in centimetres press c \00"
@str.15 = [16 x i8] c"invalid option \00"
define void @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 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), i32* %1)
%6 = load i32, i32* %1
%7 = mul nsw i32 %6, 1000
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.11, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.12, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.13, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.14, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%13 = load i8, i8* %2
%14 = sext i8 %13 to i32
switch i32 %14, label %24 [
i32 97, label %15
i32 98, label %18
i32 99, label %20
]
15: ; preds = %0
%16 = mul nsw i32 %6, 39
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.7, i64 0, i64 0), i32 %16)
br label %26
18: ; preds = %0
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %7)
br label %26
20: ; preds = %0
%21 = mul i32 %6, 100
%22 = mul i32 %21, %7
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.9, i64 0, i64 0), i32 %22)
br label %26
24: ; preds = %0
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.15, i64 0, i64 0))
br label %26
26: ; preds = %24, %20, %18, %15
ret void
}