#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 */
scalar_t__ EOF;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
scalar_t__ malloc(int);
char *CarPosition(FILE *fic, int position, int longueur) {
  char *tabChar = (char *)malloc(longueur * sizeof(char));
  int i = 0;
  for (i = 0; i < longueur; i++) {
    fseek(fic, position + i, SEEK_SET);
    if (fscanf(fic, "%c", &tabChar[i]) == EOF)
      return NULL;
  }
  return tabChar;
}


x86 assembly (clang, -O0):
<CarPosition>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
movslq -0x18(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1040 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11d2 <CarPosition+0xa2>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
add    -0x24(%rbp),%esi
mov    0x2e58(%rip),%rax
mov    (%rax),%edx
call   1050 <fseek@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rdx
movslq -0x24(%rbp),%rax
add    %rax,%rdx
lea    0xe63(%rip),%rsi
call   1030 <fscanf@plt>
mov    0x2e3f(%rip),%rcx
cmp    (%rcx),%rax
jne    11bf <CarPosition+0x8f>
movq   $0x0,-0x8(%rbp)
jmp    11da <CarPosition+0xaa>
jmp    11c4 <CarPosition+0x94>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1163 <CarPosition+0x33>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CarPosition>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%r15d
mov    %rdi,%rbx
mov    %edx,%edi
call   1040 <malloc@plt>
mov    %rax,%r14
test   %ebp,%ebp
jle    11ac <CarPosition+0x7c>
mov    %ebp,%r12d
mov    %r15d,%ebp
mov    0x2e8a(%rip),%r13
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x2e61(%rip),%rax
mov    (%rax),%edx
lea    (%r15,%rbp,1),%esi
mov    %rbx,%rdi
call   1050 <fseek@plt>
lea    (%r14,%r15,1),%rdx
mov    %rbx,%rdi
lea    0xe6d(%rip),%rsi
call   1030 <fscanf@plt>
cmp    0x0(%r13),%rax
je     11a9 <CarPosition+0x79>
add    $0x1,%r15
cmp    %r15,%r12
jne    1170 <CarPosition+0x40>
jmp    11ac <CarPosition+0x7c>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%c\00"
@EOF = global i64 0
define i8* @CarPosition(i32* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load i32, i32* %7
%11 = sext i32 %10 to i64
%12 = mul i64 %11, 1
%13 = trunc i64 %12 to i32
%14 = call i64 @malloc(i32 %13)
%15 = inttoptr i64 %14 to i8*
store i8* %15, i8** %8
store i32 0, i32* %9
store i32 0, i32* %9
br label %16
16: ; preds = %37, %3
%17 = load i32, i32* %9
%18 = load i32, i32* %7
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %40
20: ; preds = %16
%21 = load i32*, i32** %5
%22 = load i32, i32* %6
%23 = load i32, i32* %9
%24 = add nsw i32 %22, %23
%25 = load i32, i32* @SEEK_SET
%26 = call i32 @fseek(i32* %21, i32 %24, i32 %25)
%27 = load i32*, i32** %5
%28 = load i8*, i8** %8
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = call i64 @fscanf(i32* %27, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %31)
%33 = load i64, i64* @EOF
%34 = icmp eq i64 %32, %33
br i1 %34, label %35, label %36
35: ; preds = %20
store i8* null, i8** %4
br label %42
36: ; preds = %20
br label %37
37: ; preds = %36
%38 = load i32, i32* %9
%39 = add nsw i32 %38, 1
store i32 %39, i32* %9
br label %16
40: ; preds = %16
%41 = load i8*, i8** %8
store i8* %41, i8** %4
br label %42
42: ; preds = %40, %35
%43 = load i8*, i8** %4
ret i8* %43
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
@.str = [3 x i8] c"%c\00"
@EOF = global i64 0
define i8* @CarPosition(i32* nocapture %0, i32 %1, i32 %2) {
%4 = tail call i64 @malloc(i32 %2)
%5 = inttoptr i64 %4 to i8*
%6 = icmp sgt i32 %2, 0
br i1 %6, label %7, label %22
7: ; preds = %3
%8 = zext i32 %2 to i64
br label %11
9: ; preds = %11
%10 = icmp eq i64 %21, %8
br i1 %10, label %22, label %11
11: ; preds = %7, %9
%12 = phi i64 [ 0, %7 ], [ %21, %9 ]
%13 = load i32, i32* @SEEK_SET
%14 = trunc i64 %12 to i32
%15 = add i32 %14, %1
%16 = tail call i32 @fseek(i32* %0, i32 %15, i32 %13)
%17 = getelementptr inbounds i8, i8* %5, i64 %12
%18 = tail call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = load i64, i64* @EOF
%20 = icmp eq i64 %18, %19
%21 = add nuw nsw i64 %12, 1
br i1 %20, label %22, label %9
22: ; preds = %11, %9, %3
%23 = phi i8* [ %5, %3 ], [ %5, %9 ], [ null, %11 ]
ret i8* %23
}