#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*/ getIdentifierFromLine(char *);
char *getLine(int /*<<< orphan*/ *, char *);
char *malloc(int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ strcmp(char *, int /*<<< orphan*/);
int getLineNumberWithIdent(FILE *file, char *ident) {
  char *line = malloc(sizeof(char) * 30);
  int i = 0;
  while ((line = getLine(file, line))) {
    if (!strcmp(ident, getIdentifierFromLine(line))) {
      break;
    }
    i++;
  }
  rewind(file);
  return i;
}


x86 assembly (clang, -O0):
<getLineNumberWithIdent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1e,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <getLine@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11c8 <getLineNumberWithIdent+0x78>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <getIdentifierFromLine@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11ba <getLineNumberWithIdent+0x6a>
jmp    11c8 <getLineNumberWithIdent+0x78>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1175 <getLineNumberWithIdent+0x25>
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0x1c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getLineNumberWithIdent>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x1e,%edi
call   1060 <malloc@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1070 <getLine@plt>
test   %rax,%rax
je     11ae <getLineNumberWithIdent+0x5e>
mov    %rax,%rbx
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    %rbx,%rdi
call   1050 <getIdentifierFromLine@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <strcmp@plt>
test   %eax,%eax
je     11b0 <getLineNumberWithIdent+0x60>
add    $0x1,%ebp
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <getLine@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1180 <getLineNumberWithIdent+0x30>
jmp    11b0 <getLineNumberWithIdent+0x60>
xor    %ebp,%ebp
mov    %r15,%rdi
call   1030 <rewind@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @getLineNumberWithIdent(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
%7 = call i8* @malloc(i32 30)
store i8* %7, i8** %5
store i32 0, i32* %6
br label %8
8: ; preds = %20, %2
%9 = load i32*, i32** %3
%10 = load i8*, i8** %5
%11 = call i8* @getLine(i32* %9, i8* %10)
store i8* %11, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = load i8*, i8** %4
%15 = load i8*, i8** %5
%16 = call i32 @getIdentifierFromLine(i8* %15)
%17 = call i32 @strcmp(i8* %14, i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %13
br label %23
20: ; preds = %13
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %8
23: ; preds = %19, %8
%24 = load i32*, i32** %3
%25 = call i32 @rewind(i32* %24)
%26 = load i32, i32* %6
ret i32 %26
}

LLVM IR (-O2):
define i32 @getLineNumberWithIdent(i32* %0, i8* %1) {
%3 = tail call dereferenceable_or_null(30) i8* @malloc(i32 30)
%4 = tail call i8* @getLine(i32* %0, i8* %3)
%5 = icmp eq i8* %4, null
br i1 %5, label %16, label %6
6: ; preds = %2, %12
%7 = phi i8* [ %14, %12 ], [ %4, %2 ]
%8 = phi i32 [ %13, %12 ], [ 0, %2 ]
%9 = tail call i32 @getIdentifierFromLine(i8* %7)
%10 = tail call i32 @strcmp(i8* %1, i32 %9)
%11 = icmp eq i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %6
%13 = add nuw nsw i32 %8, 1
%14 = tail call i8* @getLine(i32* %0, i8* %7)
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %6
16: ; preds = %12, %6, %2
%17 = phi i32 [ 0, %2 ], [ %8, %6 ], [ %13, %12 ]
%18 = tail call i32 @rewind(i32* %0)
ret i32 %17
}