#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 map2check_non_det_char();
unsigned int map2check_non_det_unsigned();
char *map2check_non_det_pchar() {
  unsigned length = map2check_non_det_unsigned();
  if (length == 0)
    return NULL;
  char string[length];
  unsigned i = 0;
  for (i = 0; i < (length - 1); i++) {
    string[i] = map2check_non_det_char();
  }
  string[i] = '\0';
  return string;
}


x86 assembly (clang, -O0):
<map2check_non_det_pchar>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    $0x0,%al
call   1040 <map2check_non_det_unsigned@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1149 <map2check_non_det_pchar+0x29>
movq   $0x0,-0x8(%rbp)
jmp    11c5 <map2check_non_det_pchar+0xa5>
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jae    11af <map2check_non_det_pchar+0x8f>
mov    $0x0,%al
call   1030 <map2check_non_det_char@plt>
mov    %al,%dl
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117d <map2check_non_det_pchar+0x5d>
mov    -0x30(%rbp),%rax
mov    -0x24(%rbp),%ecx
movb   $0x0,(%rax,%rcx,1)
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x8(%rbp),%rax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<map2check_non_det_pchar>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <map2check_non_det_unsigned@plt>
test   %eax,%eax
je     1181 <map2check_non_det_pchar+0x61>
mov    %rsp,%r14
mov    %eax,%ecx
mov    %rsp,%r15
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r15
mov    %r15,%rsp
add    $0xffffffff,%eax
je     1176 <map2check_non_det_pchar+0x56>
mov    %eax,%r12d
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <map2check_non_det_char@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r12
jne    1160 <map2check_non_det_pchar+0x40>
jmp    1179 <map2check_non_det_pchar+0x59>
xor    %r12d,%r12d
movb   $0x0,(%r15,%r12,1)
mov    %r14,%rsp
mov    %r15,%rax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @map2check_non_det_pchar() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = call i32 (...) @map2check_non_det_unsigned()
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
store i8* null, i8** %1
br label %33
10: ; preds = %0
%11 = load i32, i32* %2
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %3
%14 = alloca i8, i64 %12
store i64 %12, i64* %4
store i32 0, i32* %5
store i32 0, i32* %5
br label %15
15: ; preds = %25, %10
%16 = load i32, i32* %5
%17 = load i32, i32* %2
%18 = sub i32 %17, 1
%19 = icmp ult i32 %16, %18
br i1 %19, label %20, label %28
20: ; preds = %15
%21 = call signext i8 (...) @map2check_non_det_char()
%22 = load i32, i32* %5
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %14, i64 %23
store i8 %21, i8* %24
br label %25
25: ; preds = %20
%26 = load i32, i32* %5
%27 = add i32 %26, 1
store i32 %27, i32* %5
br label %15
28: ; preds = %15
%29 = load i32, i32* %5
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %14, i64 %30
store i8 0, i8* %31
store i8* %14, i8** %1
%32 = load i8*, i8** %3
br label %33
33: ; preds = %28, %9
%34 = load i8*, i8** %1
ret i8* %34
}

LLVM IR (-O2):
define noalias i8* @map2check_non_det_pchar() {
%1 = tail call i32 (...) @map2check_non_det_unsigned()
%2 = icmp eq i32 %1, 0
br i1 %2, label %22, label %3
3: ; preds = %0
%4 = zext i32 %1 to i64
%5 = tail call i8* @llvm.stacksave()
%6 = alloca i8, i64 %4
%7 = add i32 %1, -1
%8 = icmp eq i32 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %3
%10 = zext i32 %7 to i64
br label %11
11: ; preds = %9, %11
%12 = phi i64 [ 0, %9 ], [ %15, %11 ]
%13 = tail call signext i8 (...) @map2check_non_det_char()
%14 = getelementptr inbounds i8, i8* %6, 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
%18 = zext i32 %7 to i64
br label %19
19: ; preds = %3, %17
%20 = phi i64 [ %18, %17 ], [ 0, %3 ]
%21 = getelementptr inbounds i8, i8* %6, i64 %20
store i8 0, i8* %21
tail call void @llvm.stackrestore(i8* %5)
br label %22
22: ; preds = %0, %19
%23 = phi i8* [ %6, %19 ], [ null, %0 ]
ret i8* %23
}