#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;
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
char *getField(char *, int);
scalar_t__ strcmp(char *, char *);
char *strdup(char *);
char *getRoom(FILE *adventure_file, char *room_number) {
  char line[1024];
  char *current_room;
  fseek(adventure_file, 0, SEEK_SET);
  while (fgets(line, 1024, adventure_file)) {
    current_room = getField(line, 1);
    if (strcmp(current_room, room_number) == 0) {
      return strdup(line);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<getRoom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e72(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1060 <fseek@plt>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     11e2 <getRoom+0x92>
lea    -0x420(%rbp),%rdi
mov    $0x1,%esi
call   1030 <getField@plt>
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11dd <getRoom+0x8d>
lea    -0x420(%rbp),%rdi
call   1070 <strdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11ea <getRoom+0x9a>
jmp    1177 <getRoom+0x27>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRoom>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %rsi,%r15
mov    %rdi,%r12
mov    0x2e75(%rip),%rax
mov    (%rax),%edx
xor    %r14d,%r14d
xor    %esi,%esi
call   1060 <fseek@plt>
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r12,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     11bd <getRoom+0x6d>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1030 <getField@plt>
mov    %rax,%rdi
mov    %r15,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1180 <getRoom+0x30>
mov    %rsp,%rdi
call   1070 <strdup@plt>
mov    %rax,%r14
mov    %r14,%rax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i8* @getRoom(i32* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca [1024 x i8]
%7 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%8 = load i32*, i32** %4
%9 = load i32, i32* @SEEK_SET
%10 = call i32 @fseek(i32* %8, i32 0, i32 %9)
br label %11
11: ; preds = %26, %2
%12 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%13 = load i32*, i32** %4
%14 = call i64 @fgets(i8* %12, i32 1024, i32* %13)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %11
%17 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%18 = call i8* @getField(i8* %17, i32 1)
store i8* %18, i8** %7
%19 = load i8*, i8** %7
%20 = load i8*, i8** %5
%21 = call i64 @strcmp(i8* %19, i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%25 = call i8* @strdup(i8* %24)
store i8* %25, i8** %3
br label %28
26: ; preds = %16
br label %11
27: ; preds = %11
store i8* null, i8** %3
br label %28
28: ; preds = %27, %23
%29 = load i8*, i8** %3
ret i8* %29
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define noalias i8* @getRoom(i32* nocapture %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @fseek(i32* %0, i32 0, i32 %5)
br label %7
7: ; preds = %10, %2
%8 = call i64 @fgets(i8* %4, i32 1024, i32* %0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %16, label %10
10: ; preds = %7
%11 = call i8* @getField(i8* %4, i32 1)
%12 = call i64 @strcmp(i8* %11, i8* %1)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %7
14: ; preds = %10
%15 = call i8* @strdup(i8* %4)
br label %16
16: ; preds = %7, %14
%17 = phi i8* [ %15, %14 ], [ null, %7 ]
ret i8* %17
}