#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int getc(int /*<<< orphan*/ *);
scalar_t__ isdigit(int);
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/ *);
int getd(FILE *fp, int *x, int *y) {
  static int c;
  while ((c = getc(fp)) == '\n' || c == ' ')
    ;
  if (isdigit(c)) {
    ungetc(c, fp);
    fscanf(fp, "%d %d", x, y);
    return (1);
  } else
    return (0);
}


x86 assembly (clang, -O0):
<getd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,%ecx
mov    %ecx,0x2edf(%rip)
mov    $0x1,%al
cmp    $0xa,%ecx
mov    %al,-0x21(%rbp)
je     1180 <getd+0x40>
cmpl   $0x20,0x2eca(%rip)
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1190 <getd+0x50>
jmp    1195 <getd+0x55>
jmp    1154 <getd+0x14>
mov    0x2ea9(%rip),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11dd <getd+0x9d>
mov    0x2e94(%rip),%edi
mov    -0x10(%rbp),%rsi
call   1050 <ungetc@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xe34(%rip),%rsi
call   1040 <fscanf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11e4 <getd+0xa4>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getd>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xchg   %ax,%ax
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,0x2ee6(%rip)
cmp    $0xa,%eax
je     1150 <getd+0x10>
cmp    $0x20,%eax
je     1150 <getd+0x10>
mov    %eax,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     119e <getd+0x5e>
mov    0x2eca(%rip),%edi
mov    %rbx,%rsi
call   1050 <ungetc@plt>
lea    0xe77(%rip),%rsi
mov    %rbx,%rdi
mov    %r15,%rdx
mov    %r14,%rcx
call   1040 <fscanf@plt>
mov    $0x1,%eax
jmp    11a0 <getd+0x60>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@getd.c = internal global i32 0
@.str = [6 x i8] c"%d %d\00"
define i32 @getd(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
br label %8
8: ; preds = %17, %3
%9 = load i32*, i32** %5
%10 = call i32 @getc(i32* %9)
store i32 %10, i32* @getd.c
%11 = icmp eq i32 %10, 10
br i1 %11, label %15, label %12
12: ; preds = %8
%13 = load i32, i32* @getd.c
%14 = icmp eq i32 %13, 32
br label %15
15: ; preds = %12, %8
%16 = phi i1 [ true, %8 ], [ %14, %12 ]
br i1 %16, label %17, label %18
17: ; preds = %15
br label %8
18: ; preds = %15
%19 = load i32, i32* @getd.c
%20 = call i64 @isdigit(i32 %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %18
%23 = load i32, i32* @getd.c
%24 = load i32*, i32** %5
%25 = call i32 @ungetc(i32 %23, i32* %24)
%26 = load i32*, i32** %5
%27 = load i32*, i32** %6
%28 = load i32*, i32** %7
%29 = call i32 @fscanf(i32* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %27, i32* %28)
store i32 1, i32* %4
br label %31
30: ; preds = %18
store i32 0, i32* %4
br label %31
31: ; preds = %30, %22
%32 = load i32, i32* %4
ret i32 %32
}

LLVM IR (-O2):
@getd.c = internal unnamed_addr global i32 0
@.str = [6 x i8] c"%d %d\00"
define i32 @getd(i32* nocapture %0, i32* %1, i32* %2) {
br label %4
4: ; preds = %6, %3
%5 = tail call i32 @getc(i32* %0)
store i32 %5, i32* @getd.c
switch i32 %5, label %7 [
i32 32, label %6
i32 10, label %6
]
6: ; preds = %4, %4
br label %4
7: ; preds = %4
%8 = tail call i64 @isdigit(i32 %5)
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = load i32, i32* @getd.c
%12 = tail call i32 @ungetc(i32 %11, i32* %0)
%13 = tail call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* %1, i32* %2)
br label %14
14: ; preds = %7, %10
%15 = phi i32 [ 1, %10 ], [ 0, %7 ]
ret i32 %15
}