#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 random_number(int, int);
char *inputString() {
  int i;
  int strLength = random_number(1, 6);
  static char ch[10];
  int a;
  for (i = 0; i < strLength; i++) {
    a = random_number(97, 122);
    ch[i] = (char)a;
  }
  ch[i + 1] = '\0';
  return ch;
}


x86 assembly (clang, -O0):
<inputString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x1,%edi
mov    $0x6,%esi
call   1030 <random_number@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1170 <inputString+0x60>
mov    $0x61,%edi
mov    $0x7a,%esi
call   1030 <random_number@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %al,%dl
movslq -0x4(%rbp),%rcx
lea    0x2eca(%rip),%rax
mov    %dl,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1131 <inputString+0x21>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2ea9(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e9e(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inputString>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    $0x1,%edi
mov    $0x6,%esi
call   1030 <random_number@plt>
test   %eax,%eax
jle    1162 <inputString+0x52>
mov    %eax,%r14d
mov    %eax,%r15d
xor    %ebx,%ebx
lea    0x2eef(%rip),%r12
nopw   0x0(%rax,%rax,1)
mov    $0x61,%edi
mov    $0x7a,%esi
call   1030 <random_number@plt>
mov    %al,(%rbx,%r12,1)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1140 <inputString+0x30>
add    $0x1,%r14d
jmp    1168 <inputString+0x58>
mov    $0x1,%r14d
lea    0x2eba(%rip),%rax
movb   $0x0,(%r14,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@inputString.ch = internal global [10 x i8] zeroinitializer
define i8* @inputString() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @random_number(i32 1, i32 6)
store i32 %4, i32* %2
store i32 0, i32* %1
br label %5
5: ; preds = %16, %0
%6 = load i32, i32* %1
%7 = load i32, i32* %2
%8 = icmp slt i32 %6, %7
br i1 %8, label %9, label %19
9: ; preds = %5
%10 = call i32 @random_number(i32 97, i32 122)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = trunc i32 %11 to i8
%13 = load i32, i32* %1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [10 x i8], [10 x i8]* @inputString.ch, i64 0, i64 %14
store i8 %12, i8* %15
br label %16
16: ; preds = %9
%17 = load i32, i32* %1
%18 = add nsw i32 %17, 1
store i32 %18, i32* %1
br label %5
19: ; preds = %5
%20 = load i32, i32* %1
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [10 x i8], [10 x i8]* @inputString.ch, i64 0, i64 %22
store i8 0, i8* %23
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @inputString.ch, i64 0, i64 0)
}

LLVM IR (-O2):
@inputString.ch = internal global [10 x i8] zeroinitializer
define i8* @inputString() {
%1 = tail call i32 @random_number(i32 1, i32 6)
%2 = icmp sgt i32 %1, 0
br i1 %2, label %3, label %15
3: ; preds = %0
%4 = zext i32 %1 to i64
br label %5
5: ; preds = %3, %5
%6 = phi i64 [ 0, %3 ], [ %10, %5 ]
%7 = tail call i32 @random_number(i32 97, i32 122)
%8 = trunc i32 %7 to i8
%9 = getelementptr inbounds [10 x i8], [10 x i8]* @inputString.ch, i64 0, i64 %6
store i8 %8, i8* %9
%10 = add nuw nsw i64 %6, 1
%11 = icmp eq i64 %10, %4
br i1 %11, label %12, label %5
12: ; preds = %5
%13 = add i32 %1, 1
%14 = zext i32 %13 to i64
br label %15
15: ; preds = %12, %0
%16 = phi i64 [ 1, %0 ], [ %14, %12 ]
%17 = getelementptr inbounds [10 x i8], [10 x i8]* @inputString.ch, i64 0, i64 %16
store i8 0, i8* %17
ret i8* getelementptr inbounds ([10 x i8], [10 x i8]* @inputString.ch, i64 0, i64 0)
}