#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 */
scalar_t__ ebc_isspace(char);
unsigned long ebcstrtoul(char *, char **, int);
int /*<<< orphan*/ sclp_param(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int menu_param(unsigned long *value) {
  char loadparm[8];
  char *endptr;
  int i;
  if (!sclp_param(loadparm))
    *value = ebcstrtoul(loadparm, &endptr, 10);
  if (endptr != loadparm)
    return 0;
  i = 0;
  while (ebc_isspace(loadparm[i]) && (i < 8))
    i++;
  if (!strncmp(&loadparm[i], "PROMPT", 6)) {
    *value = 0;
    return 1;
  }
  return 2;
}


x86 assembly (clang, -O0):
<menu_param>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
call   1050 <sclp_param@plt>
cmp    $0x0,%eax
jne    117a <menu_param+0x3a>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1040 <ebcstrtoul@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rax
lea    -0x18(%rbp),%rcx
cmp    %rcx,%rax
je     1197 <menu_param+0x57>
movl   $0x0,-0x4(%rbp)
jmp    1229 <menu_param+0xe9>
movl   $0x0,-0x24(%rbp)
movslq -0x24(%rbp),%rax
movsbl -0x18(%rbp,%rax,1),%edi
call   1060 <ebc_isspace@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x25(%rbp)
je     11c8 <menu_param+0x88>
cmpl   $0x8,-0x24(%rbp)
setl   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11d8 <menu_param+0x98>
jmp    11e6 <menu_param+0xa6>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119e <menu_param+0x5e>
movslq -0x24(%rbp),%rax
lea    -0x18(%rbp),%rdi
add    %rax,%rdi
lea    0xe08(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1222 <menu_param+0xe2>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1229 <menu_param+0xe9>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu_param>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <sclp_param@plt>
test   %eax,%eax
je     11bc <menu_param+0x7c>
lea    0x7(%rsp),%rbx
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nop
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1060 <ebc_isspace@plt>
test   %rax,%rax
je     118f <menu_param+0x4f>
lea    0x1(%r15),%rax
cmp    $0x8,%r15
mov    %rax,%r15
jb     1170 <menu_param+0x30>
lea    0xe6a(%rip),%rsi
mov    %rbx,%rdi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
mov    $0x2,%eax
test   %ecx,%ecx
jne    11d7 <menu_param+0x97>
movq   $0x0,(%r14)
mov    $0x1,%eax
jmp    11d7 <menu_param+0x97>
mov    %rsp,%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1040 <ebcstrtoul@plt>
mov    %rax,(%r14)
xor    %eax,%eax
cmp    %rbx,(%rsp)
je     115d <menu_param+0x1d>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"PROMPT\00"
define i32 @menu_param(i64* nocapture writeonly %0) {
%2 = alloca [8 x i8]
%3 = alloca i8*
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%5 = bitcast i8** %3 to i8*
%6 = call i32 @sclp_param(i8* %4)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = call i64 @ebcstrtoul(i8* %4, i8** %3, i32 10)
store i64 %9, i64* %0
%10 = load i8*, i8** %3
%11 = icmp eq i8* %10, %4
br i1 %11, label %12, label %27
12: ; preds = %1, %8
br label %13
13: ; preds = %12, %13
%14 = phi i64 [ %21, %13 ], [ 0, %12 ]
%15 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = call i64 @ebc_isspace(i8 signext %16)
%18 = icmp ne i64 %17, 0
%19 = icmp ult i64 %14, 8
%20 = select i1 %18, i1 %19, i1 false
%21 = add nuw nsw i64 %14, 1
br i1 %20, label %13, label %22
22: ; preds = %13
%23 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 %14
%24 = call i32 @strncmp(i8* %23, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i64 0, i64* %0
br label %27
27: ; preds = %22, %8, %26
%28 = phi i32 [ 1, %26 ], [ 0, %8 ], [ 2, %22 ]
ret i32 %28
}