#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 */
struct shell_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ shellCmd_d(unsigned int);
int /*<<< orphan*/ shellCmd_q();
int /*<<< orphan*/ shellGetEol(struct shell_data *);
int /*<<< orphan*/ shellGetUnsignedInteger(struct shell_data *, unsigned int *);
int /*<<< orphan*/ shellGetWhitespace(struct shell_data *);
int shellGetc(struct shell_data *);
int shellParse(struct shell_data *sd) {
  unsigned int uint1;
  switch (shellGetc(sd)) {
  case 'd': {
    if (shellGetWhitespace(sd))
      return -1;
    if (shellGetUnsignedInteger(sd, &uint1))
      return -1;
    if (shellGetEol(sd))
      return -1;
    shellCmd_d(uint1);
    break;
  }
  case 'q': {
    if (shellGetEol(sd))
      return -1;
    shellCmd_q();
    break;
  }
  default:
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<shellParse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <shellGetc@plt>
mov    %eax,%ecx
mov    %ecx,-0x18(%rbp)
sub    $0x64,%eax
je     1199 <shellParse+0x39>
jmp    1188 <shellParse+0x28>
mov    -0x18(%rbp),%eax
sub    $0x71,%eax
je     1204 <shellParse+0xa4>
jmp    122e <shellParse+0xce>
mov    -0x10(%rbp),%rdi
call   1060 <shellGetWhitespace@plt>
cmp    $0x0,%eax
je     11b7 <shellParse+0x57>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <shellParse+0xe1>
mov    -0x10(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1080 <shellGetUnsignedInteger@plt>
cmp    $0x0,%eax
je     11d9 <shellParse+0x79>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <shellParse+0xe1>
mov    -0x10(%rbp),%rdi
call   1040 <shellGetEol@plt>
cmp    $0x0,%eax
je     11f7 <shellParse+0x97>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <shellParse+0xe1>
mov    -0x14(%rbp),%edi
call   1030 <shellCmd_d@plt>
jmp    123a <shellParse+0xda>
mov    -0x10(%rbp),%rdi
call   1040 <shellGetEol@plt>
cmp    $0x0,%eax
je     1222 <shellParse+0xc2>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <shellParse+0xe1>
mov    $0x0,%al
call   1050 <shellCmd_q@plt>
jmp    123a <shellParse+0xda>
movl   $0xffffffff,-0x4(%rbp)
jmp    1241 <shellParse+0xe1>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<shellParse>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1070 <shellGetc@plt>
mov    $0xffffffff,%ebp
cmp    $0x71,%eax
je     11b0 <shellParse+0x50>
cmp    $0x64,%eax
jne    11c5 <shellParse+0x65>
mov    %rbx,%rdi
call   1060 <shellGetWhitespace@plt>
test   %eax,%eax
jne    11c5 <shellParse+0x65>
lea    0x4(%rsp),%rsi
mov    %rbx,%rdi
call   1080 <shellGetUnsignedInteger@plt>
test   %eax,%eax
jne    11c5 <shellParse+0x65>
mov    %rbx,%rdi
call   1040 <shellGetEol@plt>
test   %eax,%eax
jne    11c5 <shellParse+0x65>
mov    0x4(%rsp),%edi
call   1030 <shellCmd_d@plt>
xor    %ebp,%ebp
jmp    11c5 <shellParse+0x65>
mov    %rbx,%rdi
call   1040 <shellGetEol@plt>
test   %eax,%eax
jne    11c5 <shellParse+0x65>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <shellCmd_q@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.shell_data = type { i32 }
define i32 @shellParse(%struct.shell_data* %0) {
%2 = alloca i32
%3 = alloca %struct.shell_data*
%4 = alloca i32
store %struct.shell_data* %0, %struct.shell_data** %3
%5 = load %struct.shell_data*, %struct.shell_data** %3
%6 = call i32 @shellGetc(%struct.shell_data* %5)
switch i32 %6, label %32 [
i32 100, label %7
i32 113, label %25
]
7: ; preds = %1
%8 = load %struct.shell_data*, %struct.shell_data** %3
%9 = call i32 @shellGetWhitespace(%struct.shell_data* %8)
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
store i32 -1, i32* %2
br label %34
12: ; preds = %7
%13 = load %struct.shell_data*, %struct.shell_data** %3
%14 = call i32 @shellGetUnsignedInteger(%struct.shell_data* %13, i32* %4)
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 -1, i32* %2
br label %34
17: ; preds = %12
%18 = load %struct.shell_data*, %struct.shell_data** %3
%19 = call i32 @shellGetEol(%struct.shell_data* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %22
21: ; preds = %17
store i32 -1, i32* %2
br label %34
22: ; preds = %17
%23 = load i32, i32* %4
%24 = call i32 @shellCmd_d(i32 %23)
br label %33
25: ; preds = %1
%26 = load %struct.shell_data*, %struct.shell_data** %3
%27 = call i32 @shellGetEol(%struct.shell_data* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i32 -1, i32* %2
br label %34
30: ; preds = %25
%31 = call i32 (...) @shellCmd_q()
br label %33
32: ; preds = %1
store i32 -1, i32* %2
br label %34
33: ; preds = %30, %22
store i32 0, i32* %2
br label %34
34: ; preds = %33, %32, %29, %21, %16, %11
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
%struct.shell_data = type { i32 }
define i32 @shellParse(%struct.shell_data* %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = tail call i32 @shellGetc(%struct.shell_data* %0)
switch i32 %4, label %22 [
i32 100, label %5
i32 113, label %17
]
5: ; preds = %1
%6 = tail call i32 @shellGetWhitespace(%struct.shell_data* %0)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %22
8: ; preds = %5
%9 = call i32 @shellGetUnsignedInteger(%struct.shell_data* %0, i32* %2)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %8
%12 = call i32 @shellGetEol(%struct.shell_data* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %22
14: ; preds = %11
%15 = load i32, i32* %2
%16 = call i32 @shellCmd_d(i32 %15)
br label %22
17: ; preds = %1
%18 = tail call i32 @shellGetEol(%struct.shell_data* %0)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = tail call i32 (...) @shellCmd_q()
br label %22
22: ; preds = %14, %20, %1, %17, %11, %8, %5
%23 = phi i32 [ -1, %5 ], [ -1, %8 ], [ -1, %11 ], [ -1, %17 ], [ -1, %1 ], [ 0, %20 ], [ 0, %14 ]
ret i32 %23
}