#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 */
typedef int /*<<< orphan*/ uint32_t;

/* Variables and functions */
scalar_t__ global_exists(char *);
int /*<<< orphan*/ global_value(char *);
scalar_t__ isdigit(char);
int /*<<< orphan*/ parse_integer(char *);
int /*<<< orphan*/ printf(char *);
uint32_t parse_parameter(char *buffer) {
  for (; *buffer != ' '; buffer++) {
    if (*buffer == '\n' || !(*buffer)) {
      printf("[ASSUMED] ");
      return 0;
    }
  }
  buffer++;
  if (*buffer == '$' || isdigit(*buffer)) {
    return parse_integer(buffer);
  }
  if (global_exists(buffer)) {
    return global_value(buffer);
  }
  printf("[INVALID] ");
  return 0;
}


x86 assembly (clang, -O0):
<parse_parameter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
je     11b7 <parse_parameter+0x67>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     1189 <parse_parameter+0x39>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11a1 <parse_parameter+0x51>
lea    0xe70(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1231 <parse_parameter+0xe1>
jmp    11a6 <parse_parameter+0x56>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    115c <parse_parameter+0xc>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x24,%eax
je     11e9 <parse_parameter+0x99>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11fa <parse_parameter+0xaa>
mov    -0x10(%rbp),%rdi
call   1070 <parse_integer@plt>
mov    %eax,-0x4(%rbp)
jmp    1231 <parse_parameter+0xe1>
mov    -0x10(%rbp),%rdi
call   1060 <global_exists@plt>
cmp    $0x0,%rax
je     121e <parse_parameter+0xce>
mov    -0x10(%rbp),%rdi
call   1050 <global_value@plt>
mov    %eax,-0x4(%rbp)
jmp    1231 <parse_parameter+0xe1>
lea    0xde6(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_parameter>:
push   %rbx
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
movzbl -0x1(%rbx),%eax
test   %al,%al
je     1174 <parse_parameter+0x24>
cmp    $0x20,%al
je     1184 <parse_parameter+0x34>
cmp    $0xa,%al
jne    1160 <parse_parameter+0x10>
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret
mov    (%rbx),%al
cmp    $0x24,%al
je     1197 <parse_parameter+0x47>
movsbl %al,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     11a0 <parse_parameter+0x50>
mov    %rbx,%rdi
pop    %rbx
jmp    1070 <parse_integer@plt>
mov    %rbx,%rdi
call   1060 <global_exists@plt>
test   %rax,%rax
je     11b6 <parse_parameter+0x66>
mov    %rbx,%rdi
pop    %rbx
jmp    1050 <global_value@plt>
lea    0xe4e(%rip),%rdi
jmp    117b <parse_parameter+0x2b>

LLVM IR (-O0):
@.str = [11 x i8] c"[ASSUMED] \00"
@.str.1 = [11 x i8] c"[INVALID] \00"
define i32 @parse_parameter(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
br label %4
4: ; preds = %21, %1
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 32
br i1 %8, label %9, label %24
9: ; preds = %4
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 10
br i1 %13, label %18, label %14
14: ; preds = %9
%15 = load i8*, i8** %3
%16 = load i8, i8* %15
%17 = icmp ne i8 %16, 0
br i1 %17, label %20, label %18
18: ; preds = %14, %9
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %2
br label %48
20: ; preds = %14
br label %21
21: ; preds = %20
%22 = load i8*, i8** %3
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %3
br label %4
24: ; preds = %4
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
%27 = load i8*, i8** %3
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 36
br i1 %30, label %36, label %31
31: ; preds = %24
%32 = load i8*, i8** %3
%33 = load i8, i8* %32
%34 = call i64 @isdigit(i8 signext %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %31, %24
%37 = load i8*, i8** %3
%38 = call i32 @parse_integer(i8* %37)
store i32 %38, i32* %2
br label %48
39: ; preds = %31
%40 = load i8*, i8** %3
%41 = call i64 @global_exists(i8* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %39
%44 = load i8*, i8** %3
%45 = call i32 @global_value(i8* %44)
store i32 %45, i32* %2
br label %48
46: ; preds = %39
%47 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %2
br label %48
48: ; preds = %46, %43, %36, %18
%49 = load i32, i32* %2
ret i32 %49
}

LLVM IR (-O2):
@.str = [11 x i8] c"[ASSUMED] \00"
@.str.1 = [11 x i8] c"[INVALID] \00"
define i32 @parse_parameter(i8* %0) {
br label %2
2: ; preds = %7, %1
%3 = phi i8* [ %0, %1 ], [ %8, %7 ]
%4 = load i8, i8* %3
switch i8 %4, label %7 [
i8 32, label %9
i8 10, label %5
i8 0, label %5
]
5: ; preds = %2, %2
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %25
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
9: ; preds = %2
%10 = getelementptr inbounds i8, i8* %3, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 36
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = tail call i64 @isdigit(i8 signext %11)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %13, %9
%17 = tail call i32 @parse_integer(i8* %10)
br label %25
18: ; preds = %13
%19 = tail call i64 @global_exists(i8* %10)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = tail call i32 @global_value(i8* %10)
br label %25
23: ; preds = %18
%24 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %21, %16, %5
%26 = phi i32 [ 0, %5 ], [ %17, %16 ], [ %22, %21 ], [ 0, %23 ]
ret i32 %26
}