#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*/ *fopen(char *, char *);
char *get_line_from_file(int /*<<< orphan*/ *, char *);
char *get_value_from_line(char *, int);
int /*<<< orphan*/ perror(char *);
char *get_rbi_description(char rbi[2]) {
  char *ret = NULL;
  FILE *rbifile = fopen("rbi.csv", "r");
  char *line = NULL;
  if (rbifile == NULL) {
    perror("fopen");
    return NULL;
  }
  line = get_line_from_file(rbifile, rbi);
  if (line != NULL) {
    ret = get_value_from_line(line, 2);
  }
  return ret;
}


x86 assembly (clang, -O0):
<get_rbi_description>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
lea    0xea5(%rip),%rdi
lea    0xea6(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1197 <get_rbi_description+0x57>
lea    0xe85(%rip),%rdi
call   1060 <perror@plt>
movq   $0x0,-0x8(%rbp)
jmp    11cd <get_rbi_description+0x8d>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <get_line_from_file@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11c5 <get_rbi_description+0x85>
mov    -0x28(%rbp),%rdi
mov    $0x2,%esi
call   1030 <get_value_from_line@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rbi_description>:
push   %rbx
mov    %rdi,%rbx
lea    0xeb5(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     117a <get_rbi_description+0x3a>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <get_line_from_file@plt>
test   %rax,%rax
je     1186 <get_rbi_description+0x46>
mov    %rax,%rdi
mov    $0x2,%esi
pop    %rbx
jmp    1030 <get_value_from_line@plt>
lea    0xe89(%rip),%rdi
call   1060 <perror@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"rbi.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"fopen\00"
define i8* @get_rbi_description(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i8*
store i8* %0, i8** %3
store i8* null, i8** %4
%7 = call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %5
store i8* null, i8** %6
%8 = load i32*, i32** %5
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %2
br label %23
12: ; preds = %1
%13 = load i32*, i32** %5
%14 = load i8*, i8** %3
%15 = call i8* @get_line_from_file(i32* %13, i8* %14)
store i8* %15, i8** %6
%16 = load i8*, i8** %6
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i8*, i8** %6
%20 = call i8* @get_value_from_line(i8* %19, i32 2)
store i8* %20, i8** %4
br label %21
21: ; preds = %18, %12
%22 = load i8*, i8** %4
store i8* %22, i8** %2
br label %23
23: ; preds = %21, %10
%24 = load i8*, i8** %2
ret i8* %24
}

LLVM IR (-O2):
@.str = [8 x i8] c"rbi.csv\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"fopen\00"
define i8* @get_rbi_description(i8* %0) {
%2 = tail call i32* @fopen(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%3 = icmp eq i32* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %11
6: ; preds = %1
%7 = tail call i8* @get_line_from_file(i32* %2, i8* %0)
%8 = icmp eq i8* %7, null
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i8* @get_value_from_line(i8* %7, i32 2)
br label %11
11: ; preds = %6, %9, %4
%12 = phi i8* [ null, %4 ], [ %10, %9 ], [ null, %6 ]
ret i8* %12
}