#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 */
char *malloc(int);
char random_choice_char(char *);
int random_integer(unsigned int, unsigned int);
char *random_word(unsigned int min_length, unsigned int max_length) {
  if (min_length < 1 || max_length < 1 || min_length > max_length)
    return NULL;
  char *word;
  int word_length;
  word_length = random_integer(min_length, max_length);
  word = malloc(sizeof(char) * word_length);
  for (int i = 0; i < word_length; ++i)
    word[i] = random_choice_char("abcdefghijklmnopqrstuvwxyz");
  return word;
}


x86 assembly (clang, -O0):
<random_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
cmpl   $0x1,-0xc(%rbp)
jb     115e <random_word+0x2e>
cmpl   $0x1,-0x10(%rbp)
jb     115e <random_word+0x2e>
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jbe    116b <random_word+0x3b>
movq   $0x0,-0x8(%rbp)
jmp    11ce <random_word+0x9e>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1040 <random_integer@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    11c6 <random_word+0x96>
lea    0xe5a(%rip),%rdi
call   1050 <random_choice_char@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1193 <random_word+0x63>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_word>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    -0x1(%rdi),%eax
cmp    %esi,%eax
jae    1177 <random_word+0x47>
call   1040 <random_integer@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   1030 <malloc@plt>
mov    %rax,%r15
test   %ebp,%ebp
jle    117a <random_word+0x4a>
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xea2(%rip),%r14
xchg   %ax,%ax
mov    %r14,%rdi
call   1050 <random_choice_char@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1160 <random_word+0x30>
jmp    117a <random_word+0x4a>
xor    %r15d,%r15d
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
define i8* @random_word(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%9 = load i32, i32* %4
%10 = icmp ult i32 %9, 1
br i1 %10, label %18, label %11
11: ; preds = %2
%12 = load i32, i32* %5
%13 = icmp ult i32 %12, 1
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = icmp ugt i32 %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14, %11, %2
store i8* null, i8** %3
br label %43
19: ; preds = %14
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = call i32 @random_integer(i32 %20, i32 %21)
store i32 %22, i32* %7
%23 = load i32, i32* %7
%24 = sext i32 %23 to i64
%25 = mul i64 1, %24
%26 = trunc i64 %25 to i32
%27 = call i8* @malloc(i32 %26)
store i8* %27, i8** %6
store i32 0, i32* %8
br label %28
28: ; preds = %38, %19
%29 = load i32, i32* %8
%30 = load i32, i32* %7
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %41
32: ; preds = %28
%33 = call signext i8 @random_choice_char(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%34 = load i8*, i8** %6
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
store i8 %33, i8* %37
br label %38
38: ; preds = %32
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %28
41: ; preds = %28
%42 = load i8*, i8** %6
store i8* %42, i8** %3
br label %43
43: ; preds = %41, %18
%44 = load i8*, i8** %3
ret i8* %44
}

LLVM IR (-O2):
@.str = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
define noalias i8* @random_word(i32 %0, i32 %1) {
%3 = add i32 %0, -1
%4 = icmp ult i32 %3, %1
br i1 %4, label %5, label %17
5: ; preds = %2
%6 = tail call i32 @random_integer(i32 %0, i32 %1)
%7 = tail call i8* @malloc(i32 %6)
%8 = icmp sgt i32 %6, 0
br i1 %8, label %9, label %17
9: ; preds = %5
%10 = zext i32 %6 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %15, %11 ]
%13 = tail call signext i8 @random_choice_char(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%14 = getelementptr inbounds i8, i8* %7, i64 %12
store i8 %13, i8* %14
%15 = add nuw nsw i64 %12, 1
%16 = icmp eq i64 %15, %10
br i1 %16, label %17, label %11
17: ; preds = %11, %5, %2
%18 = phi i8* [ null, %2 ], [ %7, %5 ], [ %7, %11 ]
ret i8* %18
}