#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 */
int EOF;
int /*<<< orphan*/ exit(int);
int getchar();
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ ungetc(int, int /*<<< orphan*/);
int readdelim(int d) {
  int c;
  while ((c = getchar()) != EOF) {
    if (c == d)
      return (1);
    if (c == ' ')
      continue;
    ungetc(c, stdin);
    return 0;
  }
  exit(1);
}


x86 assembly (clang, -O0):
<readdelim>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <getchar@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e94(%rip),%rcx
cmp    (%rcx),%eax
je     1198 <readdelim+0x68>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    116c <readdelim+0x3c>
movl   $0x1,-0x4(%rbp)
jmp    11a2 <readdelim+0x72>
cmpl   $0x20,-0xc(%rbp)
jne    117b <readdelim+0x4b>
jmp    113b <readdelim+0xb>
mov    -0xc(%rbp),%edi
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
call   1040 <ungetc@plt>
movl   $0x0,-0x4(%rbp)
jmp    11a2 <readdelim+0x72>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readdelim>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2ea3(%rip),%r14
nopl   (%rax)
xor    %eax,%eax
call   1030 <getchar@plt>
cmp    (%r14),%eax
je     1176 <readdelim+0x46>
cmp    %ebx,%eax
je     1169 <readdelim+0x39>
cmp    $0x20,%eax
je     1140 <readdelim+0x10>
mov    0x2e8c(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1040 <ungetc@plt>
xor    %eax,%eax
jmp    116e <readdelim+0x3e>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@EOF = global i32 0
@stdin = global i32 0
define i32 @readdelim(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
br label %5
5: ; preds = %17, %1
%6 = call i32 (...) @getchar()
store i32 %6, i32* %4
%7 = load i32, i32* @EOF
%8 = icmp ne i32 %6, %7
br i1 %8, label %9, label %22
9: ; preds = %5
%10 = load i32, i32* %4
%11 = load i32, i32* %3
%12 = icmp eq i32 %10, %11
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 1, i32* %2
br label %24
14: ; preds = %9
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 32
br i1 %16, label %17, label %18
17: ; preds = %14
br label %5
18: ; preds = %14
%19 = load i32, i32* %4
%20 = load i32, i32* @stdin
%21 = call i32 @ungetc(i32 %19, i32 %20)
store i32 0, i32* %2
br label %24
22: ; preds = %5
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %18, %13
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@EOF = global i32 0
@stdin = global i32 0
define i32 @readdelim(i32 %0) {
br label %2
2: ; preds = %8, %1
%3 = tail call i32 (...) @getchar()
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %3, %4
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = icmp eq i32 %3, %0
br i1 %7, label %15, label %8
8: ; preds = %6
%9 = icmp eq i32 %3, 32
br i1 %9, label %2, label %10
10: ; preds = %8
%11 = load i32, i32* @stdin
%12 = tail call i32 @ungetc(i32 %3, i32 %11)
br label %15
13: ; preds = %2
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %6, %10
%16 = phi i32 [ 0, %10 ], [ 1, %6 ]
ret i32 %16
}