#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*/ free(char *);
int get_numval(char *);
char *parse(char *, int);
float rand();
int /*<<< orphan*/ set_numvar(char *, int);
int /*<<< orphan*/ srand(unsigned int);
int /*<<< orphan*/ strcmp(char *, char *);
scalar_t__ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ trim(char *);
void cmd_generate(char *str) {
  int upper, lower, rnd;
  char *exp, *var;
  if (!strcmp(str, "")) {
  } else {
    trim(str);
  }
  var = parse(str, 1);
  exp = parse(str, 2);
  lower = get_numval(exp);
  free(exp);
  exp = parse(str, 3);
  upper = get_numval(exp);
  srand((unsigned)time(NULL));
  rnd = lower + (int)((float)upper * rand() / (32767 + 1.0));
  set_numvar(var, rnd);
  free(exp);
  free(var);
}


x86 assembly (clang, -O0):
<cmd_generate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11ba <cmd_generate+0x2a>
jmp    11c3 <cmd_generate+0x33>
mov    -0x8(%rbp),%rdi
call   1040 <trim@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   10a0 <parse@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   10a0 <parse@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <get_numval@plt>
mov    %eax,-0x10(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
mov    $0x3,%esi
call   10a0 <parse@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1090 <get_numval@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x30(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    $0x0,%al
call   10b0 <rand@plt>
mov    -0x30(%rbp),%eax
movaps %xmm0,%xmm1
movss  -0x2c(%rbp),%xmm0
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xda4(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1070 <set_numvar@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_generate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbp
cmpb   $0x0,(%rdi)
je     1197 <cmd_generate+0x17>
mov    %rbp,%rdi
call   1040 <trim@plt>
mov    %rbp,%rdi
mov    $0x1,%esi
call   1090 <parse@plt>
mov    %rax,%r15
mov    %rbp,%rdi
mov    $0x2,%esi
call   1090 <parse@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1080 <get_numval@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
mov    $0x3,%esi
call   1090 <parse@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1080 <get_numval@plt>
mov    %eax,%ebx
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
cvtsi2ss %ebx,%xmm0
movss  %xmm0,0x4(%rsp)
xor    %eax,%eax
call   10a0 <rand@plt>
mulss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
mulsd  0xdeb(%rip),%xmm0
cvttsd2si %xmm0,%esi
add    %r14d,%esi
mov    %r15,%rdi
call   1060 <set_numvar@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define void @cmd_generate(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @strcmp(i8* %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %1
br label %15
12: ; preds = %1
%13 = load i8*, i8** %2
%14 = call i32 @trim(i8* %13)
br label %15
15: ; preds = %12, %11
%16 = load i8*, i8** %2
%17 = call i8* @parse(i8* %16, i32 1)
store i8* %17, i8** %7
%18 = load i8*, i8** %2
%19 = call i8* @parse(i8* %18, i32 2)
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i32 @get_numval(i8* %20)
store i32 %21, i32* %4
%22 = load i8*, i8** %6
%23 = call i32 @free(i8* %22)
%24 = load i8*, i8** %2
%25 = call i8* @parse(i8* %24, i32 3)
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = call i32 @get_numval(i8* %26)
store i32 %27, i32* %3
%28 = call i64 @time(i32* null)
%29 = trunc i64 %28 to i32
%30 = call i32 @srand(i32 %29)
%31 = load i32, i32* %4
%32 = load i32, i32* %3
%33 = sitofp i32 %32 to float
%34 = call float (...) @rand()
%35 = fmul float %33, %34
%36 = fpext float %35 to double
%37 = fdiv double %36, 3.276800e+04
%38 = fptosi double %37 to i32
%39 = add nsw i32 %31, %38
store i32 %39, i32* %5
%40 = load i8*, i8** %7
%41 = load i32, i32* %5
%42 = call i32 @set_numvar(i8* %40, i32 %41)
%43 = load i8*, i8** %6
%44 = call i32 @free(i8* %43)
%45 = load i8*, i8** %7
%46 = call i32 @free(i8* %45)
ret void
}

LLVM IR (-O2):
define void @cmd_generate(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @trim(i8* %0)
br label %6
6: ; preds = %1, %4
%7 = tail call i8* @parse(i8* %0, i32 1)
%8 = tail call i8* @parse(i8* %0, i32 2)
%9 = tail call i32 @get_numval(i8* %8)
%10 = tail call i32 @free(i8* %8)
%11 = tail call i8* @parse(i8* %0, i32 3)
%12 = tail call i32 @get_numval(i8* %11)
%13 = tail call i64 @time(i32* null)
%14 = trunc i64 %13 to i32
%15 = tail call i32 @srand(i32 %14)
%16 = sitofp i32 %12 to float
%17 = tail call float (...) @rand()
%18 = fmul float %17, %16
%19 = fpext float %18 to double
%20 = fmul double %19, 0x3F00000000000000
%21 = fptosi double %20 to i32
%22 = add nsw i32 %9, %21
%23 = tail call i32 @set_numvar(i8* %7, i32 %22)
%24 = tail call i32 @free(i8* %11)
%25 = tail call i32 @free(i8* %7)
ret void
}