#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*/ FE_ALL_EXCEPT;
int /*<<< orphan*/ feenableexcept(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  printf("Dividing by zero (first time)\n");
  volatile float a = 1.0f, b = 0.0f;
  volatile float c = a / b;
  printf("Result: %f\n", c);
  feenableexcept(FE_ALL_EXCEPT);
  printf("Dividing by zero (second time)\n");
  c = a / b;
  printf("Result: %f (we shouldn't get here)\n", c);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  0xec2(%rip),%xmm0
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xeb5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
call   1040 <feenableexcept@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe9b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
movl   $0x3f800000,0x14(%rsp)
3f
movl   $0x0,0x10(%rsp)
movss  0x14(%rsp),%xmm0
divss  0x10(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    0x2e5f(%rip),%rax
mov    (%rax),%edi
call   1050 <feenableexcept@plt>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
movss  0x14(%rsp),%xmm0
divss  0x10(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe55(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Dividing by zero (first time)\0A\00"
@.str.1 = [12 x i8] c"Result: %f\0A\00"
@FE_ALL_EXCEPT = global i32 0
@.str.2 = [32 x i8] c"Dividing by zero (second time)\0A\00"
@.str.3 = [36 x i8] c"Result: %f (we shouldn't get here)\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store volatile float 1.000000e+00, float* %1
store volatile float 0.000000e+00, float* %2
%5 = load volatile float, float* %1
%6 = load volatile float, float* %2
%7 = fdiv float %5, %6
store volatile float %7, float* %3
%8 = load volatile float, float* %3
%9 = fpext float %8 to double
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %9)
%11 = load i32, i32* @FE_ALL_EXCEPT
%12 = call i32 @feenableexcept(i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%14 = load volatile float, float* %1
%15 = load volatile float, float* %2
%16 = fdiv float %14, %15
store volatile float %16, float* %3
%17 = load volatile float, float* %3
%18 = fpext float %17 to double
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), double %18)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [12 x i8] c"Result: %f\0A\00"
@FE_ALL_EXCEPT = global i32 0
@.str.3 = [36 x i8] c"Result: %f (we shouldn't get here)\0A\00"
@str = [30 x i8] c"Dividing by zero (first time)\00"
@str.4 = [31 x i8] c"Dividing by zero (second time)\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
%5 = bitcast float* %1 to i8*
store volatile float 1.000000e+00, float* %1
%6 = bitcast float* %2 to i8*
store volatile float 0.000000e+00, float* %2
%7 = bitcast float* %3 to i8*
%8 = load volatile float, float* %1
%9 = load volatile float, float* %2
%10 = fdiv float %8, %9
store volatile float %10, float* %3
%11 = load volatile float, float* %3
%12 = fpext float %11 to double
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), double %12)
%14 = load i32, i32* @FE_ALL_EXCEPT
%15 = tail call i32 @feenableexcept(i32 %14)
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.4, i64 0, i64 0))
%17 = load volatile float, float* %1
%18 = load volatile float, float* %2
%19 = fdiv float %17, %18
store volatile float %19, float* %3
%20 = load volatile float, float* %3
%21 = fpext float %20 to double
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), double %21)
ret i32 0
}