#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 bfdtx_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);
  if (detectmult == 1)
    percent = rand() % 16;
  else
    percent = rand() % 26;
  txint = txint * (75 + percent) / 100;
  BFD_LONGUS2TIMEVAL(&txint, newtv);
  return;
}


x86 assembly (clang, -O0):
<bfdtx_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 <bfdtx_cal_new_txinterval+0x2c>
cmpq   $0x0,-0x18(%rbp)
jne    1161 <bfdtx_cal_new_txinterval+0x31>
jmp    11cf <bfdtx_cal_new_txinterval+0x9f>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <BFD_TIMEVAL2LONGUS@plt>
movzbl -0x1(%rbp),%eax
cmp    $0x1,%eax
jne    1192 <bfdtx_cal_new_txinterval+0x62>
mov    $0x0,%al
call   1040 <rand@plt>
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
jmp    11a4 <bfdtx_cal_new_txinterval+0x74>
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):
<bfdtx_cal_new_txinterval>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
test   %rsi,%rsi
je     11a0 <bfdtx_cal_new_txinterval+0x70>
mov    %rdx,%rbx
test   %rdx,%rdx
je     11a0 <bfdtx_cal_new_txinterval+0x70>
mov    %edi,%ebp
lea    0x8(%rsp),%r14
mov    %rsi,%rdi
mov    %r14,%rsi
call   1030 <BFD_TIMEVAL2LONGUS@plt>
xor    %eax,%eax
call   1040 <rand@plt>
cmp    $0x1,%bpl
mov    $0x10,%ecx
mov    $0x1a,%esi
cmove  %ecx,%esi
cltd
idiv   %esi
lea    0x4b(%rdx),%eax
imul   0x8(%rsp),%rax
shr    $0x2,%rax
movabs $0x28f5c28f5c28f5c3,%rcx
c2 f5 28
mul    %rcx
shr    $0x2,%rdx
mov    %rdx,0x8(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <BFD_LONGUS2TIMEVAL@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
define void @bfdtx_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 %36
15: ; preds = %11
%16 = load %struct.timeval*, %struct.timeval** %5
%17 = call i32 @BFD_TIMEVAL2LONGUS(%struct.timeval* %16, i64* %7)
%18 = load i8, i8* %4
%19 = zext i8 %18 to i32
%20 = icmp eq i32 %19, 1
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = call i32 (...) @rand()
%23 = srem i32 %22, 16
store i32 %23, i32* %8
br label %27
24: ; preds = %15
%25 = call i32 (...) @rand()
%26 = srem i32 %25, 26
store i32 %26, i32* %8
br label %27
27: ; preds = %24, %21
%28 = load i64, i64* %7
%29 = load i32, i32* %8
%30 = add i32 75, %29
%31 = zext i32 %30 to i64
%32 = mul i64 %28, %31
%33 = udiv i64 %32, 100
store i64 %33, i64* %7
%34 = load %struct.timeval*, %struct.timeval** %6
%35 = call i32 @BFD_LONGUS2TIMEVAL(i64* %7, %struct.timeval* %34)
br label %36
36: ; preds = %27, %14
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
define void @bfdtx_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 %21
9: ; preds = %3
%10 = call i32 @BFD_TIMEVAL2LONGUS(%struct.timeval* %1, i64* %4)
%11 = icmp eq i8 %0, 1
%12 = call i32 (...) @rand()
%13 = select i1 %11, i32 16, i32 26
%14 = srem i32 %12, %13
%15 = load i64, i64* %4
%16 = add nsw i32 %14, 75
%17 = zext i32 %16 to i64
%18 = mul i64 %15, %17
%19 = udiv i64 %18, 100
store i64 %19, i64* %4
%20 = call i32 @BFD_LONGUS2TIMEVAL(i64* %4, %struct.timeval* %2)
br label %21
21: ; preds = %3, %9
ret void
}