#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_END;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int getIdInDescriptorBase(FILE *base, char *id, char *fileName) {
  char buffer[100] = {0};
  char currentId[100] = {0};
  char currentFileName[100] = {0};
  int find = 0;
  rewind(base);
  do {
    fscanf(base, "%s\t%s\n", currentFileName, currentId);
    if (strcmp(currentFileName, fileName) == 0) {
      strcpy(id, currentId);
      find = 1;
    }
  } while (!feof(base) && !find);
  fseek(base, 0, SEEK_END);
  return (find);
}


x86 assembly (clang, -O0):
<getIdInDescriptorBase>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0xf0(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
lea    -0x160(%rbp),%rdi
xor    %esi,%esi
mov    $0x64,%edx
call   1050 <memset@plt>
movl   $0x0,-0x164(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x8(%rbp),%rdi
lea    -0x160(%rbp),%rdx
lea    -0xf0(%rbp),%rcx
lea    0xe17(%rip),%rsi
call   1060 <fscanf@plt>
lea    -0x160(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1222 <getIdInDescriptorBase+0xb2>
mov    -0x10(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x1,-0x164(%rbp)
jmp    1227 <getIdInDescriptorBase+0xb7>
mov    -0x8(%rbp),%rdi
call   1080 <feof@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x165(%rbp)
jne    1255 <getIdInDescriptorBase+0xe5>
cmpl   $0x0,-0x164(%rbp)
setne  %al
xor    $0xff,%al
mov    %al,-0x165(%rbp)
mov    -0x165(%rbp),%al
test   $0x1,%al
jne    11d0 <getIdInDescriptorBase+0x60>
mov    -0x8(%rbp),%rdi
mov    0x2d7a(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1090 <fseek@plt>
mov    -0x164(%rbp),%eax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getIdInDescriptorBase>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rdx,%r14
mov    %rsi,0x8(%rsp)
mov    %rdi,%rbx
xorps  %xmm0,%xmm0
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xb0(%rsp)
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0x90(%rsp)
movaps %xmm0,0x80(%rsp)
movl   $0x0,0xe0(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x70(%rsp)
call   1040 <rewind@plt>
lea    0x10(%rsp),%r13
lea    0x80(%rsp),%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xdf6(%rip),%rsi
mov    %r13,%rdx
mov    %rbp,%rcx
call   1050 <fscanf@plt>
mov    %r13,%rdi
mov    %r14,%rsi
call   1060 <strcmp@plt>
mov    %rax,%r12
xor    %r15d,%r15d
test   %rax,%rax
jne    123e <getIdInDescriptorBase+0xde>
mov    0x8(%rsp),%rdi
mov    %rbp,%rsi
call   1030 <strcpy@plt>
mov    $0x1,%r15d
mov    %rbx,%rdi
call   1070 <feof@plt>
test   %eax,%eax
jne    124f <getIdInDescriptorBase+0xef>
test   %r12,%r12
jne    1200 <getIdInDescriptorBase+0xa0>
mov    0x2d92(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <fseek@plt>
mov    %r15d,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%s\09%s\0A\00"
@SEEK_END = global i32 0
define i32 @getIdInDescriptorBase(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [100 x i8]
%8 = alloca [100 x i8]
%9 = alloca [100 x i8]
%10 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%11 = bitcast [100 x i8]* %7 to i8*
%12 = bitcast [100 x i8]* %8 to i8*
%13 = bitcast [100 x i8]* %9 to i8*
store i32 0, i32* %10
%14 = load i32*, i32** %4
%15 = call i32 @rewind(i32* %14)
br label %16
16: ; preds = %38, %3
%17 = load i32*, i32** %4
%18 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%20 = call i32 @fscanf(i32* %17, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %18, i8* %19)
%21 = getelementptr inbounds [100 x i8], [100 x i8]* %9, i64 0, i64 0
%22 = load i8*, i8** %6
%23 = call i64 @strcmp(i8* %21, i8* %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %29
25: ; preds = %16
%26 = load i8*, i8** %5
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%28 = call i32 @strcpy(i8* %26, i8* %27)
store i32 1, i32* %10
br label %29
29: ; preds = %25, %16
br label %30
30: ; preds = %29
%31 = load i32*, i32** %4
%32 = call i32 @feof(i32* %31)
%33 = icmp ne i32 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %30
%35 = load i32, i32* %10
%36 = icmp ne i32 %35, 0
%37 = xor i1 %36, true
br label %38
38: ; preds = %34, %30
%39 = phi i1 [ false, %30 ], [ %37, %34 ]
br i1 %39, label %16, label %40
40: ; preds = %38
%41 = load i32*, i32** %4
%42 = load i32, i32* @SEEK_END
%43 = call i32 @fseek(i32* %41, i32 0, i32 %42)
%44 = load i32, i32* %10
ret i32 %44
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s\09%s\0A\00"
@SEEK_END = global i32 0
define i32 @getIdInDescriptorBase(i32* nocapture %0, i8* %1, i8* %2) {
%4 = alloca [100 x i8]
%5 = alloca [100 x i8]
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %5, i64 0, i64 0
%8 = tail call i32 @rewind(i32* %0)
br label %9
9: ; preds = %15, %3
%10 = call i32 @fscanf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %7, i8* %6)
%11 = call i64 @strcmp(i8* %7, i8* %2)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = call i32 @strcpy(i8* %1, i8* %6)
br label %15
15: ; preds = %9, %13
%16 = phi i32 [ 1, %13 ], [ 0, %9 ]
%17 = xor i1 %12, true
%18 = call i32 @feof(i32* %0)
%19 = icmp eq i32 %18, 0
%20 = select i1 %19, i1 %17, i1 false
br i1 %20, label %9, label %21
21: ; preds = %15
%22 = load i32, i32* @SEEK_END
%23 = call i32 @fseek(i32* %0, i32 0, i32 %22)
ret i32 %16
}