#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 */
scalar_t__ feof(int /*<<< orphan*/ *);
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ i3_log(char *, char *);
scalar_t__ isspace(char);
char i3fread_letter(FILE *fp) {
  char c;
  do {
    if (feof(fp)) {
      i3_log("%s", "i3fread_letter: EOF encountered on read.");
      return '\0';
    }
    c = getc(fp);
  } while (isspace(c));
  return c;
}


x86 assembly (clang, -O0):
<i3fread_letter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <feof@plt>
cmp    $0x0,%rax
je     117b <i3fread_letter+0x3b>
lea    0xe9a(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1060 <i3_log@plt>
movb   $0x0,-0x1(%rbp)
jmp    11a0 <i3fread_letter+0x60>
mov    -0x10(%rbp),%rdi
call   1050 <getc@plt>
mov    %al,-0x11(%rbp)
movsbl -0x11(%rbp),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
jne    114c <i3fread_letter+0xc>
mov    -0x11(%rbp),%al
mov    %al,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i3fread_letter>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <feof@plt>
test   %rax,%rax
jne    1176 <i3fread_letter+0x36>
mov    %rbx,%rdi
call   1050 <getc@plt>
mov    %eax,%ebp
movsbl %al,%edi
call   1030 <isspace@plt>
test   %rax,%rax
jne    1150 <i3fread_letter+0x10>
jmp    118b <i3fread_letter+0x4b>
lea    0xe83(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1060 <i3_log@plt>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [41 x i8] c"i3fread_letter: EOF encountered on read.\00"
define signext i8 @i3fread_letter(i32* %0) {
%2 = alloca i8
%3 = alloca i32*
%4 = alloca i8
store i32* %0, i32** %3
br label %5
5: ; preds = %14, %1
%6 = load i32*, i32** %3
%7 = call i64 @feof(i32* %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = call i32 @i3_log(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
store i8 0, i8* %2
br label %20
11: ; preds = %5
%12 = load i32*, i32** %3
%13 = call signext i8 @getc(i32* %12)
store i8 %13, i8* %4
br label %14
14: ; preds = %11
%15 = load i8, i8* %4
%16 = call i64 @isspace(i8 signext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %5, label %18
18: ; preds = %14
%19 = load i8, i8* %4
store i8 %19, i8* %2
br label %20
20: ; preds = %18, %9
%21 = load i8, i8* %2
ret i8 %21
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [41 x i8] c"i3fread_letter: EOF encountered on read.\00"
define signext i8 @i3fread_letter(i32* nocapture %0) {
br label %2
2: ; preds = %7, %1
%3 = tail call i64 @feof(i32* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @i3_log(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %11
7: ; preds = %2
%8 = tail call signext i8 @getc(i32* %0)
%9 = tail call i64 @isspace(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %2
11: ; preds = %7, %5
%12 = phi i8 [ 0, %5 ], [ %8, %7 ]
ret i8 %12
}