#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 __VERIFIER_nondet_int();
scalar_t__ alloca(int);
int main() {
  int length1 = __VERIFIER_nondet_int();
  if (length1 < 1) {
    length1 = 1;
  }
  char *x = (char *)alloca(length1 * sizeof(char));
  char *y;
  if (x <= y && y < x + length1 * sizeof(char)) {
    *y = 0;
    while (*x != 0) {
      *x = 0;
      x++;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <__VERIFIER_nondet_int@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jge    114a <main+0x2a>
movl   $0x1,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1030 <alloca@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     11bb <main+0x9b>
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x8(%rbp),%rdx
shl    $0x0,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jae    11bb <main+0x9b>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11b6 <main+0x96>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    118e <main+0x6e>
jmp    11bb <main+0x9b>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1040 <__VERIFIER_nondet_int@plt>
test   %eax,%eax
mov    $0x1,%edi
cmovg  %eax,%edi
call   1030 <alloca@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i32 (...) @__VERIFIER_nondet_int()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 1, i32* %2
br label %9
9: ; preds = %8, %0
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 1
%13 = trunc i64 %12 to i32
%14 = call i64 @alloca(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %3
%16 = load i8*, i8** %3
%17 = load i8*, i8** %4
%18 = icmp ule i8* %16, %17
br i1 %18, label %19, label %39
19: ; preds = %9
%20 = load i8*, i8** %4
%21 = load i8*, i8** %3
%22 = load i32, i32* %2
%23 = sext i32 %22 to i64
%24 = mul i64 %23, 1
%25 = getelementptr inbounds i8, i8* %21, i64 %24
%26 = icmp ult i8* %20, %25
br i1 %26, label %27, label %39
27: ; preds = %19
%28 = load i8*, i8** %4
store i8 0, i8* %28
br label %29
29: ; preds = %34, %27
%30 = load i8*, i8** %3
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %29
%35 = load i8*, i8** %3
store i8 0, i8* %35
%36 = load i8*, i8** %3
%37 = getelementptr inbounds i8, i8* %36, i32 1
store i8* %37, i8** %3
br label %29
38: ; preds = %29
br label %39
39: ; preds = %38, %19, %9
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32 (...) @__VERIFIER_nondet_int()
%2 = icmp sgt i32 %1, 1
%3 = select i1 %2, i32 %1, i32 1
%4 = tail call i64 @alloca(i32 %3)
ret i32 0
}