#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*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
void readstr(FILE *f, char *string) {
  do {
    if (fgets(string, 255, f) == NULL)
      perror("fgets");
  } while ((string[0] == '/') || (string[0] == '\n'));
}


x86 assembly (clang, -O0):
<readstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0xff,%esi
call   1030 <fgets@plt>
cmp    $0x0,%rax
jne    1158 <readstr+0x38>
lea    0xead(%rip),%rdi
call   1040 <perror@plt>
jmp    115d <readstr+0x3d>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2f,%ecx
mov    %al,-0x11(%rbp)
je     1182 <readstr+0x62>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1130 <readstr+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readstr>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xece(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1030 <fgets@plt>
test   %rax,%rax
je     1162 <readstr+0x42>
movzbl (%rbx),%eax
cmp    $0xa,%al
je     1140 <readstr+0x20>
cmp    $0x2f,%al
je     1140 <readstr+0x20>
jmp    116c <readstr+0x4c>
mov    %r15,%rdi
call   1040 <perror@plt>
jmp    1155 <readstr+0x35>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"fgets\00"
define void @readstr(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
br label %5
5: ; preds = %25, %2
%6 = load i8*, i8** %4
%7 = load i32*, i32** %3
%8 = call i32* @fgets(i8* %6, i32 255, i32* %7)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %5
br label %13
13: ; preds = %12
%14 = load i8*, i8** %4
%15 = getelementptr inbounds i8, i8* %14, i64 0
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 47
br i1 %18, label %25, label %19
19: ; preds = %13
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 10
br label %25
25: ; preds = %19, %13
%26 = phi i1 [ true, %13 ], [ %24, %19 ]
br i1 %26, label %5, label %27
27: ; preds = %25
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"fgets\00"
define void @readstr(i32* nocapture %0, i8* %1) {
br label %3
3: ; preds = %10, %2
%4 = tail call i32* @fgets(i8* %1, i32 255, i32* %0)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %8
6: ; preds = %3
%7 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %3, %6
%9 = load i8, i8* %1
switch i8 %9, label %11 [
i8 47, label %10
i8 10, label %10
]
10: ; preds = %8, %8
br label %3
11: ; preds = %8
ret void
}