#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*/ SEEK_SET;
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
long row_num(FILE *fp, char symbol, char *buf, long pos_in_file) {
  fseek(fp, pos_in_file, SEEK_SET);
  for (;;) {
    if (fgets(buf, 10000, fp) == NULL) {
      memset(buf, 0, 10000);
      break;
    }
    if (buf[0] == symbol)
      break;
  }
  return ftell(fp);
}


x86 assembly (clang, -O0):
<row_num>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2e77(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x2710,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
jne    11a1 <row_num+0x61>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x2710,%edx
call   1030 <memset@plt>
jmp    11be <row_num+0x7e>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jne    11b9 <row_num+0x79>
jmp    11be <row_num+0x7e>
jmp    1170 <row_num+0x30>
mov    -0x8(%rbp),%rdi
call   1050 <ftell@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<row_num>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%ebp
mov    %rdi,%r14
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
mov    %rcx,%rsi
call   1060 <fseek@plt>
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x2710,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     117c <row_num+0x3c>
cmp    %bpl,(%rbx)
jne    1160 <row_num+0x20>
jmp    118b <row_num+0x4b>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2710,%edx
call   1030 <memset@plt>
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <ftell@plt>

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i64 @row_num(i32* %0, i8 signext %1, i8* %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i64
store i32* %0, i32** %5
store i8 %1, i8* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%9 = load i32*, i32** %5
%10 = load i64, i64* %8
%11 = load i32, i32* @SEEK_SET
%12 = call i32 @fseek(i32* %9, i64 %10, i32 %11)
br label %13
13: ; preds = %30, %4
%14 = load i8*, i8** %7
%15 = load i32*, i32** %5
%16 = call i32* @fgets(i8* %14, i32 10000, i32* %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8*, i8** %7
%20 = call i32 @memset(i8* %19, i32 0, i32 10000)
br label %31
21: ; preds = %13
%22 = load i8*, i8** %7
%23 = getelementptr inbounds i8, i8* %22, i64 0
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = load i8, i8* %6
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %25, %27
br i1 %28, label %29, label %30
29: ; preds = %21
br label %31
30: ; preds = %21
br label %13
31: ; preds = %29, %18
%32 = load i32*, i32** %5
%33 = call i64 @ftell(i32* %32)
ret i64 %33
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i64 @row_num(i32* nocapture %0, i8 signext %1, i8* %2, i64 %3) {
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @fseek(i32* %0, i64 %3, i32 %5)
br label %7
7: ; preds = %12, %4
%8 = tail call i32* @fgets(i8* %2, i32 10000, i32* %0)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @memset(i8* %2, i32 0, i32 10000)
br label %15
12: ; preds = %7
%13 = load i8, i8* %2
%14 = icmp eq i8 %13, %1
br i1 %14, label %15, label %7
15: ; preds = %12, %10
%16 = tail call i64 @ftell(i32* %0)
ret i64 %16
}