#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 RAND_MAX;
int rand();
int getIntRandomNumberAround(int x, double perc) {
  double r;
  int new_int;
  r = -perc + (2 * perc * rand() / (RAND_MAX + 1.0));
  new_int = ((1) > ((int)((double)x * (1.0 + r / 100.00)))
                 ? (1)
                 : ((int)((double)x * (1.0 + r / 100.00))));
  return new_int;
}


x86 assembly (clang, -O0):
<getIntRandomNumberAround>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xec7(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    $0x0,%al
call   1030 <rand@plt>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm1
movsd  0xe8c(%rip),%xmm2
mov    0x2e6d(%rip),%rax
addsd  (%rax),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xe6a(%rip),%xmm1
divsd  %xmm1,%xmm2
movsd  0xe56(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    $0x1,%eax
cmp    %ecx,%eax
jle    11d0 <getIntRandomNumberAround+0xc0>
mov    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11fd <getIntRandomNumberAround+0xed>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm2
movsd  0xe26(%rip),%xmm1
divsd  %xmm1,%xmm2
movsd  0xe12(%rip),%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIntRandomNumberAround>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
mov    %edi,%ebx
addsd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
mov    0x2ea8(%rip),%rax
movsd  0xeb8(%rip),%xmm1
movsd  (%rax),%xmm2
addsd  %xmm1,%xmm2
divsd  %xmm2,%xmm0
subsd  0x8(%rsp),%xmm0
xorps  %xmm2,%xmm2
cvtsi2sd %ebx,%xmm2
divsd  0xe9f(%rip),%xmm0
addsd  %xmm1,%xmm0
mulsd  %xmm2,%xmm0
cvttsd2si %xmm0,%ecx
test   %ecx,%ecx
mov    $0x1,%eax
cmovg  %ecx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define i32 @getIntRandomNumberAround(i32 %0, double %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store i32 %0, i32* %3
store double %1, double* %4
%7 = load double, double* %4
%8 = fneg double %7
%9 = load double, double* %4
%10 = fmul double 2.000000e+00, %9
%11 = call i32 (...) @rand()
%12 = sitofp i32 %11 to double
%13 = fmul double %10, %12
%14 = load double, double* @RAND_MAX
%15 = fadd double %14, 1.000000e+00
%16 = fdiv double %13, %15
%17 = fadd double %8, %16
store double %17, double* %5
%18 = load i32, i32* %3
%19 = sitofp i32 %18 to double
%20 = load double, double* %5
%21 = fdiv double %20, 1.000000e+02
%22 = fadd double 1.000000e+00, %21
%23 = fmul double %19, %22
%24 = fptosi double %23 to i32
%25 = icmp sgt i32 1, %24
br i1 %25, label %26, label %27
26: ; preds = %2
br label %35
27: ; preds = %2
%28 = load i32, i32* %3
%29 = sitofp i32 %28 to double
%30 = load double, double* %5
%31 = fdiv double %30, 1.000000e+02
%32 = fadd double 1.000000e+00, %31
%33 = fmul double %29, %32
%34 = fptosi double %33 to i32
br label %35
35: ; preds = %27, %26
%36 = phi i32 [ 1, %26 ], [ %34, %27 ]
store i32 %36, i32* %6
%37 = load i32, i32* %6
ret i32 %37
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define i32 @getIntRandomNumberAround(i32 %0, double %1) {
%3 = fmul double %1, 2.000000e+00
%4 = tail call i32 (...) @rand()
%5 = sitofp i32 %4 to double
%6 = fmul double %3, %5
%7 = load double, double* @RAND_MAX
%8 = fadd double %7, 1.000000e+00
%9 = fdiv double %6, %8
%10 = fsub double %9, %1
%11 = sitofp i32 %0 to double
%12 = fdiv double %10, 1.000000e+02
%13 = fadd double %12, 1.000000e+00
%14 = fmul double %13, %11
%15 = fptosi double %14 to i32
%16 = icmp sgt i32 %15, 1
%17 = select i1 %16, i32 %15, i32 1
ret i32 %17
}