#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 EOF;
char getch();
scalar_t__ isdigit(char);
int /*<<< orphan*/ ungetch(char);
int getop(char s[]) {
  char c;
  int i = 0;
  while ((c = getch()) == ' ' || c == '\t')
    ;
  if (c < '0' || c > '9')
    return c;
  s[0] = c;
  while (isdigit(s[++i] = c = getch()))
    ;
  s[i] = '\0';
  if (c != EOF)
    ungetch(c);
  return '0';
}


x86 assembly (clang, -O0):
<getop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1050 <getch@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x19(%rbp)
je     116b <getop+0x3b>
movsbl -0x11(%rbp),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    117b <getop+0x4b>
jmp    1180 <getop+0x50>
jmp    1143 <getop+0x13>
movsbl -0x11(%rbp),%eax
cmp    $0x30,%eax
jl     119a <getop+0x6a>
movsbl -0x11(%rbp),%eax
cmp    $0x39,%eax
jle    11a6 <getop+0x76>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1215 <getop+0xe5>
mov    -0x11(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    $0x0,%al
call   1050 <getch@plt>
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %edx,%rdx
mov    %al,(%rcx,%rdx,1)
movsbl %al,%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11e3 <getop+0xb3>
jmp    11af <getop+0x7f>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movsbl -0x11(%rbp),%eax
mov    0x2dee(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     120e <getop+0xde>
movsbl -0x11(%rbp),%edi
call   1040 <ungetch@plt>
movl   $0x30,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getop>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getch@plt>
cmp    $0x9,%al
je     1140 <getop+0x10>
cmp    $0x20,%al
je     1140 <getop+0x10>
lea    -0x3a(%rax),%ecx
cmp    $0xf6,%cl
jae    115d <getop+0x2d>
movsbl %al,%r14d
jmp    11b3 <getop+0x83>
mov    %al,(%r14)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1050 <getch@plt>
mov    %eax,%ebx
mov    %al,0x1(%r14,%rbp,1)
add    $0x1,%rbp
movsbl %al,%r15d
mov    %r15d,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1170 <getop+0x40>
mov    %ebp,%eax
movb   $0x0,(%r14,%rax,1)
mov    0x2e47(%rip),%rax
mov    $0x30,%r14d
cmp    (%rax),%bl
je     11b3 <getop+0x83>
mov    %r15d,%edi
call   1040 <ungetch@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i8 0
define i32 @getop(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %5
br label %6
6: ; preds = %16, %1
%7 = call signext i8 (...) @getch()
store i8 %7, i8* %4
%8 = sext i8 %7 to i32
%9 = icmp eq i32 %8, 32
br i1 %9, label %14, label %10
10: ; preds = %6
%11 = load i8, i8* %4
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 9
br label %14
14: ; preds = %10, %6
%15 = phi i1 [ true, %6 ], [ %13, %10 ]
br i1 %15, label %16, label %17
16: ; preds = %14
br label %6
17: ; preds = %14
%18 = load i8, i8* %4
%19 = sext i8 %18 to i32
%20 = icmp slt i32 %19, 48
br i1 %20, label %25, label %21
21: ; preds = %17
%22 = load i8, i8* %4
%23 = sext i8 %22 to i32
%24 = icmp sgt i32 %23, 57
br i1 %24, label %25, label %28
25: ; preds = %21, %17
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
store i32 %27, i32* %2
br label %56
28: ; preds = %21
%29 = load i8, i8* %4
%30 = load i8*, i8** %3
%31 = getelementptr inbounds i8, i8* %30, i64 0
store i8 %29, i8* %31
br label %32
32: ; preds = %41, %28
%33 = call signext i8 (...) @getch()
store i8 %33, i8* %4
%34 = load i8*, i8** %3
%35 = load i32, i32* %5
%36 = add nsw i32 %35, 1
store i32 %36, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %34, i64 %37
store i8 %33, i8* %38
%39 = call i64 @isdigit(i8 signext %33)
%40 = icmp ne i64 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %32
br label %32
42: ; preds = %32
%43 = load i8*, i8** %3
%44 = load i32, i32* %5
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %43, i64 %45
store i8 0, i8* %46
%47 = load i8, i8* %4
%48 = sext i8 %47 to i32
%49 = load i8, i8* @EOF
%50 = sext i8 %49 to i32
%51 = icmp ne i32 %48, %50
br i1 %51, label %52, label %55
52: ; preds = %42
%53 = load i8, i8* %4
%54 = call i32 @ungetch(i8 signext %53)
br label %55
55: ; preds = %52, %42
store i32 48, i32* %2
br label %56
56: ; preds = %55, %25
%57 = load i32, i32* %2
ret i32 %57
}

LLVM IR (-O2):
@EOF = global i8 0
define i32 @getop(i8* nocapture writeonly %0) {
br label %2
2: ; preds = %4, %1
%3 = tail call signext i8 (...) @getch()
switch i8 %3, label %5 [
i8 32, label %4
i8 9, label %4
]
4: ; preds = %2, %2
br label %2
5: ; preds = %2
%6 = sext i8 %3 to i32
%7 = add i8 %3, -58
%8 = icmp ult i8 %7, -10
br i1 %8, label %24, label %9
9: ; preds = %5
store i8 %3, i8* %0
br label %10
10: ; preds = %10, %9
%11 = phi i64 [ %13, %10 ], [ 0, %9 ]
%12 = tail call signext i8 (...) @getch()
%13 = add nuw i64 %11, 1
%14 = getelementptr inbounds i8, i8* %0, i64 %13
store i8 %12, i8* %14
%15 = tail call i64 @isdigit(i8 signext %12)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %10
17: ; preds = %10
%18 = and i64 %13, 4294967295
%19 = getelementptr inbounds i8, i8* %0, i64 %18
store i8 0, i8* %19
%20 = load i8, i8* @EOF
%21 = icmp eq i8 %12, %20
br i1 %21, label %24, label %22
22: ; preds = %17
%23 = tail call i32 @ungetch(i8 signext %12)
br label %24
24: ; preds = %17, %22, %5
%25 = phi i32 [ %6, %5 ], [ 48, %22 ], [ 48, %17 ]
ret i32 %25
}