#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 */
char EOF;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
char getc(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int);
char *get_inc_fname(FILE *i) {
  int j = 0;
  char c;
  char *name;
  int size = 0;
  int pos;
  pos = ftell(i);
  printf("Start file-p position: %d\n", (int)ftell(i));
  while ((c = getc(i)) != EOF) {
    if (c == '<') {
      c = getc(i);
      while ((c != EOF) && (c != '>')) {
        size++;
        c = getc(i);
      }
      break;
    }
  }
  printf("Size of filename string is: %d\n", size);
  printf("Current file-p position: %d\n", (int)ftell(i));
  fseek(i, -(ftell(i) - pos), SEEK_CUR);
  printf("Reset the file-p position to: %d\n", (int)ftell(i));
  name = (char *)malloc(sizeof(char) * size);
  while ((c = getc(i)) != EOF && (j < size)) {
    if (c == '<') {
      c = getc(i);
      while ((c != EOF) && (c != '>')) {
        name[j] = c;
        j++;
        c = getc(i);
      }
      break;
    }
  }
  return name;
}


x86 assembly (clang, -O0):
<get_inc_fname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ftell@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ftell@plt>
mov    %eax,%esi
lea    0xe78(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%eax
mov    0x2e3d(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1223 <get_inc_fname+0xd3>
movsbl -0xd(%rbp),%eax
cmp    $0x3c,%eax
jne    121e <get_inc_fname+0xce>
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%ecx
mov    0x2e0e(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x21(%rbp)
je     11ef <get_inc_fname+0x9f>
movsbl -0xd(%rbp),%eax
cmp    $0x3e,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    11ff <get_inc_fname+0xaf>
jmp    1219 <get_inc_fname+0xc9>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0xd(%rbp)
jmp    11c7 <get_inc_fname+0x77>
jmp    1223 <get_inc_fname+0xd3>
jmp    118d <get_inc_fname+0x3d>
mov    -0x1c(%rbp),%esi
lea    0xdee(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <ftell@plt>
mov    %eax,%esi
lea    0xdf7(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <ftell@plt>
mov    -0x30(%rbp),%rdi
sub    -0x20(%rbp),%eax
xor    %esi,%esi
sub    %eax,%esi
mov    0x2d7c(%rip),%rax
mov    (%rax),%edx
call   1060 <fseek@plt>
mov    -0x8(%rbp),%rdi
call   1040 <ftell@plt>
mov    %eax,%esi
lea    0xdd3(%rip),%rdi
call   1030 <printf@plt>
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%ecx
mov    0x2d2d(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x31(%rbp)
je     12cf <get_inc_fname+0x17f>
mov    -0xc(%rbp),%eax
cmp    -0x1c(%rbp),%eax
setl   %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    12df <get_inc_fname+0x18f>
jmp    1362 <get_inc_fname+0x212>
movsbl -0xd(%rbp),%eax
cmp    $0x3c,%eax
jne    135d <get_inc_fname+0x20d>
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0xd(%rbp)
movsbl -0xd(%rbp),%ecx
mov    0x2cdd(%rip),%rax
movsbl (%rax),%edx
xor    %eax,%eax
cmp    %edx,%ecx
mov    %al,-0x32(%rbp)
je     1320 <get_inc_fname+0x1d0>
movsbl -0xd(%rbp),%eax
cmp    $0x3e,%eax
setne  %al
mov    %al,-0x32(%rbp)
mov    -0x32(%rbp),%al
test   $0x1,%al
jne    1330 <get_inc_fname+0x1e0>
jmp    1358 <get_inc_fname+0x208>
mov    -0xd(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <getc@plt>
mov    %al,-0xd(%rbp)
jmp    12f8 <get_inc_fname+0x1a8>
jmp    1362 <get_inc_fname+0x212>
jmp    129d <get_inc_fname+0x14d>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_inc_fname>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <ftell@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <ftell@plt>
lea    0xe8f(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    0x2e61(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    (%r15),%al
je     11d4 <get_inc_fname+0x84>
cmp    $0x3c,%al
jne    1190 <get_inc_fname+0x40>
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    $0x3e,%al
je     11d4 <get_inc_fname+0x84>
cmp    (%r15),%al
je     11d4 <get_inc_fname+0x84>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    $0x3e,%al
je     11d4 <get_inc_fname+0x84>
cmp    (%r15),%al
jne    11c0 <get_inc_fname+0x70>
lea    0xe40(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <ftell@plt>
lea    0xe4a(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <ftell@plt>
sub    %eax,%r14d
mov    0x2dde(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <fseek@plt>
mov    %rbx,%rdi
call   1040 <ftell@plt>
lea    0xe32(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <getc@plt>
test   %ebp,%ebp
je     1288 <get_inc_fname+0x138>
cmp    (%r15),%al
je     1288 <get_inc_fname+0x138>
cmp    $0x3c,%al
jne    1240 <get_inc_fname+0xf0>
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    $0x3e,%al
je     1288 <get_inc_fname+0x138>
cmp    (%r15),%al
je     1288 <get_inc_fname+0x138>
mov    %r14,%rbp
nopl   0x0(%rax)
mov    %al,0x0(%rbp)
mov    %rbx,%rdi
call   1070 <getc@plt>
cmp    $0x3e,%al
je     1288 <get_inc_fname+0x138>
add    $0x1,%rbp
cmp    (%r15),%al
jne    1270 <get_inc_fname+0x120>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Start file-p position: %d\0A\00"
@EOF = global i8 0
@.str.1 = [32 x i8] c"Size of filename string is: %d\0A\00"
@.str.2 = [29 x i8] c"Current file-p position: %d\0A\00"
@SEEK_CUR = global i32 0
@.str.3 = [34 x i8] c"Reset the file-p position to: %d\0A\00"
define i8* @get_inc_fname(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %2
store i32 0, i32* %3
store i32 0, i32* %6
%8 = load i32*, i32** %2
%9 = call i32 @ftell(i32* %8)
store i32 %9, i32* %7
%10 = load i32*, i32** %2
%11 = call i32 @ftell(i32* %10)
%12 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %45, %1
%14 = load i32*, i32** %2
%15 = call signext i8 @getc(i32* %14)
store i8 %15, i8* %4
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %16, %18
br i1 %19, label %20, label %46
20: ; preds = %13
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 60
br i1 %23, label %24, label %45
24: ; preds = %20
%25 = load i32*, i32** %2
%26 = call signext i8 @getc(i32* %25)
store i8 %26, i8* %4
br label %27
27: ; preds = %39, %24
%28 = load i8, i8* %4
%29 = sext i8 %28 to i32
%30 = load i8, i8* @EOF
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %29, %31
br i1 %32, label %33, label %37
33: ; preds = %27
%34 = load i8, i8* %4
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 62
br label %37
37: ; preds = %33, %27
%38 = phi i1 [ false, %27 ], [ %36, %33 ]
br i1 %38, label %39, label %44
39: ; preds = %37
%40 = load i32, i32* %6
%41 = add nsw i32 %40, 1
store i32 %41, i32* %6
%42 = load i32*, i32** %2
%43 = call signext i8 @getc(i32* %42)
store i8 %43, i8* %4
br label %27
44: ; preds = %37
br label %46
45: ; preds = %20
br label %13
46: ; preds = %44, %13
%47 = load i32, i32* %6
%48 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %47)
%49 = load i32*, i32** %2
%50 = call i32 @ftell(i32* %49)
%51 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %50)
%52 = load i32*, i32** %2
%53 = load i32*, i32** %2
%54 = call i32 @ftell(i32* %53)
%55 = load i32, i32* %7
%56 = sub nsw i32 %54, %55
%57 = sub nsw i32 0, %56
%58 = load i32, i32* @SEEK_CUR
%59 = call i32 @fseek(i32* %52, i32 %57, i32 %58)
%60 = load i32*, i32** %2
%61 = call i32 @ftell(i32* %60)
%62 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %61)
%63 = load i32, i32* %6
%64 = sext i32 %63 to i64
%65 = mul i64 1, %64
%66 = trunc i64 %65 to i32
%67 = call i64 @malloc(i32 %66)
%68 = inttoptr i64 %67 to i8*
store i8* %68, i8** %5
br label %69
69: ; preds = %112, %46
%70 = load i32*, i32** %2
%71 = call signext i8 @getc(i32* %70)
store i8 %71, i8* %4
%72 = sext i8 %71 to i32
%73 = load i8, i8* @EOF
%74 = sext i8 %73 to i32
%75 = icmp ne i32 %72, %74
br i1 %75, label %76, label %80
76: ; preds = %69
%77 = load i32, i32* %3
%78 = load i32, i32* %6
%79 = icmp slt i32 %77, %78
br label %80
80: ; preds = %76, %69
%81 = phi i1 [ false, %69 ], [ %79, %76 ]
br i1 %81, label %82, label %113
82: ; preds = %80
%83 = load i8, i8* %4
%84 = sext i8 %83 to i32
%85 = icmp eq i32 %84, 60
br i1 %85, label %86, label %112
86: ; preds = %82
%87 = load i32*, i32** %2
%88 = call signext i8 @getc(i32* %87)
store i8 %88, i8* %4
br label %89
89: ; preds = %101, %86
%90 = load i8, i8* %4
%91 = sext i8 %90 to i32
%92 = load i8, i8* @EOF
%93 = sext i8 %92 to i32
%94 = icmp ne i32 %91, %93
br i1 %94, label %95, label %99
95: ; preds = %89
%96 = load i8, i8* %4
%97 = sext i8 %96 to i32
%98 = icmp ne i32 %97, 62
br label %99
99: ; preds = %95, %89
%100 = phi i1 [ false, %89 ], [ %98, %95 ]
br i1 %100, label %101, label %111
101: ; preds = %99
%102 = load i8, i8* %4
%103 = load i8*, i8** %5
%104 = load i32, i32* %3
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %103, i64 %105
store i8 %102, i8* %106
%107 = load i32, i32* %3
%108 = add nsw i32 %107, 1
store i32 %108, i32* %3
%109 = load i32*, i32** %2
%110 = call signext i8 @getc(i32* %109)
store i8 %110, i8* %4
br label %89
111: ; preds = %99
br label %113
112: ; preds = %82
br label %69
113: ; preds = %111, %80
%114 = load i8*, i8** %5
ret i8* %114
}

LLVM IR (-O2):
@.str = [27 x i8] c"Start file-p position: %d\0A\00"
@EOF = global i8 0
@.str.1 = [32 x i8] c"Size of filename string is: %d\0A\00"
@.str.2 = [29 x i8] c"Current file-p position: %d\0A\00"
@SEEK_CUR = global i32 0
@.str.3 = [34 x i8] c"Reset the file-p position to: %d\0A\00"
define i8* @get_inc_fname(i32* nocapture %0) {
%2 = tail call i32 @ftell(i32* %0)
%3 = tail call i32 @ftell(i32* %0)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %5
5: ; preds = %9, %1
%6 = tail call signext i8 @getc(i32* %0)
%7 = load i8, i8* @EOF
%8 = icmp eq i8 %6, %7
br i1 %8, label %25, label %9
9: ; preds = %5
%10 = icmp eq i8 %6, 60
br i1 %10, label %11, label %5
11: ; preds = %9
%12 = tail call signext i8 @getc(i32* %0)
%13 = load i8, i8* @EOF
%14 = icmp ne i8 %12, %13
%15 = icmp ne i8 %12, 62
%16 = and i1 %15, %14
br i1 %16, label %17, label %25
17: ; preds = %11, %17
%18 = phi i32 [ %19, %17 ], [ 0, %11 ]
%19 = add nuw nsw i32 %18, 1
%20 = tail call signext i8 @getc(i32* %0)
%21 = load i8, i8* @EOF
%22 = icmp ne i8 %20, %21
%23 = icmp ne i8 %20, 62
%24 = and i1 %23, %22
br i1 %24, label %17, label %25
25: ; preds = %5, %17, %11
%26 = phi i32 [ 0, %11 ], [ %19, %17 ], [ 0, %5 ]
%27 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = tail call i32 @ftell(i32* %0)
%29 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = tail call i32 @ftell(i32* %0)
%31 = sub i32 %2, %30
%32 = load i32, i32* @SEEK_CUR
%33 = tail call i32 @fseek(i32* %0, i32 %31, i32 %32)
%34 = tail call i32 @ftell(i32* %0)
%35 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = tail call i64 @malloc(i32 %26)
%37 = inttoptr i64 %36 to i8*
%38 = icmp ne i32 %26, 0
br label %39
39: ; preds = %44, %25
%40 = tail call signext i8 @getc(i32* %0)
%41 = load i8, i8* @EOF
%42 = icmp ne i8 %40, %41
%43 = and i1 %38, %42
br i1 %43, label %44, label %62
44: ; preds = %39
%45 = icmp eq i8 %40, 60
br i1 %45, label %46, label %39
46: ; preds = %44
%47 = tail call signext i8 @getc(i32* %0)
%48 = load i8, i8* @EOF
%49 = icmp ne i8 %47, %48
%50 = icmp ne i8 %47, 62
%51 = and i1 %50, %49
br i1 %51, label %52, label %62
52: ; preds = %46, %52
%53 = phi i64 [ %56, %52 ], [ 0, %46 ]
%54 = phi i8 [ %57, %52 ], [ %47, %46 ]
%55 = getelementptr inbounds i8, i8* %37, i64 %53
store i8 %54, i8* %55
%56 = add nuw i64 %53, 1
%57 = tail call signext i8 @getc(i32* %0)
%58 = load i8, i8* @EOF
%59 = icmp ne i8 %57, %58
%60 = icmp ne i8 %57, 62
%61 = and i1 %60, %59
br i1 %61, label %52, label %62
62: ; preds = %39, %52, %46
ret i8* %37
}