#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 */
struct timeval {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ double_to_timeval(double, struct timeval *);
int /*<<< orphan*/ printf(char *);
double timeval_to_double(struct timeval *);
void timeval_div(struct timeval *tv, double d) {
  double result_d;
  if (d == 0) {
    printf("Divide by zero error.\n");
    return;
  }
  if (d == 1.0) {
    return;
  }
  result_d = timeval_to_double(tv) / d;
  double_to_timeval(result_d, tv);
}


x86 assembly (clang, -O0):
<timeval_div>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    116a <timeval_div+0x3a>
jp     116a <timeval_div+0x3a>
lea    0xea8(%rip),%rdi
call   1030 <printf@plt>
jmp    11ad <timeval_div+0x7d>
movsd  -0x10(%rbp),%xmm0
movsd  0xe89(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    118c <timeval_div+0x5c>
jp     118c <timeval_div+0x5c>
jmp    11ad <timeval_div+0x7d>
mov    -0x8(%rbp),%rdi
call   1040 <timeval_to_double@plt>
divsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
mov    -0x8(%rbp),%rdi
call   1050 <double_to_timeval@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timeval_div>:
push   %rbx
sub    $0x10,%rsp
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1152 <timeval_div+0x22>
jp     1152 <timeval_div+0x22>
lea    0xec0(%rip),%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1030 <puts@plt>
ucomisd 0xea6(%rip),%xmm0
jne    1164 <timeval_div+0x34>
jp     1164 <timeval_div+0x34>
add    $0x10,%rsp
pop    %rbx
ret
mov    %rdi,%rbx
movsd  %xmm0,0x8(%rsp)
call   1040 <timeval_to_double@plt>
divsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
add    $0x10,%rsp
pop    %rbx
jmp    1050 <double_to_timeval@plt>

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [23 x i8] c"Divide by zero error.\0A\00"
define void @timeval_div(%struct.timeval* %0, double %1) {
%3 = alloca %struct.timeval*
%4 = alloca double
%5 = alloca double
store %struct.timeval* %0, %struct.timeval** %3
store double %1, double* %4
%6 = load double, double* %4
%7 = fcmp oeq double %6, 0.000000e+00
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %22
10: ; preds = %2
%11 = load double, double* %4
%12 = fcmp oeq double %11, 1.000000e+00
br i1 %12, label %13, label %14
13: ; preds = %10
br label %22
14: ; preds = %10
%15 = load %struct.timeval*, %struct.timeval** %3
%16 = call double @timeval_to_double(%struct.timeval* %15)
%17 = load double, double* %4
%18 = fdiv double %16, %17
store double %18, double* %5
%19 = load double, double* %5
%20 = load %struct.timeval*, %struct.timeval** %3
%21 = call i32 @double_to_timeval(double %19, %struct.timeval* %20)
br label %22
22: ; preds = %14, %13, %8
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@str = [22 x i8] c"Divide by zero error.\00"
define void @timeval_div(%struct.timeval* %0, double %1) {
%3 = fcmp oeq double %1, 0.000000e+00
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %12
6: ; preds = %2
%7 = fcmp oeq double %1, 1.000000e+00
br i1 %7, label %12, label %8
8: ; preds = %6
%9 = tail call double @timeval_to_double(%struct.timeval* %0)
%10 = fdiv double %9, %1
%11 = tail call i32 @double_to_timeval(double %10, %struct.timeval* %0)
br label %12
12: ; preds = %6, %8, %4
ret void
}