#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 */
double atof(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int main() {
  double num1 = 0, num2 = 0;
  char str[100] = {'\0'};
  printf("\nEnter number 1 :");
  scanf("%s", str);
  num1 = atof(str);
  printf("\nEnter number 2 :");
  scanf("%s", str);
  num2 = atof(str);
  printf("\n%g + %g = %g", num1, num2, num1 + num2);
  printf("\n%g - %g = %g", num1, num2, num1 - num2);
  printf("\n%g * %g = %g", num1, num2, num1 * num2);
  (num2 != 0) ? printf("\n%g / %g = %g\n", num1, num2, num1 / num2)
              : printf("\n%g / %g = undefined\n", num1, num2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe87(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x10(%rbp)
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xe5b(%rip),%rdi
call   1060 <scanf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
addsd  -0x18(%rbp),%xmm2
lea    0xe42(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
subsd  -0x18(%rbp),%xmm2
lea    0xe2e(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  -0x18(%rbp),%xmm2
lea    0xe1a(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  -0x18(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    124d <main+0x10d>
jp     124d <main+0x10d>
jmp    1274 <main+0x134>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
divsd  -0x18(%rbp),%xmm2
lea    0xde9(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
jmp    128c <main+0x14c>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xddb(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
xorpd  %xmm0,%xmm0
movapd %xmm0,0x60(%rsp)
movapd %xmm0,0x50(%rsp)
movapd %xmm0,0x40(%rsp)
movapd %xmm0,0x30(%rsp)
movapd %xmm0,0x20(%rsp)
movapd %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
lea    0xe92(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe96(%rip),%r14
lea    0x10(%rsp),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <atof@plt>
movsd  %xmm0,(%rsp)
lea    0xe75(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    %rbx,%rdi
call   1030 <atof@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
movapd %xmm0,%xmm2
addsd  %xmm1,%xmm2
lea    0xe4f(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
subsd  %xmm1,%xmm2
lea    0xe3c(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  (%rsp),%xmm0
movapd %xmm0,%xmm2
movsd  0x8(%rsp),%xmm1
mulsd  %xmm1,%xmm2
lea    0xe29(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jne    1233 <main+0x103>
jnp    1250 <main+0x120>
movsd  (%rsp),%xmm0
movapd %xmm0,%xmm2
divsd  %xmm1,%xmm2
lea    0xe0a(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
jmp    1263 <main+0x133>
lea    0xe09(%rip),%rdi
movsd  (%rsp),%xmm0
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"\0AEnter number 1 :\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"\0AEnter number 2 :\00"
@.str.3 = [14 x i8] c"\0A%g + %g = %g\00"
@.str.4 = [14 x i8] c"\0A%g - %g = %g\00"
@.str.5 = [14 x i8] c"\0A%g * %g = %g\00"
@.str.6 = [15 x i8] c"\0A%g / %g = %g\0A\00"
@.str.7 = [22 x i8] c"\0A%g / %g = undefined\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca [100 x i8]
store i32 0, i32* %1
store double 0.000000e+00, double* %2
store double 0.000000e+00, double* %3
%5 = bitcast [100 x i8]* %4 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %7)
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%10 = call double @atof(i8* %9)
store double %10, double* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%15 = call double @atof(i8* %14)
store double %15, double* %3
%16 = load double, double* %2
%17 = load double, double* %3
%18 = load double, double* %2
%19 = load double, double* %3
%20 = fadd double %18, %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %16, double %17, double %20)
%22 = load double, double* %2
%23 = load double, double* %3
%24 = load double, double* %2
%25 = load double, double* %3
%26 = fsub double %24, %25
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), double %22, double %23, double %26)
%28 = load double, double* %2
%29 = load double, double* %3
%30 = load double, double* %2
%31 = load double, double* %3
%32 = fmul double %30, %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %28, double %29, double %32)
%34 = load double, double* %3
%35 = fcmp une double %34, 0.000000e+00
br i1 %35, label %36, label %43
36: ; preds = %0
%37 = load double, double* %2
%38 = load double, double* %3
%39 = load double, double* %2
%40 = load double, double* %3
%41 = fdiv double %39, %40
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), double %37, double %38, double %41)
br label %47
43: ; preds = %0
%44 = load double, double* %2
%45 = load double, double* %3
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), double %44, double %45)
br label %47
47: ; preds = %43, %36
%48 = phi i32 [ %42, %36 ], [ %46, %43 ]
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"\0AEnter number 1 :\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [18 x i8] c"\0AEnter number 2 :\00"
@.str.3 = [14 x i8] c"\0A%g + %g = %g\00"
@.str.4 = [14 x i8] c"\0A%g - %g = %g\00"
@.str.5 = [14 x i8] c"\0A%g * %g = %g\00"
@.str.6 = [15 x i8] c"\0A%g / %g = %g\0A\00"
@.str.7 = [22 x i8] c"\0A%g / %g = undefined\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call double @atof(i8* %2)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%8 = call double @atof(i8* %2)
%9 = fadd double %5, %8
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), double %5, double %8, double %9)
%11 = fsub double %5, %8
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), double %5, double %8, double %11)
%13 = fmul double %5, %8
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), double %5, double %8, double %13)
%15 = fcmp une double %8, 0.000000e+00
br i1 %15, label %16, label %19
16: ; preds = %0
%17 = fdiv double %5, %8
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), double %5, double %8, double %17)
br label %21
19: ; preds = %0
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0), double %5, double %8)
br label %21
21: ; preds = %19, %16
ret i32 0
}