#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*/ BFD_LONGUS2TIMEVAL(unsigned long long *, struct timeval *);
int /*<<< orphan*/ BFD_TIMEVAL2LONGUS(struct timeval *, unsigned long long *);
int rand();
void bfd_echo_cal_new_txinterval(unsigned char detectmult,
                                 struct timeval *oldtv, struct timeval *newtv) {
  unsigned long long int txint;
  unsigned int percent;
  if (!oldtv || !newtv)
    return;
  BFD_TIMEVAL2LONGUS(oldtv, &txint);
  percent = rand() % 26;
  txint = txint * (75 + percent) / 100;
  BFD_LONGUS2TIMEVAL(&txint, newtv);
  return;
}


x86 assembly (clang, -O0):
<bfd_echo_cal_new_txinterval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115c <bfd_echo_cal_new_txinterval+0x2c>
cmpq   $0x0,-0x18(%rbp)
jne    1161 <bfd_echo_cal_new_txinterval+0x31>
jmp    11ab <bfd_echo_cal_new_txinterval+0x7b>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <BFD_TIMEVAL2LONGUS@plt>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x1a,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    -0x20(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x4b,%ecx
mov    %ecx,%ecx
imul   %rcx,%rax
mov    $0x64,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdi
call   1050 <BFD_LONGUS2TIMEVAL@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bfd_echo_cal_new_txinterval>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     11a4 <bfd_echo_cal_new_txinterval+0x74>
mov    %rdx,%rbx
test   %rdx,%rdx
je     11a4 <bfd_echo_cal_new_txinterval+0x74>
mov    %rsp,%r14
mov    %rsi,%rdi
mov    %r14,%rsi
call   1030 <BFD_TIMEVAL2LONGUS@plt>
xor    %eax,%eax
call   1040 <rand@plt>
cltq
imul   $0x4ec4ec4f,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x23,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,4),%edx
lea    (%rdx,%rdx,4),%edx
add    %ecx,%edx
neg    %edx
add    %edx,%eax
add    $0x4b,%eax
imul   (%rsp),%rax
shr    $0x2,%rax
movabs $0x28f5c28f5c28f5c3,%rcx
c2 f5 28
mul    %rcx
shr    $0x2,%rdx
mov    %rdx,(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <BFD_LONGUS2TIMEVAL@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
define void @bfd_echo_cal_new_txinterval(i8 zeroext %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca i8
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval*
%7 = alloca i64
%8 = alloca i32
store i8 %0, i8* %4
store %struct.timeval* %1, %struct.timeval** %5
store %struct.timeval* %2, %struct.timeval** %6
%9 = load %struct.timeval*, %struct.timeval** %5
%10 = icmp ne %struct.timeval* %9, null
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = load %struct.timeval*, %struct.timeval** %6
%13 = icmp ne %struct.timeval* %12, null
br i1 %13, label %15, label %14
14: ; preds = %11, %3
br label %28
15: ; preds = %11
%16 = load %struct.timeval*, %struct.timeval** %5
%17 = call i32 @BFD_TIMEVAL2LONGUS(%struct.timeval* %16, i64* %7)
%18 = call i32 (...) @rand()
%19 = srem i32 %18, 26
store i32 %19, i32* %8
%20 = load i64, i64* %7
%21 = load i32, i32* %8
%22 = add i32 75, %21
%23 = zext i32 %22 to i64
%24 = mul i64 %20, %23
%25 = udiv i64 %24, 100
store i64 %25, i64* %7
%26 = load %struct.timeval*, %struct.timeval** %6
%27 = call i32 @BFD_LONGUS2TIMEVAL(i64* %7, %struct.timeval* %26)
br label %28
28: ; preds = %15, %14
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
define void @bfd_echo_cal_new_txinterval(i8 zeroext %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
%6 = icmp ne %struct.timeval* %1, null
%7 = icmp ne %struct.timeval* %2, null
%8 = and i1 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %3
%10 = call i32 @BFD_TIMEVAL2LONGUS(%struct.timeval* %1, i64* %4)
%11 = call i32 (...) @rand()
%12 = srem i32 %11, 26
%13 = load i64, i64* %4
%14 = add nsw i32 %12, 75
%15 = zext i32 %14 to i64
%16 = mul i64 %13, %15
%17 = udiv i64 %16, 100
store i64 %17, i64* %4
%18 = call i32 @BFD_LONGUS2TIMEVAL(i64* %4, %struct.timeval* %2)
br label %19
19: ; preds = %3, %9
ret void
}