#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 */
unsigned long ebcdic_strtoul(char *, char **, int);
scalar_t__ ecbdic_isspace(char);
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 = ebcdic_strtoul(loadparm, &endptr, 10);
  if (endptr != loadparm)
    return 0;
  i = 0;
  while ((i < 8) && ecbdic_isspace(loadparm[i]))
    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   1060 <sclp_param@plt>
cmp    $0x0,%eax
jne    117a <menu_param+0x3a>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xa,%edx
call   1050 <ebcdic_strtoul@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    1226 <menu_param+0xe6>
movl   $0x0,-0x24(%rbp)
xor    %eax,%eax
cmpl   $0x8,-0x24(%rbp)
mov    %al,-0x25(%rbp)
jge    11c5 <menu_param+0x85>
movslq -0x24(%rbp),%rax
movsbl -0x18(%rbp,%rax,1),%edi
call   1040 <ecbdic_isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11d5 <menu_param+0x95>
jmp    11e3 <menu_param+0xa3>
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    0xe0b(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    121f <menu_param+0xdf>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1226 <menu_param+0xe6>
movl   $0x2,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu_param>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <sclp_param@plt>
test   %eax,%eax
je     11ed <menu_param+0xad>
movsbl 0x8(%rsp),%edi
call   1040 <ecbdic_isspace@plt>
test   %rax,%rax
je     1210 <menu_param+0xd0>
movsbl 0x9(%rsp),%edi
call   1040 <ecbdic_isspace@plt>
test   %rax,%rax
je     1214 <menu_param+0xd4>
movsbl 0xa(%rsp),%edi
call   1040 <ecbdic_isspace@plt>
test   %rax,%rax
je     121b <menu_param+0xdb>
movsbl 0xb(%rsp),%edi
call   1040 <ecbdic_isspace@plt>
test   %rax,%rax
je     1222 <menu_param+0xe2>
movsbl 0xc(%rsp),%edi
call   1040 <ecbdic_isspace@plt>
test   %rax,%rax
je     1229 <menu_param+0xe9>
movsbl 0xd(%rsp),%edi
call   1040 <ecbdic_isspace@plt>
test   %rax,%rax
je     1230 <menu_param+0xf0>
movsbl 0xe(%rsp),%edi
call   1040 <ecbdic_isspace@plt>
test   %rax,%rax
je     1237 <menu_param+0xf7>
movsbl 0xf(%rsp),%edi
call   1040 <ecbdic_isspace@plt>
cmp    $0x1,%rax
mov    $0x8,%eax
sbb    $0x0,%rax
jmp    123c <menu_param+0xfc>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xa,%edx
call   1050 <ebcdic_strtoul@plt>
mov    %rax,(%r14)
xor    %eax,%eax
cmp    %rbx,0x10(%rsp)
jne    126c <menu_param+0x12c>
jmp    115f <menu_param+0x1f>
xor    %eax,%eax
jmp    123c <menu_param+0xfc>
mov    $0x1,%eax
jmp    123c <menu_param+0xfc>
mov    $0x2,%eax
jmp    123c <menu_param+0xfc>
mov    $0x3,%eax
jmp    123c <menu_param+0xfc>
mov    $0x4,%eax
jmp    123c <menu_param+0xfc>
mov    $0x5,%eax
jmp    123c <menu_param+0xfc>
mov    $0x6,%eax
lea    (%rsp,%rax,1),%rdi
add    $0x8,%rdi
lea    0xdb5(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
mov    $0x2,%eax
test   %ecx,%ecx
jne    126c <menu_param+0x12c>
movq   $0x0,(%r14)
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
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 @ebcdic_strtoul(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 = icmp slt i32 %21, 8
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [8 x i8], [8 x i8]* %4, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = call i64 @ecbdic_isspace(i8 signext %27)
%29 = icmp ne i64 %28, 0
br label %30
30: ; preds = %23, %20
%31 = phi i1 [ false, %20 ], [ %29, %23 ]
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 @ebcdic_strtoul(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 %58
12: ; preds = %1, %8
%13 = load i8, i8* %4
%14 = call i64 @ecbdic_isspace(i8 signext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %52, label %16
16: ; preds = %12
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 1
%18 = load i8, i8* %17
%19 = call i64 @ecbdic_isspace(i8 signext %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %52, label %21
21: ; preds = %16
%22 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 2
%23 = load i8, i8* %22
%24 = call i64 @ecbdic_isspace(i8 signext %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %52, label %26
26: ; preds = %21
%27 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 3
%28 = load i8, i8* %27
%29 = call i64 @ecbdic_isspace(i8 signext %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %52, label %31
31: ; preds = %26
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 4
%33 = load i8, i8* %32
%34 = call i64 @ecbdic_isspace(i8 signext %33)
%35 = icmp eq i64 %34, 0
br i1 %35, label %52, label %36
36: ; preds = %31
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 5
%38 = load i8, i8* %37
%39 = call i64 @ecbdic_isspace(i8 signext %38)
%40 = icmp eq i64 %39, 0
br i1 %40, label %52, label %41
41: ; preds = %36
%42 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 6
%43 = load i8, i8* %42
%44 = call i64 @ecbdic_isspace(i8 signext %43)
%45 = icmp eq i64 %44, 0
br i1 %45, label %52, label %46
46: ; preds = %41
%47 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 7
%48 = load i8, i8* %47
%49 = call i64 @ecbdic_isspace(i8 signext %48)
%50 = icmp eq i64 %49, 0
%51 = select i1 %50, i64 7, i64 8
br label %52
52: ; preds = %46, %41, %36, %31, %26, %21, %16, %12
%53 = phi i64 [ 0, %12 ], [ 1, %16 ], [ 2, %21 ], [ 3, %26 ], [ 4, %31 ], [ 5, %36 ], [ 6, %41 ], [ %51, %46 ]
%54 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 %53
%55 = call i32 @strncmp(i8* %54, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 6)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %52
store i64 0, i64* %0
br label %58
58: ; preds = %52, %8, %57
%59 = phi i32 [ 1, %57 ], [ 0, %8 ], [ 2, %52 ]
ret i32 %59
}